Filters with images
See original GitHub issueHey all, been loving Konva I’ve got a question about filters with images. Basically I need to load multiple images onto a layer in a stage and remove black bg by having a colour threshold and then fill white pixels as a colour. Also on scroll on a div these images would change to the next images in the list that I’ve already cached the image data
I’ve managed to get the Konva setup working with regular Konva.js without react loading the images, caching and adding filters within the onload, then redrawing.
Can we apply filters and threshold to multiple Konva <Image />
without having to add a custom component with onload state and lifecycle methods? I have the pixels/image already so I don’t need to load from a url.
The second FastLayer here contains the images I wish to manipulate with filters and the imaged change on scroll.
<Stage width={width} height={height}>
<FastLayer>
<Image x={x} y={y} image={image.getImage()} />
</FastLayer>
<FastLayer>
<Image x={x} y={y} image={arrayImage[0]} />
<Image x={x} y={y} image={arrayImage[1]} />
</FastLayer>
</Stage>
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
Do not create
<canvas>
elements insiderender()
function. It is possible that element can be “rendered” many times. Instead create canvas somewhere in lifecycle methods.Somethis like this:
@jamesg1 right, you have to call cache manually, but you can add filters inside
render()
function.I am closing the issue. Add a comment if you still have questions.