[update] implement geom from haxework

This commit is contained in:
2020-02-11 22:47:47 +03:00
parent 7c0acdf71b
commit 1b6ed32d0a
18 changed files with 63 additions and 79 deletions

View File

@@ -15,31 +15,36 @@ using haxework.color.ColorUtil;
@:style(false) public var solid:Null<Bool>;
private var svgs:Map<ButtonState, SVG>;
private var needUpdate:Bool;
public function new(?svg:String, ?color:Color, ?solid:Bool) {
this.svg = svg;
this.color = color;
this.solid = solid;
init(solid);
this.needUpdate = true;
}
private inline function buildSVG(color:Color):SVG {
return new SVG(svg.replace("currentColor", '#${color}'));
}
private function init(solid:Bool):Void {
var color = color;
if (solid) {
color = color.multiply(1.5);
private function update():Void {
if (needUpdate && svg != null) {
var color = color;
if (solid) {
color = color.multiply(1.5);
}
svgs = new Map();
svgs.set(UP, buildSVG(color));
svgs.set(DOWN, buildSVG(color.diff(-24)));
svgs.set(OVER, buildSVG(color.diff(24)));
svgs.set(DISABLED, buildSVG(color.grey()));
needUpdate = false;
}
svgs = new Map();
svgs.set(UP, buildSVG(color));
svgs.set(DOWN, buildSVG(color.diff(-24)));
svgs.set(OVER, buildSVG(color.diff(24)));
svgs.set(DISABLED, buildSVG(color.grey()));
}
public function draw(view:ButtonView):Void {
update();
var svg = svgs.get(view.state);
var graphics = view.content.graphics;
graphics.beginFill(0, 0);