Sfoglia il codice sorgente

filter grayed -> grayscale() + allow grayscale(0.5) + a few % support

Nicolas Cannasse 5 anni fa
parent
commit
06be74321b
1 ha cambiato i file con 15 aggiunte e 6 eliminazioni
  1. 15 6
      h2d/domkit/BaseComponents.hx

+ 15 - 6
h2d/domkit/BaseComponents.hx

@@ -7,9 +7,9 @@ class CustomParser extends CssValue.ValueParser {
 	function parseScale( value ) {
 	function parseScale( value ) {
 		switch( value ) {
 		switch( value ) {
 		case VGroup([x,y]):
 		case VGroup([x,y]):
-			return { x : parseFloat(x), y : parseFloat(y) };
+			return { x : parseFloatPercent(x), y : parseFloatPercent(y) };
 		default:
 		default:
-			var s = parseFloat(value);
+			var s = parseFloatPercent(value);
 			return { x : s, y : s };
 			return { x : s, y : s };
 		}
 		}
 	}
 	}
@@ -169,7 +169,7 @@ class CustomParser extends CssValue.ValueParser {
 		case VIdent("none"):
 		case VIdent("none"):
 			return null;
 			return null;
 		case VGroup(vl):
 		case VGroup(vl):
-			return { dx : parseFloat(vl[0]), dy : parseFloat(vl[1]), color : vl.length >= 3 ? parseColor(vl[2]) : 0, alpha : vl.length >= 4 ? parseFloat(vl[3]) : 1 };
+			return { dx : parseFloat(vl[0]), dy : parseFloat(vl[1]), color : vl.length >= 3 ? parseColor(vl[2]) : 0, alpha : vl.length >= 4 ? parseFloatPercent(vl[3]) : 1 };
 		default:
 		default:
 			return { dx : 1, dy : 1, color : parseColor(value), alpha : 1 };
 			return { dx : 1, dy : 1, color : parseColor(value), alpha : 1 };
 		}
 		}
@@ -207,9 +207,18 @@ class CustomParser extends CssValue.ValueParser {
 	public function parseFilter(value) : #if macro Bool #else h2d.filter.Filter #end {
 	public function parseFilter(value) : #if macro Bool #else h2d.filter.Filter #end {
 		return switch( value ) {
 		return switch( value ) {
 		case VIdent("none"): #if macro true #else null #end;
 		case VIdent("none"): #if macro true #else null #end;
-		case VIdent("grayed"): #if macro true #else h2d.filter.ColorMatrix.grayed() #end;
+		case VCall("grayscale",[]): #if macro true #else h2d.filter.ColorMatrix.grayed() #end;
+		case VCall("grayscale",[v]):
+			var v = parseFloatPercent(v);
+			#if macro
+				true;
+			#else
+				var f = new h2d.filter.ColorMatrix();
+				f.matrix.colorSaturate(-v);
+				f;
+			#end
 		case VCall("saturate",[v]):
 		case VCall("saturate",[v]):
-			var v = parseFloat(v);
+			var v = parseFloatPercent(v);
 			#if macro
 			#if macro
 				true;
 				true;
 			#else
 			#else
@@ -226,7 +235,7 @@ class CustomParser extends CssValue.ValueParser {
 				new h2d.filter.Outline(s, c);
 				new h2d.filter.Outline(s, c);
 			#end
 			#end
 		case VCall("brightness",[v]):
 		case VCall("brightness",[v]):
-			var v = parseFloat(v);
+			var v = parseFloatPercent(v);
 			#if macro
 			#if macro
 				true;
 				true;
 			#else
 			#else