So I spent some time building a rich text editor as a side project. Here’s some of what I learned which I’m sharing so you can avoid the bear traps and subsequent pain! Lets take a look…
Tag Archives: html5 canvas
Konva – Stage, Layer & Node snapshot and download
Getting snapshot images of the stage, layer and nodes is straightforward once you know a couple of tricks – here they are…
Konva – A workaround for inaccurate Path measuring
Long story short, Konvas path measuring for Path.getLength() and Path.getPointAtLength() methods are broken. There’s a simple and higher performance fix with SVG – lets take a look….
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”
Konva – an approach to drag-bounds control for a group
Writing drag bound functions is easy with rectangular shapes like Konva.Rects and Konva.Images- but Konva.Groups have a few more unexpected challenges. Lets take a look at some of the assumption traps around the Konva.Group and see what we can do.
HTML5 canvas – how to control scaling 101
So there I was, trying to place a new canvas element exactly over a Konva stage, which worked but the scaling was all wrong compared to the Konva output – what gives ?
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 – making a shape fill the view
The topic of how to get a shape to the front and center of the canvas view often arises. Here is my approach…
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”
Konva – editing path points
I wondered how to edit the points on a path or line – here’s an answer. Both the Konva Line and Path use a list of points to draw themselves. The Line takes a simple array of x & y values whilst the Path wants a data definition composed of SVG drawing commands. I choseContinue reading “Konva – editing path points”