Fraction values must be in the range 0 to 1: 1.0000001
Closed this issue · 3 comments
SVG:
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M11.7526 1H4.24742C2.45392 1 1 2.45392 1 4.24742V11.7526C1 13.5461 2.45392 15 4.24742 15H11.7526C13.5461 15 15 13.5461 15 11.7526V4.24742C15 2.45392 13.5461 1 11.7526 1Z" fill="url(#paint0_linear)" stroke="#D9D9D9" stroke-width="0.0714286"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M3.30081 10.8536H2.9715V6.45301H3.30081V10.8536ZM3.13146 5.37429C2.99259 5.37429 2.87775 5.26413 2.87775 5.12525C2.87775 4.98228 2.99201 4.87154 3.13146 4.87154C3.27444 4.87154 3.38811 4.9817 3.38811 5.12525C3.38811 5.26413 3.27444 5.37429 3.13146 5.37429Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M6.49936 10.9392C4.88914 10.9392 3.8719 9.76665 3.8719 7.90277C3.8719 6.0482 4.89383 4.87105 6.49936 4.87105C8.10488 4.87105 9.12623 6.04827 9.12623 7.90277C9.12623 9.76672 8.109 10.9392 6.49936 10.9392V10.9392ZM6.49936 5.17392C5.09777 5.17392 4.203 6.23215 4.203 7.9027C4.203 9.57447 5.10188 10.6368 6.49936 10.6368C7.90094 10.6368 8.79572 9.57447 8.79572 7.9027C8.79572 6.23157 7.90094 5.17392 6.49936 5.17392Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M11.4711 10.9397C10.2623 10.9397 9.39568 10.257 9.34647 9.2808H9.66933C9.71855 10.0813 10.4704 10.6414 11.4958 10.6414C12.4965 10.6414 13.195 10.073 13.195 9.30541C13.195 8.68781 12.7784 8.3327 11.7899 8.08366L11.0914 7.91197C10.001 7.63364 9.50583 7.19242 9.50583 6.45352C9.50583 5.53414 10.3642 4.87202 11.4389 4.87202C12.5499 4.87202 13.3796 5.52595 13.4165 6.39203H13.0937C13.0485 5.68537 12.3583 5.17028 11.4307 5.17028C10.5436 5.17028 9.83685 5.70175 9.83685 6.44529C9.83685 7.03418 10.2699 7.3729 11.2174 7.6096L11.8754 7.77718C13.0151 8.05903 13.526 8.49674 13.526 9.28074C13.526 10.2569 12.7051 10.9396 11.4711 10.9396L11.4711 10.9397Z" fill="black"/>
<defs>
<linearGradient id="paint0_linear" x1="8" y1="8" x2="8" y2="15" gradientUnits="userSpaceOnUse">
<stop offset="1" stop-color="white"/>
<stop offset="1" stop-color="#E9E5E5"/>
</linearGradient>
</defs>
</svg>
Actual:
Exception in thread "main" java.lang.IllegalArgumentException: Fraction values must be in the range 0 to 1: 1.0000001
at java.desktop/java.awt.MultipleGradientPaint.<init>(MultipleGradientPaint.java:178)
at java.desktop/java.awt.LinearGradientPaint.<init>(LinearGradientPaint.java:285)
at com.github.weisj.jsvg.nodes.LinearGradient.gradientForBounds(LinearGradient.java:74)
at com.github.weisj.jsvg.nodes.AbstractGradient.paintForBounds(AbstractGradient.java:152)
at com.github.weisj.jsvg.nodes.AbstractGradient.fillShape(AbstractGradient.java:136)
at com.github.weisj.jsvg.nodes.LinearGradient.fillShape(LinearGradient.java:40)
at com.github.weisj.jsvg.renderer.ShapeRenderer.renderShapeFill(ShapeRenderer.java:157)
at com.github.weisj.jsvg.renderer.ShapeRenderer.renderWithPaintOrder(ShapeRenderer.java:115)
at com.github.weisj.jsvg.nodes.ShapeNode.render(ShapeNode.java:147)
at com.github.weisj.jsvg.renderer.NodeRenderer.renderNode(NodeRenderer.java:93)
at com.github.weisj.jsvg.nodes.container.CommonRenderableContainerNode.render(CommonRenderableContainerNode.java:81)
at com.github.weisj.jsvg.nodes.container.BaseInnerViewContainer.renderWithSize(BaseInnerViewContainer.java:142)
at com.github.weisj.jsvg.nodes.container.BaseInnerViewContainer.renderWithSize(BaseInnerViewContainer.java:85)
Another SVG:
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<defs>
<linearGradient id="dotnet-a" x1="49.997%" x2="49.997%" y1="-19.516%" y2="129.625%">
<stop offset="0%" stop-color="#0994DC"/>
<stop offset="35.001%" stop-color="#66CEF5"/>
<stop offset="35.001%" stop-color="#66CEF5"/>
<stop offset="84.616%" stop-color="#127BCA"/>
<stop offset="84.616%" stop-color="#127BCA"/>
<stop offset="100%" stop-color="#127BCA"/>
</linearGradient>
<linearGradient id="dotnet-b" x1="50.001%" x2="50.001%" y1="-19.516%" y2="129.624%">
<stop offset="0%" stop-color="#0E76BC"/>
<stop offset="36%" stop-color="#36AEE8"/>
<stop offset="36%" stop-color="#36AEE8"/>
<stop offset="84.616%" stop-color="#00ADEF"/>
<stop offset="84.616%" stop-color="#00ADEF"/>
<stop offset="100%" stop-color="#00ADEF"/>
</linearGradient>
<linearGradient id="dotnet-c" x1="49.999%" x2="49.999%" y1="110.922%" y2="-6.214%">
<stop offset="0%" stop-color="#1C63B7"/>
<stop offset="50%" stop-color="#33BDF2"/>
<stop offset="100%" stop-color="#33BDF2" stop-opacity=".42"/>
</linearGradient>
<linearGradient id="dotnet-d" x1="50.001%" x2="50.001%" y1="-19.515%" y2="129.627%">
<stop offset="0%" stop-color="#166AB8"/>
<stop offset="39.999%" stop-color="#36AEE8"/>
<stop offset="39.999%" stop-color="#36AEE8"/>
<stop offset="84.616%" stop-color="#0798DD"/>
<stop offset="84.616%" stop-color="#0798DD"/>
<stop offset="100%" stop-color="#0798DD"/>
</linearGradient>
<linearGradient id="dotnet-e" x1="49.999%" x2="49.999%" y1="-19.521%" y2="129.627%">
<stop offset="0%" stop-color="#124379"/>
<stop offset="39%" stop-color="#1487CB"/>
<stop offset="39%" stop-color="#1487CB"/>
<stop offset="78.023%" stop-color="#165197"/>
<stop offset="78.023%" stop-color="#165197"/>
<stop offset="100%" stop-color="#165197"/>
</linearGradient>
<linearGradient id="dotnet-f" x1="0%" y1="50.001%" y2="50.001%">
<stop offset="0%" stop-color="#33BDF2" stop-opacity=".698"/>
<stop offset="100%" stop-color="#1DACD8"/>
</linearGradient>
<linearGradient id="dotnet-g" x1="50.01%" x2="50.01%" y1="94.686%" y2="-3.025%">
<stop offset="0%" stop-color="#136AB4"/>
<stop offset="60%" stop-color="#59CAF5" stop-opacity=".549"/>
<stop offset="100%" stop-color="#59CAF5" stop-opacity=".235"/>
</linearGradient>
<linearGradient id="dotnet-h" x1="-.001%" x2="99.999%" y1="50%" y2="50%">
<stop offset="0%" stop-color="#05A1E6" stop-opacity=".247"/>
<stop offset="100%" stop-color="#05A1E6"/>
</linearGradient>
<linearGradient id="dotnet-i" x1="49.998%" x2="49.998%" y1="124.314%" y2="-9.421%">
<stop offset="0%" stop-color="#318ED5"/>
<stop offset="100%" stop-color="#38A7E4"/>
</linearGradient>
<linearGradient id="dotnet-j" x1="49.999%" x2="49.999%" y1="91.2%" y2="-76.785%">
<stop offset="0%" stop-color="#05A1E6"/>
<stop offset="100%" stop-color="#05A1E6" stop-opacity=".549"/>
</linearGradient>
<linearGradient id="dotnet-k" x1="50%" x2="50%" y1="100.01%" y2=".01%">
<stop offset="0%" stop-color="#1959A6"/>
<stop offset="50%" stop-color="#05A1E6"/>
<stop offset="50%" stop-color="#05A1E6"/>
<stop offset="91.759%" stop-color="#7EC5EA"/>
<stop offset="100%" stop-color="#7EC5EA"/>
</linearGradient>
<linearGradient id="dotnet-l" x1="59.804%" x2="38.471%" y1="94.568%" y2="5.755%">
<stop offset="0%" stop-color="#165096"/>
<stop offset="100%" stop-color="#0D82CA"/>
</linearGradient>
<linearGradient id="dotnet-m" x1="49.995%" x2="49.995%" y1="76.998%" y2="-3.299%">
<stop offset="0%" stop-color="#05A1E6"/>
<stop offset="87.363%" stop-color="#0495D6"/>
<stop offset="100%" stop-color="#0495D6"/>
</linearGradient>
<linearGradient id="dotnet-n" x1="65.263%" x2="34.263%" y1="-4.161%" y2="105.844%">
<stop offset="0%" stop-color="#38A7E4" stop-opacity=".329"/>
<stop offset="96.153%" stop-color="#0E88D3"/>
<stop offset="96.153%" stop-color="#0E88D3"/>
<stop offset="100%" stop-color="#0E88D3"/>
</linearGradient>
<linearGradient id="dotnet-o" x1="50.017%" x2="50.017%" y1="-.296%" y2="101.882%">
<stop offset="0%" stop-color="#168CD4"/>
<stop offset="50%" stop-color="#1C87CC"/>
<stop offset="100%" stop-color="#154B8D"/>
</linearGradient>
<linearGradient id="dotnet-p" x1="16.674%" x2="87.813%" y1="205.565%" y2="-19.836%">
<stop offset="0%" stop-color="#97D6EE"/>
<stop offset="70.329%" stop-color="#55C1EA"/>
<stop offset="100%" stop-color="#55C1EA"/>
</linearGradient>
<linearGradient id="dotnet-q" x1="6.89%" x2="75.783%" y1="6.3%" y2="116.771%">
<stop offset="0%" stop-color="#7ACCEC"/>
<stop offset="100%" stop-color="#3FB7ED"/>
</linearGradient>
<linearGradient id="dotnet-r" x1="49.997%" x2="49.997%" y1="6.363%" y2="127.961%">
<stop offset="0%" stop-color="#1DA7E7"/>
<stop offset="100%" stop-color="#37ABE7" stop-opacity="0"/>
</linearGradient>
</defs>
<g fill="none" fill-rule="evenodd" transform="translate(0 5)">
<path fill="url(#dotnet-a)" d="M5.581875,1.2930625 C6.154625,3.0446875 6.371625,6.1694375 8.046625,6.1694375 C8.174125,6.1694375 8.303,6.1569375 8.4323125,6.1323125 C6.9096875,5.7773125 6.7291875,2.6865625 5.800125,1.086 C5.72601395,1.15359392 5.65322925,1.2226279 5.5818125,1.2930625"/>
<path fill="url(#dotnet-b)" d="M5.800125,1.086 C6.72925,2.6865625 6.9096875,5.7773125 8.4323125,6.1323125 C8.5519375,6.110375 8.6718125,6.077125 8.7919375,6.0351875 C7.42525,5.365625 7.0475,2.36425 5.9923125,0.919375 C5.92718099,0.973692841 5.8631065,1.02926574 5.800125,1.0860625"/>
<path fill="#14559A" d="M7.1388125,0.1340625 C7.0115625,0.1340625 6.8824375,0.1465625 6.752875,0.1711875 C6.4139375,0.2350625 6.069625,0.381 5.7225625,0.6018125 C5.817375,0.695375 5.9075625,0.8024375 5.9924375,0.9193125 C6.3454375,0.626375 6.696125,0.4099375 7.0455625,0.2798125 C7.17308647,0.232096055 7.30451932,0.195562533 7.438375,0.170625 C7.34043741,0.145986755 7.23980104,0.133703785 7.1388125,0.1340625"/>
<path fill="url(#dotnet-c)" d="M9.8588125,5.4179375 C10.0044159,5.30161179 10.1446446,5.17871356 10.2790625,5.049625 C9.6970625,3.306125 9.48875,0.1366875 7.802,0.1366875 C7.681375,0.1366875 7.5596875,0.1479375 7.43825,0.1704375 C8.9746875,0.5525625 9.1715,3.8953125 9.858875,5.4179375"/>
<path fill="#3092C4" d="M7.4383125,0.200202405 C7.34037009,0.160833491 7.23973522,0.141214626 7.13875,0.141802405 L7.8020625,0.145702405 C7.6814375,0.145702405 7.55975,0.163702405 7.4383125,0.200102405"/>
<path fill="#1969BC" d="M9.829375,5.7883125 C9.7634375,5.7254375 9.7008125,5.6564375 9.6391875,5.5828125 C9.3554375,5.7836875 9.0728125,5.9360625 8.791875,6.0351875 C8.89214707,6.08443682 8.99832769,6.12060755 9.1078125,6.1428125 C9.19639215,6.1607489 9.28656043,6.1696694 9.3769375,6.1694375 C9.692125,6.1694375 9.9413125,6.132125 10.1535,6.030375 C10.036625,5.96725 9.9295625,5.885375 9.829375,5.7883125"/>
<path fill="url(#dotnet-d)" d="M7.0454375,0.2800625 C8.4215625,0.9998125 8.5411875,4.2593125 9.63925,5.5828125 C9.7139772,5.53001897 9.78713389,5.47503682 9.858625,5.4179375 C9.17125,3.8953125 8.9746875,0.5523125 7.4385625,0.1704375 C7.30462229,0.19564948 7.17309666,0.232326101 7.0454375,0.2800625"/>
<path fill="url(#dotnet-e)" d="M5.9923125,0.919375 C7.0474375,2.36425 7.42525,5.3655625 8.7919375,6.0351875 C9.072875,5.9360625 9.3555625,5.7836875 9.63925,5.5828125 C8.5411875,4.2593125 8.4215625,0.9998125 7.0454375,0.2800625 C6.6960625,0.4099375 6.3453125,0.626375 5.9923125,0.9193125"/>
<path fill="url(#dotnet-f)" d="M4.90675,1.250875 C4.741375,1.6248125 4.5724375,2.1163125 4.3681875,2.757875 C4.774375,2.185625 5.17925,1.6925 5.581875,1.293125 C5.5264375,1.122625 5.466875,0.9654375 5.4026875,0.8253125 C5.2298458,0.9581469 5.06431254,1.10022927 4.9068125,1.2509375"/>
<path fill="#2B74B1" d="M5.5493125,0.7174375 C5.49990143,0.752604557 5.45106172,0.788567583 5.4028125,0.8253125 C5.467,0.965375 5.52625,1.1225625 5.58175,1.2930625 C5.65327167,1.2227584 5.72603309,1.15372674 5.8,1.086 C5.7220625,0.9520625 5.63925,0.828375 5.5493125,0.7174375"/>
<path fill="#125A9E" d="M5.7225,0.601875 C5.6639156,0.639108459 5.60615181,0.677617651 5.54925,0.717375 C5.63925,0.8283125 5.722,0.952 5.80025,1.0861875 C5.86309495,1.02917558 5.92717261,0.973537416 5.9924375,0.9193125 C5.907625,0.8025 5.8174375,0.695375 5.7225625,0.6018125"/>
<path fill="url(#dotnet-g)" d="M15.1091875,0.0006875 C14.330875,3.00225 12.70525,5.4130625 11.3423125,6.020875 L11.3398125,6.020875 C11.315,6.032125 11.2904375,6.042375 11.2661875,6.0523125 C11.2628125,6.054375 11.25975,6.054625 11.2571875,6.0558125 C11.2500625,6.0586875 11.2434375,6.0609375 11.23625,6.0638125 C11.232875,6.0658125 11.229875,6.0665 11.2268125,6.0676875 C11.2153125,6.0718125 11.2040625,6.07525 11.1928125,6.07975 C11.1879375,6.0818125 11.183375,6.0830625 11.17875,6.0846875 C11.1732241,6.08681193 11.1675915,6.08864773 11.161875,6.0901875 C11.15675,6.0921875 11.151375,6.0936875 11.1455,6.0959375 C11.140625,6.0979375 11.1355,6.0988125 11.1309375,6.1008125 C11.1209375,6.1036875 11.1118125,6.106125 11.1018125,6.1095625 C11.0976875,6.1095625 11.093875,6.1118125 11.0895625,6.1129375 C11.083375,6.1149375 11.0764375,6.116375 11.0698125,6.11825 C11.06525,6.12025 11.0614375,6.1209375 11.0565625,6.1219375 C11.0496875,6.1239375 11.042,6.1258125 11.0350625,6.1274375 L11.009,6.1331875 C11.0714215,6.15620063 11.1374725,6.16780189 11.204,6.1674375 C12.496375,6.1674375 13.799375,3.8514375 15.9554375,-4.26325641e-14 L15.108875,-4.26325641e-14 L15.1091875,0.0006875 Z"/>
<path fill="url(#dotnet-h)" d="M4.0875625,0.255875 C4.088375,0.255875 4.0894375,0.253875 4.089875,0.253875 C4.0909375,0.253875 4.0925,0.253875 4.093,0.251875 L4.094625,0.251875 C4.10175,0.249375 4.108375,0.2465625 4.1155625,0.243875 C4.1174375,0.243875 4.118375,0.243875 4.1196875,0.241875 C4.1215,0.241875 4.12325,0.2398125 4.1250625,0.2395625 C4.1326875,0.237125 4.140375,0.23425 4.1475625,0.231625 L4.14875,0.231625 C4.165875,0.2265 4.18175,0.220125 4.1983125,0.2141875 C4.2006875,0.2141875 4.2029375,0.2121875 4.20575,0.2121875 C4.212625,0.2099375 4.2198125,0.2075 4.227,0.205875 C4.2303125,0.2038125 4.233625,0.2038125 4.2366875,0.20275 C4.2440625,0.2005625 4.25125,0.1980625 4.258125,0.1964375 C4.26125,0.1964375 4.264,0.194375 4.2663125,0.1941875 C4.2900625,0.187625 4.313625,0.1815 4.337375,0.1758125 C4.3406875,0.1758125 4.3435,0.17375 4.3470625,0.1735625 C4.3539375,0.1715625 4.360375,0.1704375 4.3678125,0.1694375 C4.370875,0.1674375 4.3744375,0.1674375 4.378,0.166375 C4.384875,0.164375 4.3915625,0.164125 4.399,0.1625 L4.4038125,0.1625 C4.4181875,0.1595625 4.43275,0.1571875 4.4470625,0.1545 L4.45575,0.1545 C4.462625,0.1525 4.46875,0.15225 4.4756875,0.151 C4.4794375,0.151 4.4833125,0.149 4.4869375,0.149 C4.4933125,0.149 4.4996875,0.1469375 4.5060625,0.146125 C4.5094375,0.146125 4.5126875,0.146125 4.5165625,0.1440625 C4.531625,0.1420625 4.5471875,0.14125 4.5630625,0.14 C4.51737049,0.135406583 4.4714844,0.133007993 4.4255625,0.1328125 C2.9701875,0.1328125 0.9649375,2.83325 0.0616875,6.330375 L0.23575,6.330375 C0.5248125,5.814875 0.7845,5.3271875 1.022,4.869375 C1.6545625,2.3923125 2.9430625,0.7030625 4.087625,0.2555"/>
<path fill="#0D82CA" d="M4.9068125,1.250875 C5.06428877,1.10016465 5.22980135,0.958082121 5.402625,0.82525 C5.36747867,0.747062868 5.32806516,0.670864812 5.2845625,0.597 C5.1514375,0.7585625 5.02975,0.97175 4.9068125,1.250875"/>
<path fill="#0D82CA" d="M5.026375,0.276375 C5.121375,0.356125 5.2065625,0.46575 5.2845,0.5971875 C5.3090625,0.567 5.333875,0.539125 5.359625,0.5130625 C5.2515,0.412125 5.13475,0.3293125 5.0079375,0.2669375 C5.0130625,0.26975 5.0181875,0.2720625 5.0235,0.2743125 C5.0235,0.2743125 5.0255,0.2763125 5.026375,0.2763125"/>
<path fill="url(#dotnet-i)" d="M1.021875,4.8696875 C2.349,2.312375 2.97775,0.693875 4.0875625,0.25575 C2.94325,0.703625 1.6545,2.392875 1.0219375,4.8696875"/>
<path fill="#127BCA" d="M5.3595625,0.513 C5.33375,0.5393125 5.30925,0.5669375 5.2844375,0.597125 C5.32796592,0.670995625 5.36746127,0.747169699 5.40275,0.8253125 C5.45099968,0.788588575 5.49983938,0.752646387 5.54925,0.7175 C5.49087533,0.64498615 5.42749091,0.57665211 5.3595625,0.513"/>
<path fill="url(#dotnet-j)" d="M1.624375,6.3191875 C1.6161875,6.32125 1.608,6.32125 1.6003125,6.3220625 L1.59575,6.3220625 C1.5888125,6.3220625 1.581625,6.324125 1.57525,6.324125 L1.5719375,6.324125 C1.5553125,6.326125 1.5389375,6.326125 1.523125,6.327375 L1.518,6.327375 C2.8611875,6.2898125 3.475125,5.6173125 3.779875,4.6419375 C4.0114375,3.9025 4.2015625,3.2795625 4.36825,2.756875 C3.805625,3.54875 3.2405,4.4926875 2.6723125,5.550125 C2.3983125,6.05975 1.9816875,6.272625 1.6243125,6.31825"/>
<path fill="url(#dotnet-k)" d="M1.624375,6.3186875 C1.9816875,6.2731875 2.3983125,6.0605625 2.6723125,5.5505625 C3.2405,4.4934375 3.8059375,3.54925 4.3679375,2.757375 C4.5724375,2.1155 4.7411875,1.62425 4.9068125,1.2503125 C3.7865,2.3166875 2.6618125,4.0898125 1.6243125,6.3181875"/>
<path fill="#05A1E6" d="M1.021875,4.86975 C0.784375,5.3275 0.5246875,5.8151875 0.235625,6.33075 L0.7419375,6.33075 C0.805878861,5.83866121 0.899360149,5.35086379 1.021875,4.87"/>
<path fill="url(#dotnet-l)" d="M4.5165,0.145375 C4.512375,0.145375 4.5093125,0.147375 4.50575,0.147375 C4.499625,0.1494375 4.49325,0.1494375 4.4868125,0.1500625 C4.4830625,0.1500625 4.4794375,0.1500625 4.4755625,0.152125 C4.4686875,0.154125 4.4623125,0.1543125 4.455625,0.155625 C4.4525625,0.155625 4.4495,0.155625 4.4469375,0.157625 C4.432375,0.1600625 4.4180625,0.16275 4.4038125,0.1651875 L4.3989375,0.1651875 C4.3915,0.16725 4.3848125,0.1683125 4.3779375,0.1693125 C4.374375,0.1713125 4.3708125,0.1713125 4.3674375,0.172125 C4.3605625,0.1741875 4.3536875,0.175 4.347,0.17625 C4.3434375,0.17825 4.340625,0.17825 4.3373125,0.1784375 C4.3135625,0.1841875 4.29,0.1903125 4.26625,0.196875 C4.26375,0.196875 4.261125,0.198875 4.2580625,0.1993125 C4.2509375,0.2013125 4.244,0.203375 4.2365625,0.205625 C4.2335,0.2076875 4.2299375,0.2076875 4.226875,0.2085 C4.21975286,0.210471267 4.21266829,0.212575803 4.205625,0.2148125 C4.202875,0.2148125 4.2005625,0.2168125 4.198,0.2168125 C4.181625,0.2229375 4.1655,0.229125 4.148625,0.2341875 C4.1415,0.2364375 4.1338125,0.2393125 4.126125,0.242 C4.1230625,0.244 4.1203125,0.2445 4.11675,0.245875 C4.1095625,0.248125 4.102375,0.251 4.09575,0.253625 C4.09325,0.2556875 4.090625,0.255875 4.088875,0.2569375 C2.9790625,0.6950625 2.35025,2.3135 1.0231875,4.8708125 C0.900564274,5.35166982 0.80710237,5.83949588 0.7433125,6.331625 L0.814375,6.331625 C1.0145,6.331625 1.071,6.3295625 1.30125,6.3295625 L1.5244375,6.3295625 C1.54025,6.3275625 1.556625,6.3275625 1.5731875,6.32625 L1.5763125,6.32625 C1.5831875,6.32625 1.5900625,6.32425 1.59675,6.32425 L1.601625,6.32425 C1.609,6.32425 1.6174375,6.32225 1.625625,6.321375 C2.663125,4.093 3.78775,2.319875 4.908125,1.2535 C5.03125,0.9744375 5.1526875,0.76125 5.285625,0.5999375 C5.207875,0.4685625 5.12275,0.3586875 5.0276875,0.2789375 C5.0276875,0.2789375 5.025125,0.2789375 5.0249375,0.276875 C5.0195,0.2746875 5.0144375,0.272 5.0090625,0.269375 C5.0036875,0.2664375 4.9990625,0.2641875 4.9934375,0.261375 C4.988213,0.259174754 4.98310239,0.256713316 4.978125,0.254 C4.9715,0.2519375 4.966125,0.2490625 4.96025,0.2464375 C4.955375,0.244375 4.9510625,0.2423125 4.9461875,0.2403125 C4.93628828,0.23646979 4.92649315,0.232364168 4.9168125,0.228 C4.9124375,0.226 4.908375,0.224875 4.9043125,0.2233125 C4.8968769,0.220605502 4.88951976,0.217687657 4.88225,0.2145625 C4.8786875,0.2125 4.874625,0.2120625 4.8705,0.210625 C4.8600625,0.207125 4.8498125,0.2034375 4.840125,0.2001875 L4.8375625,0.2001875 C4.8258125,0.1963125 4.8143125,0.1934375 4.8023125,0.1901875 C4.7995,0.188125 4.7971875,0.188125 4.794375,0.1876875 C4.783875,0.184875 4.7746875,0.1820625 4.76475,0.179375 C4.76225,0.179375 4.759875,0.1773125 4.757875,0.1773125 C4.733431,0.171050506 4.70876915,0.165672011 4.6839375,0.1611875 C4.6814375,0.1611875 4.678875,0.159125 4.6763125,0.159125 C4.66573366,0.157022559 4.65508051,0.155313052 4.644375,0.154 C4.64175,0.152 4.64025,0.152 4.638,0.152 C4.62541352,0.150071097 4.61278534,0.148424849 4.600125,0.1470625 L4.5935,0.1470625 C4.58325,0.1450625 4.5738125,0.144875 4.564375,0.1438125 C4.54825,0.1458125 4.5329375,0.1466875 4.5178125,0.148125"/>
<path fill="url(#dotnet-m)" d="M12.069,1.662375 C11.8136875,2.4803125 11.606875,3.1550625 11.4269375,3.71025 C12.1275625,2.746125 12.8176875,1.53325 13.474875,0.133625 C12.7083125,0.374375 12.2993125,0.9255 12.069,1.662375"/>
<path fill="url(#dotnet-n)" d="M11.4491875,5.96975 C11.4134375,5.988 11.377625,6.0053125 11.3423125,6.020875 C12.70525,5.4130625 14.330875,3.00225 15.1091875,0.0006875 L14.9514375,0.0006875 C13.1633125,3.1949375 12.5881875,5.3333125 11.4491875,5.96975"/>
<path fill="#079AE1" d="M10.55925,5.7014375 C10.85575,5.3395 11.0973125,4.72425 11.4270625,3.71025 C11.0466875,4.23275 10.6638125,4.6818125 10.280625,5.048125 C10.280625,5.050125 10.280625,5.050125 10.278625,5.051375 C10.3621875,5.301875 10.4539375,5.5229375 10.5585,5.701375"/>
<path fill="#1969BC" d="M10.55925,5.7014375 C10.4583125,5.8245625 10.3514375,5.9184375 10.2325625,5.9879375 C10.2065,6.0030625 10.1801875,6.0173125 10.153375,6.0304375 C10.2823391,6.10027457 10.4234862,6.14476359 10.5691875,6.1615 C10.5916875,6.16375 10.6139375,6.1658125 10.6371875,6.1674375 L10.6413125,6.1674375 C10.65175,6.1674375 10.66275,6.1674375 10.674,6.1694375 L10.7849375,6.1694375 C10.789,6.1694375 10.79325,6.1694375 10.797375,6.1674375 C10.8053125,6.1674375 10.8136875,6.1674375 10.821875,6.165375 L10.834,6.165375 C10.842375,6.165375 10.8515625,6.163375 10.8605625,6.1625 L10.8625625,6.1625 C10.86525,6.1625 10.868125,6.1605 10.87075,6.1605 C10.880125,6.1584375 10.89,6.157625 10.899125,6.1561875 L10.9075625,6.1561875 C10.9179375,6.1541875 10.92875,6.152875 10.9394375,6.150875 L10.944625,6.150875 C10.9660625,6.14675 10.987,6.14275 11.00825,6.137375 C10.832375,6.073 10.685125,5.921125 10.558375,5.704875"/>
<path fill="#1E5CB3" d="M8.046625,6.1694375 C8.1741875,6.1694375 8.303,6.1569375 8.432375,6.132125 C8.552,6.1104375 8.671875,6.077125 8.792,6.03525 C8.8921835,6.08444932 8.9982543,6.12061842 9.107625,6.142875 C9.19631167,6.16079445 9.28658396,6.16969394 9.3770625,6.1694375 L8.046625,6.1694375 Z"/>
<path fill="#1E5CB3" d="M9.3770625,6.1694375 C9.692,6.1694375 9.9414375,6.132125 10.1533125,6.030375 C10.2822898,6.10025606 10.4234579,6.14478743 10.5691875,6.1615625 C10.5916875,6.16375 10.6139375,6.1658125 10.6371875,6.1674375 L10.6413125,6.1674375 C10.65175,6.1674375 10.66275,6.1674375 10.674,6.1695 L10.71225,6.1695 L9.3761875,6.1695 L9.3770625,6.1695 L9.3770625,6.1694375 Z"/>
<path fill="#1D60B5" d="M10.713,6.1976 L10.785875,6.1976 C10.7901875,6.1976 10.79425,6.1976 10.798375,6.1944 C10.8063125,6.1944 10.8146875,6.1944 10.8231875,6.1911 L10.83525,6.1911 C10.843625,6.1911 10.8528125,6.1879 10.8615625,6.1866 L10.8638125,6.1866 C10.8665,6.1866 10.869125,6.1834 10.8718125,6.1834 C10.8811875,6.1801 10.891,6.1788 10.900125,6.1764 C10.90325,6.1764 10.9056875,6.1764 10.9089375,6.1732 C10.919375,6.17 10.9301875,6.1683 10.9409375,6.1651 L10.9460625,6.1651 C10.9675,6.1585 10.9884375,6.152 11.009625,6.1435 C11.0720479,6.18031259 11.1380979,6.19887433 11.204625,6.1983 L10.713375,6.2015 L10.713,6.1976 Z"/>
<path fill="#175FAB" d="M10.2794375,5.0514375 L10.2794375,5.049375 C10.1450445,5.178467 10.0048364,5.3013654 9.85925,5.4176875 C9.78764089,5.47471692 9.71442377,5.52969749 9.6396875,5.5825625 C9.70125,5.6561875 9.763875,5.7251875 9.829875,5.788125 C9.9300625,5.8851875 10.037125,5.967 10.1539375,6.030125 C10.1805625,6.017 10.2070625,6.00275 10.2329375,5.9876875 C10.352,5.9181875 10.458875,5.824375 10.5598125,5.7011875 C10.4553125,5.52275 10.3635625,5.3016875 10.2799375,5.0511875"/>
<path fill="url(#dotnet-o)" d="M14.452,0.0006875 L13.6581875,0.0006875 C13.6153125,0.00275 13.573625,0.0041875 13.5325,0.0068125 C13.5130625,0.0485 13.493125,0.0901875 13.4739375,0.132125 C12.8168125,1.53175 12.1266875,2.744625 11.4260625,3.70875 C11.0965625,4.7226875 10.8548125,5.3379375 10.5583125,5.699875 C10.6850625,5.916125 10.8325625,6.0681875 11.007875,6.132625 C11.013,6.1305625 11.017125,6.1305625 11.0216875,6.1295 L11.0245625,6.1295 C11.027625,6.1295 11.0309375,6.1275 11.03425,6.1275 C11.041375,6.1254375 11.0490625,6.1241875 11.05625,6.122 C11.0608125,6.1199375 11.064625,6.11975 11.06925,6.11825 C11.0759375,6.11625 11.0828125,6.1148125 11.0889375,6.1131875 C11.0930625,6.111125 11.097125,6.1105 11.1011875,6.1096875 C11.1114375,6.106375 11.120625,6.1039375 11.130375,6.100875 C11.1349375,6.098875 11.1398125,6.097125 11.1449375,6.0959375 C11.1505625,6.0939375 11.1561875,6.0925 11.1613125,6.0900625 C11.1671875,6.088 11.1730625,6.0869375 11.1781875,6.08475 C11.18275,6.0826875 11.1875625,6.0814375 11.1919375,6.079625 C11.2034375,6.0755 11.2146875,6.0720625 11.2261875,6.0675625 C11.2293125,6.0675625 11.232375,6.0646875 11.2356875,6.0640625 C11.2425625,6.0611875 11.24975,6.0589375 11.256625,6.055875 C11.259125,6.0538125 11.26225,6.053625 11.2655625,6.0525625 C11.289625,6.0425625 11.314375,6.0323125 11.3391875,6.021125 L11.34175,6.021125 C11.377767,6.00509302 11.4133229,5.98804453 11.448375,5.97 C12.5875625,5.3335625 13.16275,3.1951875 14.950875,0.0009375 L14.4514375,0.0009375 L14.4520625,0.0006875 L14.452,0.0006875 Z"/>
<path fill="#7DCBEC" d="M4.5630625,0.1410625 C4.565875,0.1410625 4.5684375,0.1410625 4.5711875,0.1430625 C4.578125,0.1430625 4.5850625,0.1430625 4.5919375,0.1453125 L4.5988125,0.1453125 C4.611375,0.1473125 4.623875,0.1484375 4.6366875,0.15025 C4.639,0.15025 4.6410625,0.15025 4.6430625,0.15225 C4.6535625,0.15425 4.6643125,0.156 4.675,0.1575625 C4.6773125,0.1575625 4.680375,0.159625 4.6829375,0.159625 C4.7075,0.1645 4.7325625,0.169625 4.7565625,0.1759375 C4.7588125,0.1759375 4.7611875,0.178 4.7631875,0.178 C4.7734375,0.1804375 4.782625,0.1835 4.792875,0.186375 C4.796,0.186375 4.7981875,0.188375 4.801,0.188875 C4.8130625,0.1919375 4.8243125,0.195 4.836,0.198875 C4.8365625,0.198875 4.83725,0.198875 4.838625,0.200875 C4.848625,0.2039375 4.8588125,0.2078125 4.86925,0.2113125 C4.8734375,0.2133125 4.87725,0.2141875 4.8810625,0.2151875 C4.88825,0.2183125 4.8961875,0.2213125 4.9030625,0.2241875 C4.907125,0.2241875 4.9111875,0.2270625 4.9155625,0.2285625 C4.925,0.2328125 4.9349375,0.2366875 4.9446875,0.24075 C4.9498125,0.2428125 4.954125,0.245125 4.9590625,0.2469375 C4.9646875,0.2498125 4.9705,0.2524375 4.976625,0.2544375 C4.98175,0.2569375 4.987375,0.2595625 4.99225,0.2618125 C4.997625,0.26475 5.0026875,0.2669375 5.007875,0.2698125 C5.134625,0.3321875 5.2514375,0.41525 5.3595625,0.516 C5.39828053,0.475232119 5.43995637,0.437379181 5.48425,0.40275 C5.2478125,0.235 4.98,0.139375 4.6709375,0.139375 C4.635125,0.139375 4.599375,0.1414375 4.5630625,0.144125"/>
<path fill="#5EC5ED" d="M5.3595625,0.513 C5.42749062,0.5766524 5.49087502,0.644986418 5.54925,0.7175 C5.60608604,0.677606149 5.66385199,0.639053834 5.7225,0.601875 C5.64893894,0.5277955 5.56916826,0.46015247 5.4840625,0.3996875 C5.43977139,0.434250305 5.3981531,0.472107907 5.3595625,0.5129375"/>
<path fill="url(#dotnet-p)" d="M4.563,0.392875 C4.59925,0.3959375 4.6350625,0.39725 4.670875,0.39725 C4.979875,0.39725 5.24775,0.301625 5.4841875,0.134125 C5.7336875,0.331 6.03525,0.39975 6.4541875,0.39975 L4.4254375,0.39975 C4.4723125,0.39975 4.518,0.3969375 4.563,0.392875" transform="matrix(1 0 0 -1 0 .534)"/>
<path fill="url(#dotnet-q)" d="M6.4541875,0.601875 C6.03525,0.601875 5.7336875,0.533125 5.4841875,0.33625 C5.56918279,0.275740937 5.64888584,0.208122974 5.7224375,0.134125 C6.06975,0.3549375 6.4138125,0.5011875 6.7530625,0.5650625 C6.88018835,0.589237921 7.00928373,0.601561612 7.1386875,0.601875 L6.4541875,0.601875 Z" transform="matrix(1 0 0 -1 0 .736)"/>
<path fill="url(#dotnet-r)" d="M11.4269375,3.71075 C11.607125,3.155125 11.8134375,2.4805625 12.06925,1.662375 C12.299875,0.9251875 12.708,0.374125 13.4745625,0.133625 C13.4948125,0.0924375 13.5139375,0.05 13.533625,0.008375 C12.284,0.08325 11.6999375,0.7189375 11.406,1.6603125 C10.892,3.3038125 10.580625,4.3691875 10.2808125,5.0480625 C10.66375,4.6820625 11.046625,4.2326875 11.4269375,3.71075"/>
<path fill="#000" fill-rule="nonzero" d="M13.5857557,5.78563256 L13.3091894,5.78563256 L13.3091894,6.6791875 L13.1964148,6.6791875 L13.1964148,5.78563256 L12.91875,5.78563256 L12.91875,5.67931437 L13.5856336,5.67931437 L13.5856336,5.78563256 L13.5857557,5.78563256 Z M14.7180177,6.67893376 L14.6057313,6.67893376 L14.6057313,6.00753056 C14.6057313,5.95462521 14.6096369,5.88979395 14.6148851,5.81341739 C14.6032903,5.85909108 14.5937703,5.89080892 14.5849827,5.91110833 L14.2575214,6.67893376 L14.2025987,6.67893376 L13.874283,5.91681754 C13.8645189,5.89563003 13.854999,5.86124789 13.8446247,5.81354426 L13.8407191,5.81354426 C13.8446247,5.85376248 13.8459672,5.91884748 13.8459672,6.00917989 L13.8459672,6.67906063 L13.7380747,6.67906063 L13.7380747,5.6791875 L13.8868541,5.6791875 L14.1818501,6.37697994 C14.2041853,6.42937781 14.2182211,6.46984977 14.2253,6.49687337 L14.2295718,6.49687337 C14.2490999,6.4418112 14.2652105,6.40083175 14.275951,6.37380815 L14.5770494,5.6791875 L14.71875,5.6791875 L14.71875,6.67893376 L14.7180177,6.67893376 Z"/>
</g>
</svg>
I think AbstractGradient
should ignore any subsequent stop
if the offset
is equal to a previous one.
Ignoring the stops with identical offsets sounds wrong to me. It’s specifically allowed to allow hard color changes in gradients e.g for striped fills. Sadly awt doesn’t like stops with the same offset, so I had to nudge the value in this case a bit (which is why 1.0000001 is popping up). The current fix is very naive and probably misses some other edge cases as well.
Ignoring the stops with identical offsets sounds wrong to me
I don't see any other solution :(
As a solution to still render such SVGs, currently I use the following patch (I didn't test stripped fills, but for my SVGs output is identical to batik one):
Index: community/platform/util/ui/src/com/github/weisj/jsvg/nodes/AbstractGradient.java
===================================================================
diff --git a/community/platform/util/ui/src/com/github/weisj/jsvg/nodes/AbstractGradient.java b/community/platform/util/ui/src/com/github/weisj/jsvg/nodes/AbstractGradient.java
--- a/community/platform/util/ui/src/com/github/weisj/jsvg/nodes/AbstractGradient.java (revision 1412a876f53db2b0bca38425440953be728863f8)
+++ b/community/platform/util/ui/src/com/github/weisj/jsvg/nodes/AbstractGradient.java (revision 654744b1cda250f83aedb2b409e711924ec4ba17)
@@ -21,14 +21,6 @@
*/
package com.github.weisj.jsvg.nodes;
-import java.awt.*;
-import java.awt.geom.AffineTransform;
-import java.awt.geom.Rectangle2D;
-import java.util.List;
-
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
import com.github.weisj.jsvg.attributes.Percentage;
import com.github.weisj.jsvg.attributes.SpreadMethod;
import com.github.weisj.jsvg.attributes.UnitType;
@@ -38,6 +30,14 @@
import com.github.weisj.jsvg.nodes.container.ContainerNode;
import com.github.weisj.jsvg.parser.AttributeNode;
import com.github.weisj.jsvg.renderer.GraphicsUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.awt.*;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+import java.util.Arrays;
+import java.util.List;
@SuppressWarnings("java:S119") // Generic name Self is intentional
abstract class AbstractGradient<Self extends AbstractGradient<Self>> extends ContainerNode implements SVGPaint {
@@ -45,14 +45,14 @@
protected UnitType gradientUnits;
protected SpreadMethod spreadMethod;
- private @NotNull Color[] colors;
+ private Color[] colors;
private @Percentage float[] offsets;
public @Percentage float[] offsets() {
return offsets;
}
- public @NotNull Color[] colors() {
+ public Color @NotNull [] colors() {
return colors;
}
@@ -91,34 +91,31 @@
colors = new Color[stops.size()];
offsets = new float[stops.size()];
- boolean realGradient = false;
- for (int i = 0; i < offsets.length; i++) {
- Stop stop = stops.get(i);
+ int itemIndex = 0;
+ for (int stopIndex = 0, n = stops.size(); stopIndex < n; stopIndex++) {
+ Stop stop = stops.get(stopIndex);
// Clamp the offset
float stopOffset = Math.max(0, Math.min(1, stop.offset()));
Color stopColor = stop.color();
- if (i > 0) {
- // Keep track whether the provided colors and offsets are actually different.
- realGradient = realGradient
- || stopOffset > stops.get(i - 1).offset()
- || !stopColor.equals(colors[i - 1]);
- }
-
- if (i > 0 && stopOffset <= offsets[i - 1]) {
- // The awt gradient implementations really don't like it if
- // two offsets are equal. Hence we use the next possible float value instead as it will produce
- // the same effect as if the equal values were used.
- stopOffset = Math.nextAfter(stopOffset, Double.MAX_VALUE);
+ if (itemIndex > 0) {
+ // we don't check "less than" as stops are sorted
+ if (stopOffset == offsets[itemIndex - 1] || stopColor.equals(colors[itemIndex - 1])) {
+ // The awt gradient implementations really don't like
+ // if two offsets are equal or not increasing -
+ // skip it (https://github.com/weisJ/jsvg/issues/31)
+ continue;
+ }
}
- offsets[i] = stopOffset;
- colors[i] = stopColor;
+ offsets[itemIndex] = stopOffset;
+ colors[itemIndex] = stopColor;
+ itemIndex++;
}
- if (!realGradient && colors.length > 0) {
- colors = new Color[] {colors[0]};
- offsets = new float[] {0f};
+ if (offsets.length != itemIndex) {
+ offsets = Arrays.copyOf(offsets, itemIndex);
+ colors = Arrays.copyOf(colors, itemIndex);
}
}
@@ -149,11 +146,11 @@
Color[] gradColors = colors();
if (gradColors.length == 0) return PaintParser.DEFAULT_COLOR;
if (gradColors.length == 1) return gradColors[0];
- return gradientForBounds(gradientUnits.deriveMeasure(context), bounds, offsets(), gradColors);
+ return gradientForBounds(gradientUnits.deriveMeasure(context), bounds, offsets, gradColors);
}
protected abstract @NotNull Paint gradientForBounds(@NotNull MeasureContext measure, @NotNull Rectangle2D bounds,
- @Percentage float[] gradOffsets, @NotNull Color[] gradColors);
+ @Percentage float[] gradOffsets, @NotNull Color @NotNull [] gradColors);
protected @NotNull AffineTransform computeViewTransform(@NotNull Rectangle2D bounds) {
AffineTransform viewTransform = gradientUnits.viewTransform(bounds);