4 ms·
That's really a question of the APIs you're using rather than the language. If you're using a browser, you don't even need JS to draw the line; you can just go
by kragen 11y ago
That's really a question of the APIs you're using rather than the language. If you're using a browser, you don't even need JS to draw the line; you can just go to this URL:
data:text/html,<svg><line x1=0 y1=30 x2=40 y2=50 stroke=black>
If you're using an API other than the browser, it can be super simple. Like, with processing.js, http://sketchpad.cc/sp/pad/view/zdsBK2b9xo/latest http://sketchpad.cc/sp/pad/view/zdsBK2b9xo/latest consists of:
line(0, 30, 40, 50);
and that works. (Although you could surely argue that the language of processing.js isn't itself JS, but you can invoke its facilities from JS.)
There are also clumsier ways to draw lines, like with DOM manipulation in SVG or drawing stuff on a <canvas>, and those might be desirable for the extra flexibility they give you. But you don't have to start with them.
- krapp 11y ago>and that works. Depends on the browser. IE > 8 doesn't support it.
- kragen 11y agoAre you saying processing.js doesn't work in IE after IE 8?
- krapp 11y agoIE 8 and above only supports image data URIs within CSS, link and image tags[0]. Processing.js probably works around that with Canvas or something. [0]https://developer.mozilla.org/en-US/docs/Web/HTTP/data_URIs https://developer.mozilla.org/en-US/docs/Web/HTTP/data_URIs