Prechádzať zdrojové kódy

[ts][pixi] Add tint property for Pixi's convention.

Richard Fu 1 rok pred
rodič
commit
89831677e4

+ 7 - 0
spine-ts/spine-core/src/Utils.ts

@@ -171,6 +171,13 @@ export class Color {
 		color.b = ((value & 0x000000ff)) / 255;
 	}
 
+	toRgb888 () {
+		function hex(x: number) {
+			return ("0" + (x * 255).toString(16)).slice(-2);
+		}
+		return Number("0x" + hex(this.r) + hex(this.g) + hex(this.b));
+	}
+
 	static fromString (hex: string): Color {
 		return new Color().setFromString(hex);
 	}

+ 7 - 0
spine-ts/spine-pixi/src/Spine.ts

@@ -432,6 +432,13 @@ export class Spine extends Container {
 		Spine.skeletonCache[cacheKey] = skeletonData;
 		return new this(skeletonData, options);
 	}
+
+	public get tint (): number {
+		return this.skeleton.color.toRgb888();
+	}
+	public set tint (value: number) {
+		Color.rgb888ToColor(this.skeleton.color, value);
+	}
 }
 
 Skeleton.yDown = true;