Love these types of projects! Very neat. Does the API use actual LEGO pieces? If so, could you render something and output a count of the pieces necessary so as to actually build it IRL? That’d be slick.
Here's a clock made with LegraJS:
<a href="https://legra-click.glitch.me/" rel="nofollow">https://legra-click.glitch.me/</a><p>Source: <a href="https://glitch.com/edit/#!/legra-click" rel="nofollow">https://glitch.com/edit/#!/legra-click</a>
I've done something like this in Go: <a href="https://github.com/esimov/legoizer" rel="nofollow">https://github.com/esimov/legoizer</a>
I'm reminded of one of my favorite music videos: <a href="https://youtu.be/fTH71AAxXmM" rel="nofollow">https://youtu.be/fTH71AAxXmM</a>
Looks very similar to legofy<p><a href="https://github.com/JuanPotato/Legofy" rel="nofollow">https://github.com/JuanPotato/Legofy</a>
How do you create something like this? I.e. what are the keywords I’d look for if I wanted to create my own graphics library from scratch like this?<p>Very cool btw
For paths and polygons you should just implement the 2d Path API<p><a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D#Paths" rel="nofollow">https://developer.mozilla.org/en-US/docs/Web/API/CanvasRende...</a><p><pre><code> context.moveTo(x,y);
context.lineTo(x,y);
context.closePath();</code></pre>
I wonder why no one, who implements some kind of JavaScript graphics library like this one, just mimics the Canvas 2D context API, so you could just drop this into your current application.
Cool!
For the image rendering, could you have a setting to constrain the colours used to currently-available Lego bricks? You might also offer dithering for better image matching.
What would the optimizations be for a larger canvas?<p>Does it redraw the whole canvas when an update is made* to a single line when there are several other lines on the canvas?<p>*edit for spelling mistakes
Great stuff. It would be awesome if you could select a brick type for a rectangle. You could make a 6x6 square and choose to fill it with 2x6 or 1x6 bricks.