Skip to content

Konva.Shape fill image does not respect Layer or Shape image smoothing setting #1958

@tanish2k09

Description

@tanish2k09

The scenario:
This one's simple. I'd like to create a repeated checkerboard pattern (for transparency background). The best way to do it in Konva seems to be using a Shape's repeating fill pattern with a simple 2x2 checkerboard image (and scaled using scaleX/Y).

The problem:
However, since Konva creates a dummy context to generate the fill pattern, it does not respect the image smoothing setting of the original Shape node or the parent Layer, and there seems to be no way to change that via config. The generate checkerboard fill pattern therefore looks very blurry due to bilinear interpolation scaled up from a 2x2 image when it should be a nearest-pixel interpolation.

The solution:

  1. Simply use the Shape node's image smoothing setting when creating the dummy context.
  2. Allow a separate fill-image-smoothing property that's used with the dummy context.

Solution 2 should be non-breaking.

Can submit a PR if needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions