SVG icon indicating copy to clipboard operation
SVG copied to clipboard

Gradient presentation has changed since old version and contradicts with how browsers present it

Open the8thavatar opened this issue 2 years ago • 1 comments

Description

I found an inconsistency in presentation between the current library and an old version I had been using. The presentation with the current library is also inconsistent with how current browsers render the SVG. A gradient was defined with x1="0%" x"="20%" y1="0%" y2="100%".

The old library presented it like this: pic1 This is consistent with how browsers (Chrome and Firefox) and Inkscape (see Inkscape.org) present it.

The new library presents it like this: pic2

I cannot understand how a diagonal gradient is supposed to present from the description found on w3.org or Mozilla's notes, I only know that there is this inconsistency.

Example data

<svg width="100%" height="100%" viewBox="0 0 105 105" preserveAspectRatio="xMidYMid meet" kerning="0" xml:space="preserve" xmlns:xlink="http://www.w3.org/1999/xlink" style="stroke: black; fill: none;">
	<g id="13496" type="2" node="Yes">
		<title/>
		<desc>Rectangle</desc>
		<rect x="0" y="0" width="100" height="100" style=" fill: none; stroke: rgb(0,0,0); stroke-opacity: 0; stroke-width: 0;"/>
		<rect x="0" y="0" width="100" height="100" style=" fill:url(#Grad-b0d5ff-ffffff); stroke: #0082ec; stroke-opacity: 1.0; stroke-width: 1;"/>
		<defs>
			<linearGradient id="Grad-b0d5ff-ffffff" x1="0%" y1="0%" x2="20%" y2="100%">
				<stop offset="0%" stop-color="#b0d5ff" stop-opacity="1"/>
				<stop offset="100%" stop-color="#ffffff" stop-opacity="1"/>
			</linearGradient>
		</defs>
	</g>
	<g id="13497" type="1" node="Yes">
		<title/>
		<desc>Text</desc>
		<rect x="85" y="86" width="0" height="0" style=" fill: none; stroke: rgb(0,0,0); stroke-opacity: 0; stroke-width: 0;"/>
		<text x="58" y="84" style=" font-family: Arial; font-size: 10pt; font-weight: normal; font-style: normal; text-decoration: none; word-spacing: normal; letter-spacing: normal;  stroke: rgb(0,64,0); stroke-width: 0.0;  fill: rgb(0,64,0);">test</text>
	</g>
</svg>
 

A simpler example: tested on https://www.w3schools.com/graphics/tryit.asp?filename=trysvg_linear

<svg height="207" width="469">
  <defs>
	<linearGradient id="grad1" x1="0%" y1="0%" x2="20%" y2="100%">
						<stop offset="0%" stop-color="#b0d5ff" stop-opacity="1"/>
						<stop offset="100%" stop-color="#ffffff" stop-opacity="1"/>
	</linearGradient>
  </defs>
  <rect x="0" y="0" width="469" height="207" fill="url(#grad1)" />
  Sorry, your browser does not support inline SVG.
</svg>

Used Versions

New version is 3.4.3 of the master branch. Old version unknown; was obtained in February 2017 .Net version 4.62 for the new library, .Net 4.0 for the old.

the8thavatar avatar Sep 12 '22 16:09 the8thavatar

I can confirm that the old behaviour was "correct". Several designer tools and also the image preview of the operating system render it identically (like the old library version did).

Hurricane31337 avatar Feb 03 '23 09:02 Hurricane31337