XamSvg-Samples icon indicating copy to clipboard operation
XamSvg-Samples copied to clipboard

SVG clipping is not working

Open b2yq opened this issue 3 years ago • 2 comments

Svg clipping is not working. Library is rendering image and ignroing clipping

Tested on Xamarin Android with Vapolia.Xamarin.Svg ver 4.1.0, 4.0.11, 4.0.2 Example svg:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->

<svg
   width="300"
   height="300"
   viewBox="0 0 79.374998 79.375002"
   version="1.1"
   id="svg5"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:svg="http://www.w3.org/2000/svg">
  <defs
     id="defs2">
    <clipPath
       clipPathUnits="userSpaceOnUse"
       id="clipPath1549">
      <path
         id="path1551"
         style="fill:#000086;stroke-width:0.926042;stroke-linecap:round;stroke-dasharray:3.70417, 3.70417"
         d="m 47.044642,3.8209318 h 40.676015 c 4.437083,0 8.009175,3.5720922 8.009175,8.0091752 v 32.311275 c 0,4.437081 -3.572092,8.009173 -8.009175,8.009173 H 47.044642 c -4.437084,0 -8.009176,-3.572092 -8.009176,-8.009173 V 11.830107 c 0,-4.437083 3.572092,-8.0091752 8.009176,-8.0091752 z" />
    </clipPath>
  </defs>
  <g
     id="layer1">
    <path
       id="path846"
       style="fill:#000000;fill-opacity:1;stroke-width:0.926042;stroke-linecap:round;stroke-dasharray:3.70417, 3.70417"
       d="M 68.260431,39.44854 A 31.600138,31.3936 0 0 1 36.660294,70.84214 31.600138,31.3936 0 0 1 5.0601559,39.44854 31.600138,31.3936 0 0 1 36.660294,8.0549393 31.600138,31.3936 0 0 1 68.260431,39.44854 Z"
       clip-path="url(#clipPath1549)"
       transform="translate(-17.555633,8.1582059)" />
  </g>
</svg>

Maybe i could tweak SVG manually somehow to force it working ?

b2yq avatar Apr 21 '22 21:04 b2yq

Yes clipping is not supported.

Save the Svg as « optimized » using Inkscape should replace the clipping with other compositions.

I have not heard of any Svg that can’t be used because of that.

The cause is : clipping can’t be drawn without a memory of already drawn objects, thus requiring more processing power and memory. The goal of this lib is to be as fast as possible with the smaller memory footprint possible. So the choice have been made to bypass all features requiring that.

Svg clipping is not working. Library is rendering image and ignroing clipping

Tested on Xamarin Android with Vapolia.Xamarin.Svg ver 4.1.0, 4.0.11, 4.0.2 Example svg:

<svg width="300" height="300" viewBox="0 0 79.374998 79.375002" version="1.1" id="svg5" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg"> <clipPath clipPathUnits="userSpaceOnUse" id="clipPath1549"> </clipPath>

Maybe i could tweak SVG manually somehow to force it working ?

. You are receiving this because you are subscribed to this thread.Message ID: @.***>

--

softlion avatar Apr 22 '22 04:04 softlion

i needed clipping for making inner-shadow, but your advice with saving svg as optimized did the trick, thanks!

b2yq avatar Jul 15 '22 14:07 b2yq