mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-05-29 10:24:38 +00:00
Export border of define edit text
This commit is contained in:
@@ -149,13 +149,13 @@ public class SVGExporter {
|
||||
}
|
||||
|
||||
public final Element createSubGroup(Matrix transform, String id) {
|
||||
Element group = createSubGroup(transform, id, "g");
|
||||
Element group = createSubGroup(id, "g");
|
||||
group.setAttribute("transform", transform.getTransformationString(SWF.unitDivisor, 1));
|
||||
return group;
|
||||
}
|
||||
|
||||
public final Element createClipPath(Matrix transform, String id) {
|
||||
Element group = createSubGroup(transform, id, "clipPath");
|
||||
Element group = createSubGroup(id, "clipPath");
|
||||
Node parent = group.getParentNode();
|
||||
if (parent instanceof Element) {
|
||||
Element parentElement = (Element) parent;
|
||||
@@ -164,7 +164,7 @@ public class SVGExporter {
|
||||
return group;
|
||||
}
|
||||
|
||||
private Element createSubGroup(Matrix transform, String id, String tagName) {
|
||||
private Element createSubGroup(String id, String tagName) {
|
||||
Element group = _svg.createElement(tagName);
|
||||
if (id != null) {
|
||||
group.setAttribute("id", id);
|
||||
|
||||
@@ -920,7 +920,7 @@ public class DefineEditTextTag extends TextTag {
|
||||
|
||||
@Override
|
||||
public void toImage(int frame, int time, int ratio, RenderContext renderContext, SerializableImage image, Matrix transformation, ColorTransform colorTransform) {
|
||||
render(TextRenderMode.BITMAP, image, null, transformation, colorTransform, 0);
|
||||
render(TextRenderMode.BITMAP, image, null, transformation, colorTransform, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -930,18 +930,25 @@ public class DefineEditTextTag extends TextTag {
|
||||
|
||||
@Override
|
||||
public String toHtmlCanvas(double unitDivisor) {
|
||||
return render(TextRenderMode.HTML5_CANVAS, null, null, new Matrix(), new ColorTransform(), 0);
|
||||
return render(TextRenderMode.HTML5_CANVAS, null, null, new Matrix(), new ColorTransform(), unitDivisor);
|
||||
}
|
||||
|
||||
private String render(TextRenderMode renderMode, SerializableImage image, SVGExporter svgExporter, Matrix transformation, ColorTransform colorTransform, double zoom) {
|
||||
String result = "";
|
||||
if (border) {
|
||||
// border is always black, fill color is always white?
|
||||
RGB borderColor = new RGBA(Color.black);
|
||||
RGB fillColor = new RGBA(Color.white);
|
||||
if (renderMode == TextRenderMode.BITMAP) {
|
||||
drawBorder(swf, image, borderColor, fillColor, getRect(), getTextMatrix(), transformation, colorTransform);
|
||||
} else {
|
||||
// TODO: draw border
|
||||
switch (renderMode) {
|
||||
case BITMAP:
|
||||
drawBorder(swf, image, borderColor, fillColor, getRect(), getTextMatrix(), transformation, colorTransform);
|
||||
break;
|
||||
case HTML5_CANVAS:
|
||||
result += drawBorderHtmlCanvas(swf, borderColor, fillColor, getRect(), getTextMatrix(), colorTransform, zoom);
|
||||
break;
|
||||
case SVG:
|
||||
drawBorderSVG(swf, svgExporter, borderColor, fillColor, getRect(), getTextMatrix(), colorTransform, zoom);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (hasText) {
|
||||
@@ -1124,14 +1131,15 @@ public class DefineEditTextTag extends TextTag {
|
||||
staticTextToImage(swf, allTextRecords, 2, image, getTextMatrix(), transformation, colorTransform);
|
||||
break;
|
||||
case HTML5_CANVAS:
|
||||
return staticTextToHtmlCanvas(1, swf, allTextRecords, 2, getBounds(), getTextMatrix(), colorTransform);
|
||||
result += staticTextToHtmlCanvas(zoom, swf, allTextRecords, 2, getBounds(), getTextMatrix(), colorTransform);
|
||||
break;
|
||||
case SVG:
|
||||
staticTextToSVG(swf, allTextRecords, 2, svgExporter, getBounds(), getTextMatrix(), colorTransform, zoom);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -395,6 +395,27 @@ public abstract class TextTag extends CharacterTag implements DrawableTag {
|
||||
BitmapExporter.export(swf, getBorderShape(borderColor, fillColor, rect), null, image, mat, colorTransform);
|
||||
}
|
||||
|
||||
public static String drawBorderHtmlCanvas(SWF swf, RGB borderColor, RGB fillColor, RECT rect, MATRIX textMatrix, ColorTransform colorTransform, double unitDivisor) {
|
||||
String ret = "";
|
||||
Matrix mat = new Matrix(textMatrix);
|
||||
ret += "\tctx.save();\r\n";
|
||||
ret += "\tctx.transform(" + mat.scaleX + "," + mat.rotateSkew0 + "," + mat.rotateSkew1 + "," + mat.scaleY + "," + mat.translateX + "," + mat.translateY + ");\r\n";
|
||||
SHAPE shape = getBorderShape(borderColor, fillColor, rect);
|
||||
CanvasShapeExporter cse = new CanvasShapeExporter(null, unitDivisor, swf, shape, colorTransform, 0, 0);
|
||||
cse.export();
|
||||
ret += cse.getShapeData();
|
||||
ret += "\tctx.restore();\r\n";
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static void drawBorderSVG(SWF swf, SVGExporter exporter, RGB borderColor, RGB fillColor, RECT rect, MATRIX textMatrix, ColorTransform colorTransform, double zoom) {
|
||||
exporter.createSubGroup(new Matrix(textMatrix), null);
|
||||
SHAPE shape = getBorderShape(borderColor, fillColor, rect);
|
||||
SVGShapeExporter shapeExporter = new SVGShapeExporter(swf, shape, exporter, null, colorTransform, zoom);
|
||||
shapeExporter.export();
|
||||
exporter.endGroup();
|
||||
}
|
||||
|
||||
public static void staticTextToImage(SWF swf, List<TEXTRECORD> textRecords, int numText, SerializableImage image, MATRIX textMatrix, Matrix transformation, ColorTransform colorTransform) {
|
||||
int textColor = 0;
|
||||
FontTag font = null;
|
||||
|
||||
Reference in New Issue
Block a user