News for hackers. Stuff that matters.
Re:Show HN: LegraJS – Draw using Lego-like brick shapes on C... by shihn on Sunday November 24, 2019 @02:58PM (#21622894)
That's the goal. Missing the 2d path api mainly. There are some interesting technical limitation for fill vs stroke. But for a fun hobby project, only limited time. :)
Re:Show HN: LegraJS – Draw using Lego-like brick shapes on C... by pacaro on Sunday November 24, 2019 @05:13PM (#21623807)
Can't you just replicate the entire 2d context api and pass through to an appropriately scaled (1px per block) offscreen canvas? Then pull the image from that and legoify it up to the display scale. That seems like a lot of unfun boilerplate to write, but ultimately an easier way to implement this, which would give all the gnarly parts of canvas without having to pull in external libraries ¯\_(ツ)_/¯
Re:Show HN: LegraJS – Draw using Lego-like brick shapes on C... by shihn on Sunday November 24, 2019 @05:23PM (#21623879)
True but having raw parts would give it more flexibility when animating or changing sections of the image. Especially when the canvas size is large, it won't be as optimal
Re:Show HN: LegraJS – Draw using Lego-like brick shapes on C... by pacaro on Sunday November 24, 2019 @05:55PM (#21624071)
Optimality may be a function of effort, but your approach definitely seems like a more engaging approach. It's a cool project, thank you.
Re:Show HN: LegraJS – Draw using Lego-like brick shapes on C... by shihn on Sunday November 24, 2019 @05:24PM (#21623883)
btw Legra does the offscreen canvas trick when rendering images, but not when drawing primitives