1

I am currently learning about the clip-path property but just don't get my head around the following problem:

I want to clip an element using the clip-path property with an SVG. This all works fine. But how can I move or scale the clipping position? I am aware of the "clipPathUnits" property, which is either "userSpaceOnUse" or "objectBoundingBox".

Using "userSpaceOnUse" the coordinate system is the box of the clipped element. Is there no way to transform the clipped position at all (without changing the path)?

The alternative "objectBoundingBox" requires that the path is in fractions between [0, 1]. So even if I use that, how can I then "move the clipped area" around?

<svg class="clip-svg" <!--width="500" height="500" viewBox="0 0 1000 1000"-->>
  <defs>
    <clipPath id="clip-shape" clipPathUnits="userSpaceOnUse" >
      <path fill="#454545" stroke="#000000" stroke-width="1.5794" stroke-miterlimit="10" d="M215,100.3c97.8-32.6,90.5-71.9,336-77.6
                    c92.4-2.1,98.1,81.6,121.8,116.4c101.7,149.9,53.5,155.9,14.7,178c-96.4,54.9,5.4,269-257,115.1c-57-33.5-203,46.3-263.7,20.1
                    c-33.5-14.5-132.5-45.5-95-111.1C125.9,246.6,98.6,139.1,215,100.3z"/>
    </clipPath>
  </defs>
</svg>

<style>
  .element {
  clip-path: url(#clip-shape);
  background-color: #42b983;
  width: 500px;
  height: 500px;
}
</style>

Btw: I read Sara Soueidans article which was very helpful, but it seems I miss something.

Much thanks for any help or pointers!

admi22
  • 63
  • 6
  • 1
    use it as mask like explained in the duplicate then you can easily adjust its size/position like a background image – Temani Afif Apr 10 '20 at 10:44

0 Answers0