mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-05 18:34:45 +00:00
svg import resize fix
This commit is contained in:
@@ -185,6 +185,12 @@ public class SvgImporter {
|
||||
rect.Ymin = (int) Math.round(viewBox.y * SWF.unitDivisor);
|
||||
rect.Xmax = (int) Math.round((viewBox.x + viewBox.width) * SWF.unitDivisor);
|
||||
rect.Ymax = (int) Math.round((viewBox.y + viewBox.height) * SWF.unitDivisor);
|
||||
} else if (viewBox != null) {
|
||||
double width = viewBox.width * SWF.unitDivisor;
|
||||
double height = viewBox.height * SWF.unitDivisor;
|
||||
double radioX = rect.getWidth() / width;
|
||||
double radioY = rect.getHeight() / height;
|
||||
shapes = shapes.resize(radioX, radioY);
|
||||
}
|
||||
|
||||
st.shapes = shapes;
|
||||
|
||||
@@ -99,6 +99,24 @@ public class SHAPE implements NeedsCharacters, Serializable {
|
||||
return area;
|
||||
}
|
||||
|
||||
public SHAPE resize(double multiplier) {
|
||||
return resize(multiplier, multiplier);
|
||||
}
|
||||
|
||||
public SHAPE resize(double multiplierX, double multiplierY) {
|
||||
SHAPE ret = new SHAPE();
|
||||
ret.numFillBits = numFillBits;
|
||||
ret.numLineBits = numLineBits;
|
||||
List<SHAPERECORD> recs = new ArrayList<>();
|
||||
for (SHAPERECORD r : shapeRecords) {
|
||||
SHAPERECORD c = r.resize(multiplierX, multiplierY);
|
||||
recs.add(c);
|
||||
}
|
||||
|
||||
ret.shapeRecords = recs;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static SHAPE createEmpty(int shapeNum) {
|
||||
SHAPE ret = new SHAPE();
|
||||
ret.shapeRecords = new ArrayList<>();
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.jpexs.decompiler.flash.types.shaperecords.EndShapeRecord;
|
||||
import com.jpexs.decompiler.flash.types.shaperecords.SHAPERECORD;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@@ -64,6 +65,23 @@ public class SHAPEWITHSTYLE extends SHAPE implements NeedsCharacters, Serializab
|
||||
return modified;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SHAPEWITHSTYLE resize(double multiplierX, double multiplierY) {
|
||||
SHAPEWITHSTYLE ret = new SHAPEWITHSTYLE();
|
||||
ret.numFillBits = numFillBits;
|
||||
ret.numLineBits = numLineBits;
|
||||
List<SHAPERECORD> recs = new ArrayList<>();
|
||||
for (SHAPERECORD r : shapeRecords) {
|
||||
SHAPERECORD c = r.resize(multiplierX, multiplierY);
|
||||
recs.add(c);
|
||||
}
|
||||
|
||||
ret.shapeRecords = recs;
|
||||
ret.fillStyles = fillStyles; // todo: clone?
|
||||
ret.lineStyles = lineStyles; // todo: clone?
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static SHAPEWITHSTYLE createEmpty(int shapeNum) {
|
||||
SHAPEWITHSTYLE ret = new SHAPEWITHSTYLE();
|
||||
ret.shapeRecords = new ArrayList<>();
|
||||
|
||||
@@ -428,37 +428,34 @@ public abstract class SHAPERECORD implements Cloneable, NeedsCharacters, Seriali
|
||||
return new Point2D.Double(x, y);
|
||||
}
|
||||
|
||||
public static SHAPE resizeSHAPE(SHAPE shp, double multiplier) {
|
||||
SHAPE ret = new SHAPE();
|
||||
ret.numFillBits = shp.numFillBits;
|
||||
ret.numLineBits = shp.numLineBits;
|
||||
List<SHAPERECORD> recs = new ArrayList<>();
|
||||
for (SHAPERECORD r : shp.shapeRecords) {
|
||||
SHAPERECORD c = r.clone();
|
||||
if (c instanceof StyleChangeRecord) {
|
||||
StyleChangeRecord scr = (StyleChangeRecord) c;
|
||||
scr.moveDeltaX = (int) (multiplier * scr.moveDeltaX);
|
||||
scr.moveDeltaY = (int) (multiplier * scr.moveDeltaY);
|
||||
scr.calculateBits();
|
||||
}
|
||||
if (c instanceof CurvedEdgeRecord) {
|
||||
CurvedEdgeRecord cer = (CurvedEdgeRecord) c;
|
||||
cer.controlDeltaX = (int) (multiplier * cer.controlDeltaX);
|
||||
cer.controlDeltaY = (int) (multiplier * cer.controlDeltaY);
|
||||
cer.anchorDeltaX = (int) (multiplier * cer.anchorDeltaX);
|
||||
cer.anchorDeltaY = (int) (multiplier * cer.anchorDeltaY);
|
||||
cer.calculateBits();
|
||||
}
|
||||
if (c instanceof StraightEdgeRecord) {
|
||||
StraightEdgeRecord ser = (StraightEdgeRecord) c;
|
||||
ser.deltaX = (int) (multiplier * ser.deltaX);
|
||||
ser.deltaY = (int) (multiplier * ser.deltaY);
|
||||
ser.calculateBits();
|
||||
}
|
||||
recs.add(c);
|
||||
public SHAPERECORD resize(double multiplier) {
|
||||
return resize(multiplier, multiplier);
|
||||
}
|
||||
|
||||
public SHAPERECORD resize(double multiplierX, double multiplierY) {
|
||||
SHAPERECORD c = clone();
|
||||
if (c instanceof StyleChangeRecord) {
|
||||
StyleChangeRecord scr = (StyleChangeRecord) c;
|
||||
scr.moveDeltaX = (int) (multiplierX * scr.moveDeltaX);
|
||||
scr.moveDeltaY = (int) (multiplierY * scr.moveDeltaY);
|
||||
scr.calculateBits();
|
||||
}
|
||||
ret.shapeRecords = recs;
|
||||
return ret;
|
||||
if (c instanceof CurvedEdgeRecord) {
|
||||
CurvedEdgeRecord cer = (CurvedEdgeRecord) c;
|
||||
cer.controlDeltaX = (int) (multiplierX * cer.controlDeltaX);
|
||||
cer.controlDeltaY = (int) (multiplierY * cer.controlDeltaY);
|
||||
cer.anchorDeltaX = (int) (multiplierX * cer.anchorDeltaX);
|
||||
cer.anchorDeltaY = (int) (multiplierY * cer.anchorDeltaY);
|
||||
cer.calculateBits();
|
||||
}
|
||||
if (c instanceof StraightEdgeRecord) {
|
||||
StraightEdgeRecord ser = (StraightEdgeRecord) c;
|
||||
ser.deltaX = (int) (multiplierX * ser.deltaX);
|
||||
ser.deltaY = (int) (multiplierY * ser.deltaY);
|
||||
ser.calculateBits();
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
public static Shape moveShapeToStart(Shape s) {
|
||||
|
||||
Reference in New Issue
Block a user