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

This commit is contained in:
Richard Fu 2024-05-17 12:35:58 +10:00 committed by Davide
parent 0e13cdbb76
commit 89831677e4
2 changed files with 14 additions and 0 deletions

View File

@ -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);
}

View File

@ -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;