Konva – Mouse position + pixelRatio will mess up your day

A user recently had a query regarding how to get the pixel color data for a point on the stage. This is quite easy, but there’s a catch on high pixel density devices – think Apple devices like the MacBook and iPad. Here’s the solution… TLDR: Here’s the sample code – try it on yourContinue reading “Konva – Mouse position + pixelRatio will mess up your day”

Thinking about an approach to do-undo-redo

Coding a project that needs an undo-redo feature? Me too – here’s my thinking from the end of the development on the subject based on my learnings coding a rich text editor. Let’s take your code editor as an example. Whether it’s VS Code or NotePad++, if you you type a letter then delete itContinue reading “Thinking about an approach to do-undo-redo”

Konva – Point & shape collision detection

Someone asked about shape-point collision detection for the point under the mouse in a case where there are many shapes on the stage, and how to improve performance in relation to the Stage.getAllIntesections(), Stage.getIntersection() and Shape.intersects() methods. Here’s my explanation of those functions and an approach to improving hit detection. Just to be clear –Continue reading “Konva – Point & shape collision detection”

Konva – Star rating control

Someone on Discord asked it it was possible to make a star rating widget thing with Konva – the holes in the stars sounded like an interesting challenge. Here we go… TLDR: See the demo and code. This is a Vanilla JS solution, but @ivor adapted it for React here. The key technique for makingContinue reading “Konva – Star rating control”