Skip to content

Fix context paint on shape with zero-size bbox - #725

Merged
RazrFalcon merged 1 commit into
linebender:masterfrom
LaurenzV:bbox-fix
Mar 19, 2024
Merged

RazrFalcon merged 1 commit into
linebender:masterfrom
LaurenzV:bbox-fix

Conversation

@LaurenzV

Copy link
Copy Markdown
Collaborator

Consider the following SVG:

<svg id="svg1" viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
    <title>`context-stroke` on shape with zero-size bbox</title>

    <marker id="marker1" refX="10" refY="10" markerWidth="20" markerHeight="20">
        <path id="path-marker" d="M 10 0 16 20 H 4 Z" fill="context-stroke"/>
    </marker>
    <path id="path1" stroke="green" d="M 100 25 L 100 175"
          marker-end="url(#marker1)"/>
    <!-- image frame -->
    <rect id="frame" x="1" y="1" width="198" height="198" fill="none" stroke="black"/>
</svg>

Currently, it renders like this:
test

The reason being that in my previous implementation, I wrongly assumed that we always need to have a bbox for context-fill/context-stroke, which is not true for solid paints. Since a line doesn't have a bbox, this example would fail to render correctly previously. This PR fixes this:
test

@RazrFalcon
RazrFalcon merged commit 5b97397 into linebender:master Mar 19, 2024
@RazrFalcon

Copy link
Copy Markdown
Collaborator

Thanks. Zero width/height bbox are tricky to handle in SVG.

@LaurenzV
LaurenzV deleted the bbox-fix branch March 20, 2024 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants