HTML5 Canvas Disable Perfect Drawing Tip
In some cases drawing on canvas has unexpected results. For example, let's draw a shape with fill, stroke and opacity. As strokes are drawn on top of fill, there's a line of half the size of the stroke inside the shape which is darker because it's the intersection of the fill and the stroke.
Probably that is not expected for you. So Konva
fixes such behavior with using buffer canvas.
In this case Konva
is doing these steps:
- Draw shape on buffer canvas
- Fill and stroke it WITHOUT opacity
- Apply opacity on layer's canvas
- Then draw on layer canvas result from buffer
But using buffer canvas might drop performance. So you can disable such fixing:
shape.perfectDrawEnabled(false);
See difference here:
- Vanilla
- React
- Vue