Skip to content

Commit

Permalink
box-shadow filter
Browse files Browse the repository at this point in the history
  • Loading branch information
ianharrigan committed May 22, 2023
1 parent 2c6fd47 commit 303046e
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
11 changes: 11 additions & 0 deletions haxe/ui/filters/BoxShadow.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package haxe.ui.filters;

class BoxShadow extends Filter {
public var offsetX:Float;
public var offsetY:Float;
public var color:Int;
public var alpha:Float;
public var blurRadius:Float;
public var spreadRadius:Float;
public var inset:Bool;
}
29 changes: 29 additions & 0 deletions haxe/ui/filters/FilterParser.hx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ class FilterParser {
var filter:Filter = null;
if (filterDetails[0] == "drop-shadow") {
filter = parseDropShadow(filterDetails);
} else if (filterDetails[0] == "box-shadow") {
filter = parseBoxShadow(filterDetails);
} else if (filterDetails[0] == "blur") {
filter = parseBlur(filterDetails);
} else if (filterDetails[0] == "outline") {
Expand Down Expand Up @@ -43,6 +45,30 @@ class FilterParser {
return dropShadow;
}

public static function parseBoxShadow(filterDetails:Array<Dynamic>):BoxShadow {
if (filterDetails == null || filterDetails.length == 0) {
return null;
}

var copy:Array<Dynamic> = filterDetails.copy();
buildDefaults();

var filterName = copy[0];
copy.remove(filterName);

copy = copyFilterDefaults(filterName, copy);

var boxShadow:BoxShadow = new BoxShadow();
boxShadow.offsetX = copy[0];
boxShadow.offsetY = copy[1];
boxShadow.color = copy[2];
boxShadow.alpha = copy[3];
boxShadow.blurRadius = copy[4];
boxShadow.spreadRadius = copy[5];
boxShadow.inset = copy[6];
return boxShadow;
}

public static function parseBlur(filterDetails:Array<Dynamic>):Blur {
if (filterDetails == null || filterDetails.length == 0) {
return null;
Expand Down Expand Up @@ -127,6 +153,9 @@ class FilterParser {
filterParamDefaults["drop-shadow"] = [];
filterParamDefaults["drop-shadow"] = filterParamDefaults["drop-shadow"].concat([4, 45, 0, 1, 4, 4, 1, 1, false, false, false]);

filterParamDefaults["box-shadow"] = [];
filterParamDefaults["box-shadow"] = filterParamDefaults["box-shadow"].concat([2, 2, 0, .1, 1, 0, false]);

filterParamDefaults["blur"] = [];
filterParamDefaults["blur"] = filterParamDefaults["blur"].concat([1]);

Expand Down

0 comments on commit 303046e

Please sign in to comment.