techniq / techniq/layerchart

[Pattern] Support custom patterns when using Canvas

Open
#483 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

layer:canvas
Dominant language
TypeScript
Stars
1.3k
Forks
41
Avg merge
2d 19h
Merged PRs (30d)
16

Description

Currently if you define a custom pattern via patternContext() snippet it only works for Svg as it uses <def><pattern>...</pattern></def>

<Pattern width={4} height={4}>
  {#snippet patternContent()}
    <line x2="100%" class="stroke-surface-content" />
  {/snippet}

  {#snippet children({ pattern })}
    <Rect
      width={100}
      height={300}
      fill={pattern}
    />
  {/snippet}
</Pattern>

While the simplified patterns handle most of the common use cases, it would be nice to support custom patterns with <Canvas> at some point.

Using a second <Canvas> for the pattern and LayerChart primitives (Rect, Line, Circle, etc) and then pass a references to ctx.createPattern(..., 'repeat') would probably work...

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how patternContext() is handled for Svg and how Pattern and Canvas primitives are exposed. Compare that path with the proposed second Canvas and ctx.createPattern(..., 'repeat') approach; done means custom pattern content works with Canvas-based primitives.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
data-visualization
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.