Parcourir la source

move ColorAjust to Matrix

ncannasse il y a 6 ans
Parent
commit
7741600ad6
2 fichiers modifiés avec 18 ajouts et 14 suppressions
  1. 2 14
      h2d/Drawable.hx
  2. 16 0
      h3d/Matrix.hx

+ 2 - 14
h2d/Drawable.hx

@@ -1,13 +1,5 @@
 package h2d;
 package h2d;
 
 
-typedef ColorAdjust = {
-	?saturation : Float,
-	?lightness : Float,
-	?hue : Float,
-	?contrast : Float,
-	?gain : { color : Int, alpha : Float },
-};
-
 /**
 /**
 	h2d.Drawable is the base class for all 2D objects that will draw something on screen.
 	h2d.Drawable is the base class for all 2D objects that will draw something on screen.
 	Unlike Object base class, all properties of Drawable only apply to the current object and are not inherited by its children.
 	Unlike Object base class, all properties of Drawable only apply to the current object and are not inherited by its children.
@@ -100,7 +92,7 @@ class Drawable extends Object {
 	/**
 	/**
 		Set the `colorMatrix` value by specifying which effects to apply. Calling adjustColor() reset the colorMatrix to `null`
 		Set the `colorMatrix` value by specifying which effects to apply. Calling adjustColor() reset the colorMatrix to `null`
 	**/
 	**/
-	public function adjustColor( ?col : ColorAdjust ) : Void {
+	public function adjustColor( ?col : h3d.Matrix.ColorAdjust ) : Void {
 		if( col == null )
 		if( col == null )
 			colorMatrix = null;
 			colorMatrix = null;
 		else {
 		else {
@@ -110,11 +102,7 @@ class Drawable extends Object {
 				colorMatrix = m;
 				colorMatrix = m;
 			}
 			}
 			m.identity();
 			m.identity();
-			if( col.hue != null ) m.colorHue(col.hue);
-			if( col.saturation != null ) m.colorSaturate(col.saturation);
-			if( col.contrast != null ) m.colorContrast(col.contrast);
-			if( col.lightness != null ) m.colorLightness(col.lightness);
-			if( col.gain != null ) m.colorGain(col.gain.color, col.gain.alpha);
+			m.adjustColor(col);
 		}
 		}
 	}
 	}
 
 

+ 16 - 0
h3d/Matrix.hx

@@ -1,6 +1,14 @@
 package h3d;
 package h3d;
 import hxd.Math;
 import hxd.Math;
 
 
+typedef ColorAdjust = {
+	?saturation : Float,
+	?lightness : Float,
+	?hue : Float,
+	?contrast : Float,
+	?gain : { color : Int, alpha : Float },
+};
+
 @:noDebug
 @:noDebug
 class Matrix {
 class Matrix {
 
 
@@ -708,6 +716,14 @@ class Matrix {
 		colorAdd(c);
 		colorAdd(c);
 	}
 	}
 
 
+	public function adjustColor( col : ColorAdjust ) {
+		if( col.hue != null ) colorHue(col.hue);
+		if( col.saturation != null ) colorSaturate(col.saturation);
+		if( col.contrast != null ) colorContrast(col.contrast);
+		if( col.lightness != null ) colorLightness(col.lightness);
+		if( col.gain != null ) colorGain(col.gain.color, col.gain.alpha);
+	}
+
 	// STATICS
 	// STATICS
 
 
 	public static function I() {
 	public static function I() {