| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <title>Skia WebTry</title> | 4 <title>Skia WebTry</title> |
| 5 <meta charset='utf-8' /> | 5 <meta charset='utf-8' /> |
| 6 <style type="text/css" media="screen"> | 6 <style type="text/css" media="screen"> |
| 7 .waiting, .waiting * { | 7 .waiting, .waiting * { |
| 8 cursor: wait; | 8 cursor: wait; |
| 9 } | 9 } |
| 10 textarea { | 10 textarea { |
| 11 margin-left: 0; | 11 margin-left: 0; |
| 12 border: solid 1px #ccc; | 12 border: solid 1px #ccc; |
| 13 color: green; | 13 color: green; |
| 14 } | 14 } |
| 15 pre, code { | 15 pre, code { |
| 16 padding: 0; | 16 padding: 0; |
| 17 color: green; | 17 color: green; |
| 18 } | 18 } |
| 19 #output { | 19 #output { |
| 20 color: #333; | 20 color: #333; |
| 21 } | 21 } |
| 22 </style> | 22 </style> |
| 23 </head> | 23 </head> |
| 24 <body> | 24 <body> |
| 25 <pre><code>#include "SkCanvas.h" | 25 <pre><code>#include "SkCanvas.h" |
| 26 | 26 |
| 27 void draw(SkCanvas* canvas) { | 27 void draw(SkCanvas* canvas) { |
| 28 <textarea name='code' id='code' rows='15' cols='80'>SkPaint p; | 28 <textarea name='code' id='code' rows='15' cols='80'>{{.UserCode}}</textarea> |
| 29 p.setColor(SK_ColorRED); | |
| 30 p.setAntiAlias(true); | |
| 31 p.setStyle(SkPaint::kStroke_Style); | |
| 32 p.setStrokeWidth(10); | |
| 33 | |
| 34 canvas->drawLine(20, 20, 100, 100, p); | |
| 35 </textarea> | |
| 36 } | 29 } |
| 37 </code></pre> | 30 </code></pre> |
| 38 | 31 |
| 39 <input type='button' value='Run' id='run'> | 32 <input type='button' value='Run' id='run'> |
| 40 | 33 |
| 41 <p>Image appears here:</p> | 34 <p>Image appears here:</p> |
| 42 <img id='img' src=''/> | 35 <img id='img' src=''/> |
| 43 | 36 |
| 44 <pre><code id='output'></code></pre> | 37 <pre><code id='output'></code></pre> |
| 45 | 38 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 70 // image to display. | 63 // image to display. |
| 71 endWait(); | 64 endWait(); |
| 72 console.log(e.target.response); | 65 console.log(e.target.response); |
| 73 body = JSON.parse(e.target.response); | 66 body = JSON.parse(e.target.response); |
| 74 output.innerText = body.message; | 67 output.innerText = body.message; |
| 75 if (body.hasOwnProperty('img')) { | 68 if (body.hasOwnProperty('img')) { |
| 76 img.src = 'data:image/png;base64,' + body.img; | 69 img.src = 'data:image/png;base64,' + body.img; |
| 77 } else { | 70 } else { |
| 78 img.src = ''; | 71 img.src = ''; |
| 79 } | 72 } |
| 73 window.history.pushState(null, null, "/c/" + body.hash); |
| 80 } | 74 } |
| 81 | 75 |
| 82 function codeError(e) { | 76 function codeError(e) { |
| 83 endWait(); | 77 endWait(); |
| 84 alert('Something bad happened: ' + e); | 78 alert('Something bad happened: ' + e); |
| 85 } | 79 } |
| 86 | 80 |
| 87 run.addEventListener('click', onSubmitCode); | 81 run.addEventListener('click', onSubmitCode); |
| 88 function onSubmitCode() { | 82 function onSubmitCode() { |
| 89 beginWait(); | 83 beginWait(); |
| 90 var req = new XMLHttpRequest(); | 84 var req = new XMLHttpRequest(); |
| 91 req.addEventListener('load', codeComplete); | 85 req.addEventListener('load', codeComplete); |
| 92 req.addEventListener('error', codeError); | 86 req.addEventListener('error', codeError); |
| 93 req.overrideMimeType('application/json'); | 87 req.overrideMimeType('application/json'); |
| 94 req.open('POST', '.', true); | 88 req.open('POST', '.', true); |
| 95 req.send(code.value); | 89 req.send(code.value); |
| 96 } | 90 } |
| 97 </script> | 91 </script> |
| 98 </body> | 92 </body> |
| 99 </html> | 93 </html> |
| OLD | NEW |