Let's say we have the following SVG path:
<path id="heart" d="M 10,30 A 20,20 0,0,1 50,30 A 20,20 0,0,1 90,30 Q 90,60 50,90 Q 10,60 10,30 z" />
I'm wondering if there is a way to fill only a portion of the area of this shape proportional to a given ratio. I do need to color exactly the amount of pixels equals to the ratio.
E.g., ratio = 0,6, then just fill the 60% of the pixels of the shape (starting from the bottom).
Edit:
I tried to implement the @RobertLongson's hint in the comment. There you go:
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
<linearGradient id="myGradient" gradientTransform="rotate(90)">
<stop offset="50%" stop-color="black" stop-opacity='0' />
<stop offset="50%" stop-color="black" />
</linearGradient>
<path id="heart" d="M 10,30 A 20,20 0,0,1 50,30 A 20,20 0,0,1 90,30 Q 90,60 50,90 Q 10,60 10,30 z" fill="url('#myGradient')" stroke="black" stroke-width="1" />
</svg>
However, if the ratio is 50%, this doesn't work. (i.e. we are not coloring the 50% of the pixels)