clipPath with image inverts coordinate system.
See original GitHub issueCode
This component should be giving a rounded rect with an arrow at the bottom.
const Component = () => (
<Svg height="56" width="48" viewBox="0 0 48 56">
<Defs>
<ClipPath id="tooltip">
<G stroke="#fff" strokeWidth="1" fill="lime">
<Rect width="48px" height="48px" rx="5" ry="5" />
<Path d="M30 47 L25 56 L20 47" />
</G>
</ClipPath>
</Defs>
<Image
x="0"
y="0"
preserveAspectRatio="xMidYMid slice"
width="100%"
height="100%"
clipPath="url(#tooltip)"
href={img}
/>
);
Outcome
As you can see it put the arrow at the top when clipping an image.
Outcome with Rect instead of Image
If I simply replace Image with Rect I get the following
Code
const Component = () => (
<Svg height="56" width="48" viewBox="0 0 48 56">
<Defs>
<ClipPath id="tooltip">
<G stroke="#fff" strokeWidth="1" fill="lime">
<Rect width="48px" height="48px" rx="5" ry="5" />
<Path d="M30 47 L25 56 L20 47" />
</G>
</ClipPath>
</Defs>
<Rect width="100%" height="100%" clipPath="url(#tooltip)" fill="blue" />
</Svg>
);
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:6 (3 by maintainers)
Top Results From Across the Web
clipPath with image inverts coordinate system. #681 - GitHub
I see an inverted "y" with all Image s, with or without a clipPath specified. However, the clipPath appears to be applied to...
Read more >How to invert a css clip-path or animate hard-stops in SVG ...
You can use a still use a clipPath if you use it in its url form i.e. as svg markup. Draw the path...
Read more >Animating with Clip-Path - CSS-Tricks
The clip-path CSS property creates a clipping region that sets what part of an element should be shown. Parts that are inside the...
Read more >clip-path - CSS: Cascading Style Sheets - MDN Web Docs
The clip-path CSS property creates a clipping region that sets what part of an element should be shown. Parts that are inside the...
Read more >Clipping, Masking and Compositing - SVG 1.1 - W3C
A clipping path can be thought of as a mask wherein those pixels outside the clipping path are black with an alpha value...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
After a cursory look through the code, this inversion jumps out as a likely candidate.
I can’t dive much deeper today, but figured I’d drop this here in case somebody else his time to pick it up.
@msand - this appears to fix the problem with clipPath, but it turns out I was seeing two inverted-y issues. The other one an inversion of the
Image
’s “y” coordinate and is fixed by #763.