question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

clipPath with image inverts coordinate system.

See original GitHub issue
Code

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.

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>
  );

image

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mike-marcaccicommented, Aug 15, 2018

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.

0reactions
mike-marcaccicommented, Aug 25, 2018

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found