mirror of
https://bjh21.me.uk/bedstead/.git
synced 2026-08-06 12:24:27 -04:00
webstead: SVG rendering by extremely crude regexps
This commit is contained in:
parent
1a49f8d120
commit
111484a4f1
@ -8,8 +8,16 @@
|
||||
document.getElementById("run").onclick = function(){
|
||||
Bedstead({
|
||||
arguments: document.getElementById("input").value.split(" "),
|
||||
print: function(text) {
|
||||
document.getElementById("output").textContent = text;
|
||||
print: function(charstring) {
|
||||
document.getElementById("output").textContent = charstring;
|
||||
document.getElementById("rendered")
|
||||
.setAttribute("d", charstring
|
||||
.replaceAll(/<!--(?:[^-]|-[^-])*-->/g, "")
|
||||
.replace(/^.* [hv]stem /, "")
|
||||
.replace(/^/, "m ")
|
||||
.replaceAll(/ rmoveto/g, "")
|
||||
.replaceAll(/ rlineto/g, "m")
|
||||
.replace(/ endchar/, ""));
|
||||
}
|
||||
});
|
||||
};
|
||||
@ -23,5 +31,10 @@
|
||||
<input type="button" id="run" value="Run!"/>
|
||||
</form>
|
||||
<p><code id="output"></code></p>
|
||||
<div>
|
||||
<svg width="600" height="1000" xmlns="http://www.w3.org/2000/svg">
|
||||
<path id="rendered" fill="currentColor"/>
|
||||
</svg>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user