diff options
author | Özgür Kesim <oec@codeblau.de> | 2025-04-21 13:04:10 +0200 |
---|---|---|
committer | Özgür Kesim <oec@codeblau.de> | 2025-04-21 13:04:10 +0200 |
commit | 212da96636e44272106a9bd8f85b2b40cd0b9423 (patch) | |
tree | 12dd1317c0a955de4d15f730ab183ed2271953d1 | |
parent | 1bc5dfb49aa7a5d7c369f9ee0d23cab05d48322f (diff) |
-rw-r--r-- | README.md | 4 | ||||
-rw-r--r-- | go.mod | 2 | ||||
-rw-r--r-- | index.html | 41 | ||||
-rw-r--r-- | tools.json | 4 |
4 files changed, 37 insertions, 14 deletions
@@ -17,8 +17,8 @@ Screenshots: ## Install - % go get github.com/oec/playdot - % cd $GOPATH/src/github.com/oec/playdot + % go get kesim.org/oec/playdot + % cd $GOPATH/src/kesim.org/oec/playdot % go build To run the server on port 9999 without TLS: @@ -1,3 +1,3 @@ module kesim.org/playdot -go 1.13 +go 1.23.0 @@ -13,7 +13,7 @@ body { height: 100vh; width: 100%; margin:0; - overflow:hidden; + overflow:auto; font-family:Calibri,Verdana,Sans-Serif; } @@ -31,7 +31,7 @@ body { overflow:auto; } -#run { +button { margin: 10pt; } @@ -41,8 +41,10 @@ body { } #output { - width: 100%; - height: 50vh; + /* width: 100%; */ + /* height: 50vh; */ + width: auto; + height: auto; overflow:auto; } @@ -55,6 +57,7 @@ body { svg { padding: 5px; + font-family:Calibri,Verdana,Sans-Serif; // border: 2px solid lime; } @@ -93,11 +96,12 @@ svg { {{ .Cur.Example }} </textarea> <div id="mid"> - <button id="run" class="button" onclick="run()" title="or ctrl-enter in editor">run</button> - <button id="save" class="button" onclick="share()" title="or ctrl-s in editor">share</button><span id="link"></span> - <input id="file" type="file" name="file" class="button"/> - <input id="scale" type ="range" min ="0.5" max="3" step ="0.1" value ="1"/> - <span id="doc"> + <button id="run" class="button" onclick="run()" title="or ctrl-enter in editor">run</button> + <button id="png" class="button" onclick="png()" title="or ctrl-i"/>png</button> + <button id="save" class="button" onclick="share()" title="or ctrl-s in editor">share</button><span id="link"></span> + <input id="file" class="button" type="file" name="file"/> + <input id="scale" type ="range" min ="0.5" max="3" step ="0.1" value ="1"/> + <span id="doc"> Documentation: {{ range $link, $text := .Cur.Documentation }} <a href="{{$link}}" target="_blank">{{$text}}</a> / @@ -105,6 +109,7 @@ svg { </span> </div> <div id="output"></div> + <canvas id="canvas"></canvas> <script> var output = document.getElementById("output"); var source = document.getElementById("source"); @@ -195,6 +200,24 @@ function share() { req.send(data); } +function png() { + let rect = output.children[0].getBoundingClientRect(); + let canvas = document.getElementById("canvas"); + let img = new Image(); + canvas.width = rect.width; + canvas.height = rect.height; + img.onload = () => { + let ctx = canvas.getContext('2d'); + ctx.font = "sans-serif"; + ctx.drawImage(img, 0, 0); + } + let cells = output.getElementsByTagName("text"); + for (let cell of cells) { + cell.setAttribute("font-family", "sans-serif"); + } + img.src = 'data:image/svg+xml;base64,' + btoa(output.innerHTML); +} + function load(id) { link.innerHtml = ""; var req = new XMLHttpRequest(); @@ -16,7 +16,7 @@ { "Name": "dpic", "Cmd": "dpic", - "Args": ["-z", "-v"], + "Args": ["-z", "-v"], "Suffix": ".pic", "BgColor": "Green", "Documentation": { @@ -29,7 +29,7 @@ { "Name": "povray", "Cmd": "povray", - "Args": ["+O-", "-D", "+A0.9", "+R3"], + "Args": ["+O-", "-D", "+A0.9", "+R3", "+ua"], "Suffix": ".pov", "NeedsFile": true, "ContentType": "image/png", |