mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-08 03:58:18 +00:00
Fixed #1915 SVG import - gradient when it has two final stops
This commit is contained in:
@@ -1553,21 +1553,42 @@ public class SvgImporter {
|
||||
break;
|
||||
}
|
||||
|
||||
fillStyle.gradient.gradientRecords = new GRADRECORD[gfill.stops.size()];
|
||||
int prevRatio = -1;
|
||||
int prevRatio = -1;
|
||||
|
||||
int recCount = 0;
|
||||
for (int i = 0; i < gfill.stops.size(); i++) {
|
||||
SvgStop stop = gfill.stops.get(i);
|
||||
|
||||
int ratio = Math.max((int) Math.round(stop.offset * 255), prevRatio + 1);
|
||||
recCount++;
|
||||
//two finish stops
|
||||
if (ratio == 255 && i + 1 < gfill.stops.size()) {
|
||||
if (prevRatio == 254) {
|
||||
break;
|
||||
}
|
||||
ratio = 254;
|
||||
}
|
||||
prevRatio = ratio;
|
||||
if (prevRatio == 255) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
prevRatio = -1;
|
||||
fillStyle.gradient.gradientRecords = new GRADRECORD[recCount];
|
||||
for (int i = 0; i < recCount; i++) {
|
||||
SvgStop stop = gfill.stops.get(i);
|
||||
Color color = stop.color;
|
||||
color = new Color(color.getRed(), color.getGreen(), color.getBlue(), (int) Math.round(color.getAlpha() * style.getOpacity()));
|
||||
fillStyle.gradient.gradientRecords[i] = new GRADRECORD();
|
||||
fillStyle.gradient.gradientRecords[i].inShape3 = shapeNum >= 3;
|
||||
fillStyle.gradient.gradientRecords[i].color = getRGB(shapeNum, color);
|
||||
int ratio = Math.max((int) Math.round(stop.offset * 255), prevRatio + 1);
|
||||
fillStyle.gradient.gradientRecords[i].ratio = ratio;
|
||||
prevRatio = ratio;
|
||||
if (prevRatio == 255) {
|
||||
break;
|
||||
if (ratio == 255 && i + 1 < recCount) {
|
||||
ratio = 254;
|
||||
}
|
||||
fillStyle.gradient.gradientRecords[i].ratio = ratio;
|
||||
prevRatio = ratio;
|
||||
}
|
||||
} else if (fill instanceof SvgBitmapFill) {
|
||||
SvgBitmapFill bfill = (SvgBitmapFill) fill;
|
||||
|
||||
Reference in New Issue
Block a user