News for hackers. Stuff that matters.
Re:Show HN: A resource for drawing complex primitives in Jav... by Lerc on Tuesday September 15, 2015 @06:35PM (#10223581)
Do you mind if I add these to my own library? https://github.com/Lerc/whio (MIT Licence)

It's a library I use when I teach kids JavaScript. It provides simple global functions to let them get started before they have to deal with ideas such as canvas context objects.

A Wiki page showing the functions they get to use is at http://fingswotidun.com/code/index.php/API

The functions you show here are exactly the sort of thing that would be useful for beginners.

Re:Show HN: A resource for drawing complex primitives in Jav... by carterehsmith on Tuesday September 15, 2015 @08:13PM (#10223921)
Nice, is that a LOGO programming language?
Re:Show HN: A resource for drawing complex primitives in Jav... by MJSplot_author on Tuesday September 15, 2015 @07:17PM (#10223725)
Go for it!
Re:Show HN: A resource for drawing complex primitives in Jav... by tantalor on Tuesday September 15, 2015 @04:00PM (#10222803)
Is the author aware of https://developer.mozilla.org/en-US/docs/Web/API/CanvasRende...?

Use rotate(), translate(), and scale() instead of doing your own math.

Re:Show HN: A resource for drawing complex primitives in Jav... by MJSplot_author on Tuesday September 15, 2015 @04:08PM (#10222848)
Yes, but this is as simple. It's not really my maths, it's quite standard stuff.

I'm more excited about Path2D[0] becoming adopted by more browsers.

[0] https://developer.mozilla.org/en-US/docs/Web/API/Path2D

Re:Show HN: A resource for drawing complex primitives in Jav... by runemadsen on Tuesday September 15, 2015 @04:07PM (#10222841)
Here's a resource I made for Processing. Very similar. http://printingcode.runemadsen.com/lecture-form-2/
Re:Show HN: A resource for drawing complex primitives in Jav... by artursapek on Tuesday September 15, 2015 @04:50PM (#10223095)
Nice work. Very interesting. Canvas is such a fun API.
Re:Show HN: A resource for drawing complex primitives in Jav... by tlb on Tuesday September 15, 2015 @04:12PM (#10222859)
Is it reliable to add methods to a built-in object like CanvasRenderingContext2D? I avoid it, but perhaps just out of superstition.
Re:Show HN: A resource for drawing complex primitives in Jav... by makepanic on Tuesday September 15, 2015 @04:50PM (#10223099)
You're right, extending the prototype of builtin objects is almost always a bad idea.

See String.prototype.contains → String.prototype.includes because mootools extended the String prototype[1]

[1] - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

Re:Show HN: A resource for drawing complex primitives in Jav... by MJSplot_author on Tuesday September 15, 2015 @05:01PM (#10223185)
If you know what you are doing it's fine, but it might cause incompatibility issues from namespace collisions.

You can rearrange the code to accept a context as the first argument if you are worried.

Re:Show HN: A resource for drawing complex primitives in Jav... by aikah on Tuesday September 15, 2015 @04:30PM (#10222969)
nice we need more lessons like this.