Рефакторинг canvasfx

This commit is contained in:
Victor 2016-07-30 11:23:51 +03:00
parent 1c0686c03a
commit a0b6bc168d
3 changed files with 147 additions and 239 deletions

View File

@ -21,6 +21,10 @@ public final class Converters {
float apply(); float apply();
} }
public interface VoidToDoubleFunction {
double apply();
}
public interface VoidToStringFunction { public interface VoidToStringFunction {
String apply(); String apply();
} }
@ -41,6 +45,18 @@ public final class Converters {
void apply(float f1, float f2, float f3, float f4); void apply(float f1, float f2, float f3, float f4);
} }
public interface DoubleToVoidFunction {
void apply(double d);
}
public interface Double2ToVoidFunction {
void apply(double d1, double d2);
}
public interface Double4ToVoidFunction {
void apply(double d1, double d2, double d3, double d4);
}
public interface StringToVoidFunction { public interface StringToVoidFunction {
void apply(String s); void apply(String s);
} }
@ -65,6 +81,10 @@ public final class Converters {
return new FunctionValue(args -> NumberValue.of(f.apply())); return new FunctionValue(args -> NumberValue.of(f.apply()));
} }
public static FunctionValue voidToDouble(VoidToDoubleFunction f) {
return new FunctionValue(args -> NumberValue.of(f.apply()));
}
public static FunctionValue voidToString(VoidToStringFunction f) { public static FunctionValue voidToString(VoidToStringFunction f) {
return new FunctionValue(args -> new StringValue(f.apply())); return new FunctionValue(args -> new StringValue(f.apply()));
} }
@ -115,6 +135,31 @@ public final class Converters {
}); });
} }
public static FunctionValue doubleToVoid(DoubleToVoidFunction f) {
return new FunctionValue(args -> {
Arguments.check(1, args.length);
f.apply(args[0].asNumber());
return NumberValue.ZERO;
});
}
public static FunctionValue double2ToVoid(Double2ToVoidFunction f) {
return new FunctionValue(args -> {
Arguments.check(2, args.length);
f.apply(args[0].asNumber(), args[1].asNumber());
return NumberValue.ZERO;
});
}
public static FunctionValue double4ToVoid(Double4ToVoidFunction f) {
return new FunctionValue(args -> {
Arguments.check(4, args.length);
f.apply(args[0].asNumber(), args[1].asNumber(),
args[2].asNumber(), args[3].asNumber());
return NumberValue.ZERO;
});
}
public static FunctionValue stringToVoid(StringToVoidFunction f) { public static FunctionValue stringToVoid(StringToVoidFunction f) {
return new FunctionValue(args -> { return new FunctionValue(args -> {
Arguments.check(1, args.length); Arguments.check(1, args.length);

View File

@ -52,6 +52,10 @@ public class MapValue implements Value, Iterable<Map.Entry<Value, Value>> {
set(new StringValue(key), value); set(new StringValue(key), value);
} }
public void set(String key, Function function) {
set(new StringValue(key), new FunctionValue(function));
}
public void set(Value key, Value value) { public void set(Value key, Value value) {
map.put(key, value); map.put(key, value);
} }

View File

@ -3,11 +3,11 @@ package com.annimon.ownlang.lib.modules;
import com.annimon.ownlang.annotations.ConstantInitializer; import com.annimon.ownlang.annotations.ConstantInitializer;
import com.annimon.ownlang.exceptions.TypeException; import com.annimon.ownlang.exceptions.TypeException;
import com.annimon.ownlang.lib.*; import com.annimon.ownlang.lib.*;
import static com.annimon.ownlang.lib.Converters.*;
import java.awt.Dimension; import java.awt.Dimension;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.nio.IntBuffer; import java.nio.IntBuffer;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javafx.application.Platform; import javafx.application.Platform;
@ -598,7 +598,7 @@ public final class canvasfx implements Module {
set("height", NumberValue.of(image.getHeight())); set("height", NumberValue.of(image.getHeight()));
set("preserveRatio", NumberValue.fromBoolean(image.isPreserveRatio())); set("preserveRatio", NumberValue.fromBoolean(image.isPreserveRatio()));
set("smooth", NumberValue.fromBoolean(image.isSmooth())); set("smooth", NumberValue.fromBoolean(image.isSmooth()));
set("getPixels", new FunctionValue(this::getPixels)); set("getPixels", this::getPixels);
} }
private Value getPixels(Value... args) { private Value getPixels(Value... args) {
@ -671,77 +671,71 @@ public final class canvasfx implements Module {
} }
private void init() { private void init() {
Map<String, Function> functions = new HashMap<>(); set("applyEffect", this::applyEffect);
functions.put("applyEffect", this::applyEffect); set("appendSVGPath", this::appendSVGPath);
functions.put("appendSVGPath", this::appendSVGPath); set("arc", this::arc);
functions.put("arc", this::arc); set("arcTo", this::arcTo);
functions.put("arcTo", this::arcTo); set("beginPath", voidToVoid(graphics::beginPath));
functions.put("beginPath", this::beginPath); set("bezierCurveTo", this::bezierCurveTo);
functions.put("bezierCurveTo", this::bezierCurveTo); set("clearRect", double4ToVoid(graphics::clearRect));
functions.put("clearRect", this::clearRect); set("clip", voidToVoid(graphics::clip));
functions.put("clip", this::clip); set("closePath", voidToVoid(graphics::closePath));
functions.put("closePath", this::closePath); set("drawImage", this::drawImage);
functions.put("drawImage", this::drawImage); set("fill", voidToVoid(graphics::fill));
functions.put("fill", this::fill); set("fillArc", this::fillArc);
functions.put("fillArc", this::fillArc); set("fillOval", double4ToVoid(graphics::fillOval));
functions.put("fillOval", this::fillOval); set("fillPolygon", this::fillPolygon);
functions.put("fillPolygon", this::fillPolygon); set("fillRect", double4ToVoid(graphics::fillRect));
functions.put("fillRect", this::fillRect); set("fillRoundRect", this::fillRoundRect);
functions.put("fillRoundRect", this::fillRoundRect); set("fillText", this::fillText);
functions.put("fillText", this::fillText); set("getFill", this::getFill);
functions.put("getGlobalAlpha", this::getGlobalAlpha); set("getFillRule", this::getFillRule);
functions.put("getLineWidth", this::getLineWidth); set("getGlobalAlpha", voidToDouble(graphics::getGlobalAlpha));
functions.put("getMiterLimit", this::getMiterLimit); set("getGlobalBlendMode", this::getGlobalBlendMode);
functions.put("getFill", this::getFill); set("getLineCap", this::getLineCap);
functions.put("getFillRule", this::getFillRule); set("getLineDashOffset", voidToDouble(graphics::getLineDashOffset));
functions.put("getGlobalAlpha", this::getGlobalAlpha); set("getLineJoin", this::getLineJoin);
functions.put("getGlobalBlendMode", this::getGlobalBlendMode); set("getLineWidth", voidToDouble(graphics::getLineWidth));
functions.put("getLineCap", this::getLineCap); set("getMiterLimit", voidToDouble(graphics::getMiterLimit));
functions.put("getLineJoin", this::getLineJoin); set("getStroke", this::getStroke);
functions.put("getLineWidth", this::getLineWidth); set("getTextAlign", this::getTextAlign);
functions.put("getMiterLimit", this::getMiterLimit); set("getTextBaseline", this::getTextBaseline);
functions.put("getStroke", this::getStroke); set("isPointInPath", this::isPointInPath);
functions.put("getTextAlign", this::getTextAlign); set("lineTo", double2ToVoid(graphics::lineTo));
functions.put("getTextBaseline", this::getTextBaseline); set("moveTo", double2ToVoid(graphics::moveTo));
functions.put("isPointInPath", this::isPointInPath); set("quadraticCurveTo", double4ToVoid(graphics::quadraticCurveTo));
functions.put("lineTo", this::lineTo); set("rect", double4ToVoid(graphics::rect));
functions.put("moveTo", this::moveTo); set("restore", voidToVoid(graphics::restore));
functions.put("quadraticCurveTo", this::quadraticCurveTo); set("rotate", doubleToVoid(graphics::rotate));
functions.put("rect", this::rect); set("save", voidToVoid(graphics::save));
functions.put("restore", this::restore); set("scale", double2ToVoid(graphics::scale));
functions.put("rotate", this::rotate); set("setEffect", this::setEffect);
functions.put("save", this::save); set("setFill", this::setFill);
functions.put("scale", this::scale); set("setFillRule", this::setFillRule);
functions.put("setEffect", this::setEffect); set("setGlobalAlpha", doubleToVoid(graphics::setGlobalAlpha));
functions.put("setFill", this::setFill); set("setGlobalBlendMode", this::setGlobalBlendMode);
functions.put("setFillRule", this::setFillRule); set("setLineCap", this::setLineCap);
functions.put("setGlobalAlpha", this::setGlobalAlpha); set("setLineDashOffset", doubleToVoid(graphics::setLineDashOffset));
functions.put("setGlobalBlendMode", this::setGlobalBlendMode); set("setLineJoin", this::setLineJoin);
functions.put("setLineCap", this::setLineCap); set("setLineWidth", doubleToVoid(graphics::setLineWidth));
functions.put("setLineJoin", this::setLineJoin); set("setMiterLimit", doubleToVoid(graphics::setMiterLimit));
functions.put("setLineWidth", this::setLineWidth); set("setStroke", this::setStroke);
functions.put("setMiterLimit", this::setMiterLimit); set("setTextAlign", this::setTextAlign);
functions.put("setStroke", this::setStroke); set("setTextBaseline", this::setTextBaseline);
functions.put("setTextAlign", this::setTextAlign); set("stroke", voidToVoid(graphics::stroke));
functions.put("setTextBaseline", this::setTextBaseline); set("strokeArc", this::strokeArc);
functions.put("stroke", this::stroke); set("strokeLine", double4ToVoid(graphics::strokeLine));
functions.put("strokeArc", this::strokeArc); set("strokeOval", double4ToVoid(graphics::strokeOval));
functions.put("strokeLine", this::strokeLine); set("strokePolygon", this::strokePolygon);
functions.put("strokeOval", this::strokeOval); set("strokePolyline", this::strokePolyline);
functions.put("strokePolygon", this::strokePolygon); set("strokeRect", double4ToVoid(graphics::strokeRect));
functions.put("strokePolyline", this::strokePolyline); set("strokeRoundRect", this::strokeRoundRect);
functions.put("strokeRect", this::strokeRect); set("strokeText", this::strokeText);
functions.put("strokeRoundRect", this::strokeRoundRect); set("transform", this::transform);
functions.put("strokeText", this::strokeText); set("translate", double2ToVoid(graphics::translate));
functions.put("transform", this::transform);
functions.put("translate", this::translate);
for (Map.Entry<String, Function> entry : functions.entrySet()) {
set(entry.getKey(), new FunctionValue(entry.getValue()));
}
} }
public Value applyEffect(Value... args) { private Value applyEffect(Value... args) {
if (args[0].type() != FX_EFFECT_TYPE) { if (args[0].type() != FX_EFFECT_TYPE) {
throw new TypeException("Effect expected, found " + Types.typeToString(args[0].type())); throw new TypeException("Effect expected, found " + Types.typeToString(args[0].type()));
} }
@ -749,54 +743,33 @@ public final class canvasfx implements Module {
return NumberValue.ZERO; return NumberValue.ZERO;
} }
public Value arc(Value... args) { private Value arc(Value... args) {
graphics.arc(args[0].asNumber(), args[1].asNumber(), graphics.arc(args[0].asNumber(), args[1].asNumber(),
args[2].asNumber(), args[3].asNumber(), args[2].asNumber(), args[3].asNumber(),
args[4].asNumber(), args[5].asNumber()); args[4].asNumber(), args[5].asNumber());
return NumberValue.ZERO; return NumberValue.ZERO;
} }
public Value appendSVGPath(Value... args) { private Value appendSVGPath(Value... args) {
graphics.appendSVGPath(args[0].asString()); graphics.appendSVGPath(args[0].asString());
return NumberValue.ZERO; return NumberValue.ZERO;
} }
public Value arcTo(Value... args) { private Value arcTo(Value... args) {
graphics.arcTo(args[0].asNumber(), args[1].asNumber(), graphics.arcTo(args[0].asNumber(), args[1].asNumber(),
args[2].asNumber(), args[3].asNumber(), args[2].asNumber(), args[3].asNumber(),
args[4].asNumber()); args[4].asNumber());
return NumberValue.ZERO; return NumberValue.ZERO;
} }
public Value beginPath(Value... args) { private Value bezierCurveTo(Value... args) {
graphics.beginPath();
return NumberValue.ZERO;
}
public Value bezierCurveTo(Value... args) {
graphics.bezierCurveTo(args[0].asNumber(), args[1].asNumber(), graphics.bezierCurveTo(args[0].asNumber(), args[1].asNumber(),
args[2].asNumber(), args[3].asNumber(), args[2].asNumber(), args[3].asNumber(),
args[4].asNumber(), args[5].asNumber()); args[4].asNumber(), args[5].asNumber());
return NumberValue.ZERO; return NumberValue.ZERO;
} }
public Value clearRect(Value... args) { private Value drawImage(Value... args) {
graphics.clearRect(args[0].asNumber(), args[1].asNumber(),
args[2].asNumber(), args[3].asNumber());
return NumberValue.ZERO;
}
public Value clip(Value... args) {
graphics.clip();
return NumberValue.ZERO;
}
public Value closePath(Value... args) {
graphics.closePath();
return NumberValue.ZERO;
}
public Value drawImage(Value... args) {
Arguments.checkAtLeast(3, args.length); Arguments.checkAtLeast(3, args.length);
if (!(args[0] instanceof ImageFXValue)) { if (!(args[0] instanceof ImageFXValue)) {
throw new TypeException("ImageFX expected"); throw new TypeException("ImageFX expected");
@ -826,12 +799,7 @@ public final class canvasfx implements Module {
return NumberValue.ZERO; return NumberValue.ZERO;
} }
public Value fill(Value... args) { private Value fillArc(Value... args) {
graphics.fill();
return NumberValue.ZERO;
}
public Value fillArc(Value... args) {
graphics.fillArc(args[0].asNumber(), args[1].asNumber(), graphics.fillArc(args[0].asNumber(), args[1].asNumber(),
args[2].asNumber(), args[3].asNumber(), args[2].asNumber(), args[3].asNumber(),
args[4].asNumber(), args[5].asNumber(), args[4].asNumber(), args[5].asNumber(),
@ -839,13 +807,7 @@ public final class canvasfx implements Module {
return NumberValue.ZERO; return NumberValue.ZERO;
} }
public Value fillOval(Value... args) { private Value fillPolygon(Value... args) {
graphics.fillOval(args[0].asNumber(), args[1].asNumber(),
args[2].asNumber(), args[3].asNumber());
return NumberValue.ZERO;
}
public Value fillPolygon(Value... args) {
final ArrayValue xarr = (ArrayValue) args[0]; final ArrayValue xarr = (ArrayValue) args[0];
final ArrayValue yarr = (ArrayValue) args[1]; final ArrayValue yarr = (ArrayValue) args[1];
@ -861,20 +823,14 @@ public final class canvasfx implements Module {
return NumberValue.ZERO; return NumberValue.ZERO;
} }
public Value fillRect(Value... args) { private Value fillRoundRect(Value... args) {
graphics.fillRect(args[0].asNumber(), args[1].asNumber(),
args[2].asNumber(), args[3].asNumber());
return NumberValue.ZERO;
}
public Value fillRoundRect(Value... args) {
graphics.fillRoundRect(args[0].asNumber(), args[1].asNumber(), graphics.fillRoundRect(args[0].asNumber(), args[1].asNumber(),
args[2].asNumber(), args[3].asNumber(), args[2].asNumber(), args[3].asNumber(),
args[4].asNumber(), args[5].asNumber() ); args[4].asNumber(), args[5].asNumber() );
return NumberValue.ZERO; return NumberValue.ZERO;
} }
public Value fillText(Value... args) { private Value fillText(Value... args) {
if (args.length < 4) { if (args.length < 4) {
// str x y // str x y
graphics.fillText(args[0].asString(), args[1].asNumber(), graphics.fillText(args[0].asString(), args[1].asNumber(),
@ -886,97 +842,43 @@ public final class canvasfx implements Module {
return NumberValue.ZERO; return NumberValue.ZERO;
} }
public Value getFill(Value... args) { private Value getFill(Value... args) {
return new ColorValue((Color)graphics.getFill()); return new ColorValue((Color)graphics.getFill());
} }
public Value getFillRule(Value... args) { private Value getFillRule(Value... args) {
return NumberValue.of(graphics.getFillRule().ordinal()); return NumberValue.of(graphics.getFillRule().ordinal());
} }
public Value getGlobalAlpha(Value... args) { private Value getGlobalBlendMode(Value... args) {
return NumberValue.of(graphics.getGlobalAlpha());
}
public Value getGlobalBlendMode(Value... args) {
return NumberValue.of(graphics.getGlobalBlendMode().ordinal()); return NumberValue.of(graphics.getGlobalBlendMode().ordinal());
} }
public Value getLineCap(Value... args) { private Value getLineCap(Value... args) {
return NumberValue.of(graphics.getLineCap().ordinal()); return NumberValue.of(graphics.getLineCap().ordinal());
} }
public Value getLineJoin(Value... args) { private Value getLineJoin(Value... args) {
return NumberValue.of(graphics.getLineJoin().ordinal()); return NumberValue.of(graphics.getLineJoin().ordinal());
} }
public Value getLineWidth(Value... args) { private Value getStroke(Value... args) {
return NumberValue.of(graphics.getLineWidth());
}
public Value getMiterLimit(Value... args) {
return NumberValue.of(graphics.getMiterLimit());
}
public Value getStroke(Value... args) {
return new ColorValue((Color)graphics.getStroke()); return new ColorValue((Color)graphics.getStroke());
} }
public Value getTextAlign(Value... args) { private Value getTextAlign(Value... args) {
return NumberValue.of(graphics.getTextAlign().ordinal()); return NumberValue.of(graphics.getTextAlign().ordinal());
} }
public Value getTextBaseline(Value... args) { private Value getTextBaseline(Value... args) {
return NumberValue.of(graphics.getTextBaseline().ordinal()); return NumberValue.of(graphics.getTextBaseline().ordinal());
} }
public Value isPointInPath(Value... args) { private Value isPointInPath(Value... args) {
return NumberValue.fromBoolean(graphics.isPointInPath(args[0].asNumber(), args[1].asNumber())); return NumberValue.fromBoolean(graphics.isPointInPath(args[0].asNumber(), args[1].asNumber()));
} }
public Value lineTo(Value... args) { private Value setEffect(Value... args) {
graphics.lineTo(args[0].asNumber(), args[1].asNumber());
return NumberValue.ZERO;
}
public Value moveTo(Value... args) {
graphics.moveTo(args[0].asNumber(), args[1].asNumber());
return NumberValue.ZERO;
}
public Value quadraticCurveTo(Value... args) {
graphics.quadraticCurveTo(args[0].asNumber(), args[1].asNumber(),
args[2].asNumber(), args[3].asNumber());
return NumberValue.ZERO;
}
public Value rect(Value... args) {
graphics.rect(args[0].asNumber(), args[1].asNumber(),
args[2].asNumber(), args[3].asNumber());
return NumberValue.ZERO;
}
public Value restore(Value... args) {
graphics.restore();
return NumberValue.ZERO;
}
public Value rotate(Value... args) {
graphics.rotate(args[0].asNumber());
return NumberValue.ZERO;
}
public Value save(Value... args) {
graphics.save();
return NumberValue.ZERO;
}
public Value scale(Value... args) {
graphics.scale(args[0].asNumber(), args[1].asNumber());
return NumberValue.ZERO;
}
public Value setEffect(Value... args) {
if (args[0].type() != FX_EFFECT_TYPE) { if (args[0].type() != FX_EFFECT_TYPE) {
throw new TypeException("Effect expected, found " + Types.typeToString(args[0].type())); throw new TypeException("Effect expected, found " + Types.typeToString(args[0].type()));
} }
@ -984,67 +886,47 @@ public final class canvasfx implements Module {
return NumberValue.ZERO; return NumberValue.ZERO;
} }
public Value setFill(Value... args) { private Value setFill(Value... args) {
graphics.setFill((Color) args[0].raw()); graphics.setFill((Color) args[0].raw());
return NumberValue.ZERO; return NumberValue.ZERO;
} }
public Value setFillRule(Value... args) { private Value setFillRule(Value... args) {
graphics.setFillRule(FillRule.values()[args[0].asInt()]); graphics.setFillRule(FillRule.values()[args[0].asInt()]);
return NumberValue.ZERO; return NumberValue.ZERO;
} }
public Value setGlobalAlpha(Value... args) { private Value setGlobalBlendMode(Value... args) {
graphics.setGlobalAlpha(args[0].asNumber());
return NumberValue.ZERO;
}
public Value setGlobalBlendMode(Value... args) {
graphics.setGlobalBlendMode(BlendMode.values()[args[0].asInt()]); graphics.setGlobalBlendMode(BlendMode.values()[args[0].asInt()]);
return NumberValue.ZERO; return NumberValue.ZERO;
} }
public Value setLineCap(Value... args) { private Value setLineCap(Value... args) {
graphics.setLineCap(StrokeLineCap.values()[args[0].asInt()]); graphics.setLineCap(StrokeLineCap.values()[args[0].asInt()]);
return NumberValue.ZERO; return NumberValue.ZERO;
} }
public Value setLineJoin(Value... args) { private Value setLineJoin(Value... args) {
graphics.setLineJoin(StrokeLineJoin.values()[args[0].asInt()]); graphics.setLineJoin(StrokeLineJoin.values()[args[0].asInt()]);
return NumberValue.ZERO; return NumberValue.ZERO;
} }
public Value setLineWidth(Value... args) { private Value setStroke(Value... args) {
graphics.setLineWidth(args[0].asNumber());
return NumberValue.ZERO;
}
public Value setMiterLimit(Value... args) {
graphics.setMiterLimit(args[0].asNumber());
return NumberValue.ZERO;
}
public Value setStroke(Value... args) {
graphics.setStroke((Color) args[0].raw()); graphics.setStroke((Color) args[0].raw());
return NumberValue.ZERO; return NumberValue.ZERO;
} }
public Value setTextAlign(Value... args) { private Value setTextAlign(Value... args) {
graphics.setTextAlign(TextAlignment.values()[args[0].asInt()]); graphics.setTextAlign(TextAlignment.values()[args[0].asInt()]);
return NumberValue.ZERO; return NumberValue.ZERO;
} }
public Value setTextBaseline(Value... args) { private Value setTextBaseline(Value... args) {
graphics.setTextBaseline(VPos.values()[args[0].asInt()]); graphics.setTextBaseline(VPos.values()[args[0].asInt()]);
return NumberValue.ZERO; return NumberValue.ZERO;
} }
public Value stroke(Value... args) { private Value strokeArc(Value... args) {
graphics.stroke();
return NumberValue.ZERO;
}
public Value strokeArc(Value... args) {
graphics.strokeArc(args[0].asNumber(), args[1].asNumber(), graphics.strokeArc(args[0].asNumber(), args[1].asNumber(),
args[2].asNumber(), args[3].asNumber(), args[2].asNumber(), args[3].asNumber(),
args[4].asNumber(), args[5].asNumber(), args[4].asNumber(), args[5].asNumber(),
@ -1052,19 +934,7 @@ public final class canvasfx implements Module {
return NumberValue.ZERO; return NumberValue.ZERO;
} }
public Value strokeLine(Value... args) { private Value strokePolygon(Value... args) {
graphics.strokeLine(args[0].asNumber(), args[1].asNumber(),
args[2].asNumber(), args[3].asNumber());
return NumberValue.ZERO;
}
public Value strokeOval(Value... args) {
graphics.strokeOval(args[0].asNumber(), args[1].asNumber(),
args[2].asNumber(), args[3].asNumber());
return NumberValue.ZERO;
}
public Value strokePolygon(Value... args) {
final ArrayValue xarr = (ArrayValue) args[0]; final ArrayValue xarr = (ArrayValue) args[0];
final ArrayValue yarr = (ArrayValue) args[1]; final ArrayValue yarr = (ArrayValue) args[1];
@ -1080,7 +950,7 @@ public final class canvasfx implements Module {
return NumberValue.ZERO; return NumberValue.ZERO;
} }
public Value strokePolyline(Value... args) { private Value strokePolyline(Value... args) {
final ArrayValue xarr = (ArrayValue) args[0]; final ArrayValue xarr = (ArrayValue) args[0];
final ArrayValue yarr = (ArrayValue) args[1]; final ArrayValue yarr = (ArrayValue) args[1];
@ -1096,20 +966,14 @@ public final class canvasfx implements Module {
return NumberValue.ZERO; return NumberValue.ZERO;
} }
public Value strokeRect(Value... args) { private Value strokeRoundRect(Value... args) {
graphics.strokeRect(args[0].asNumber(), args[1].asNumber(),
args[2].asNumber(), args[3].asNumber());
return NumberValue.ZERO;
}
public Value strokeRoundRect(Value... args) {
graphics.strokeRoundRect(args[0].asNumber(), args[1].asNumber(), graphics.strokeRoundRect(args[0].asNumber(), args[1].asNumber(),
args[2].asNumber(), args[3].asNumber(), args[2].asNumber(), args[3].asNumber(),
args[4].asNumber(), args[5].asNumber() ); args[4].asNumber(), args[5].asNumber() );
return NumberValue.ZERO; return NumberValue.ZERO;
} }
public Value strokeText(Value... args) { private Value strokeText(Value... args) {
if (args.length < 4) { if (args.length < 4) {
// str x y // str x y
graphics.strokeText(args[0].asString(), args[1].asNumber(), graphics.strokeText(args[0].asString(), args[1].asNumber(),
@ -1121,18 +985,13 @@ public final class canvasfx implements Module {
return NumberValue.ZERO; return NumberValue.ZERO;
} }
public Value transform(Value... args) { private Value transform(Value... args) {
graphics.transform(args[0].asNumber(), args[1].asNumber(), graphics.transform(args[0].asNumber(), args[1].asNumber(),
args[2].asNumber(), args[3].asNumber(), args[2].asNumber(), args[3].asNumber(),
args[4].asNumber(), args[5].asNumber()); args[4].asNumber(), args[5].asNumber());
return NumberValue.ZERO; return NumberValue.ZERO;
} }
public Value translate(Value... args) {
graphics.translate(args[0].asNumber(), args[1].asNumber());
return NumberValue.ZERO;
}
@Override @Override
public String toString() { public String toString() {
return "GraphicsFXValue " + asString(); return "GraphicsFXValue " + asString();