mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 09:16:01 +08:00
[csharp] Fixed ColorTimeline and TwoColorTimeline result colors not being clamped. Closes #1664.
This commit is contained in:
parent
201f0bd7d5
commit
a0c0db0f5a
@ -725,6 +725,7 @@ namespace Spine {
|
||||
slot.g += (slotData.g - slot.g) * alpha;
|
||||
slot.b += (slotData.b - slot.b) * alpha;
|
||||
slot.a += (slotData.a - slot.a) * alpha;
|
||||
slot.ClampColor();
|
||||
return;
|
||||
}
|
||||
return;
|
||||
@ -758,6 +759,7 @@ namespace Spine {
|
||||
slot.g = g;
|
||||
slot.b = b;
|
||||
slot.a = a;
|
||||
slot.ClampColor();
|
||||
} else {
|
||||
float br, bg, bb, ba;
|
||||
if (blend == MixBlend.Setup) {
|
||||
@ -775,6 +777,7 @@ namespace Spine {
|
||||
slot.g = bg + ((g - bg) * alpha);
|
||||
slot.b = bb + ((b - bb) * alpha);
|
||||
slot.a = ba + ((a - ba) * alpha);
|
||||
slot.ClampColor();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -839,18 +842,22 @@ namespace Spine {
|
||||
slot.g = slotData.g;
|
||||
slot.b = slotData.b;
|
||||
slot.a = slotData.a;
|
||||
slot.ClampColor();
|
||||
slot.r2 = slotData.r2;
|
||||
slot.g2 = slotData.g2;
|
||||
slot.b2 = slotData.b2;
|
||||
slot.ClampSecondColor();
|
||||
return;
|
||||
case MixBlend.First:
|
||||
slot.r += (slot.r - slotData.r) * alpha;
|
||||
slot.g += (slot.g - slotData.g) * alpha;
|
||||
slot.b += (slot.b - slotData.b) * alpha;
|
||||
slot.a += (slot.a - slotData.a) * alpha;
|
||||
slot.ClampColor();
|
||||
slot.r2 += (slot.r2 - slotData.r2) * alpha;
|
||||
slot.g2 += (slot.g2 - slotData.g2) * alpha;
|
||||
slot.b2 += (slot.b2 - slotData.b2) * alpha;
|
||||
slot.ClampSecondColor();
|
||||
return;
|
||||
}
|
||||
return;
|
||||
@ -893,9 +900,11 @@ namespace Spine {
|
||||
slot.g = g;
|
||||
slot.b = b;
|
||||
slot.a = a;
|
||||
slot.ClampColor();
|
||||
slot.r2 = r2;
|
||||
slot.g2 = g2;
|
||||
slot.b2 = b2;
|
||||
slot.ClampSecondColor();
|
||||
} else {
|
||||
float br, bg, bb, ba, br2, bg2, bb2;
|
||||
if (blend == MixBlend.Setup) {
|
||||
@ -919,9 +928,11 @@ namespace Spine {
|
||||
slot.g = bg + ((g - bg) * alpha);
|
||||
slot.b = bb + ((b - bb) * alpha);
|
||||
slot.a = ba + ((a - ba) * alpha);
|
||||
slot.ClampColor();
|
||||
slot.r2 = br2 + ((r2 - br2) * alpha);
|
||||
slot.g2 = bg2 + ((g2 - bg2) * alpha);
|
||||
slot.b2 = bb2 + ((b2 - bb2) * alpha);
|
||||
slot.ClampSecondColor();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -106,6 +106,13 @@ namespace Spine {
|
||||
/// color tinting.</summary>
|
||||
public float A { get { return a; } set { a = value; } }
|
||||
|
||||
public void ClampColor() {
|
||||
r = MathUtils.Clamp(r, 0, 1);
|
||||
g = MathUtils.Clamp(g, 0, 1);
|
||||
b = MathUtils.Clamp(b, 0, 1);
|
||||
a = MathUtils.Clamp(a, 0, 1);
|
||||
}
|
||||
|
||||
/// <summary>The dark color used to tint the slot's attachment for two color tinting, ignored if two color tinting is not used.</summary>
|
||||
/// <seealso cref="HasSecondColor"/>
|
||||
public float R2 { get { return r2; } set { r2 = value; } }
|
||||
@ -118,6 +125,12 @@ namespace Spine {
|
||||
/// <summary>Whether R2 G2 B2 are used to tint the slot's attachment for two color tinting. False if two color tinting is not used.</summary>
|
||||
public bool HasSecondColor { get { return data.hasSecondColor; } set { data.hasSecondColor = value; } }
|
||||
|
||||
public void ClampSecondColor () {
|
||||
r2 = MathUtils.Clamp(r2, 0, 1);
|
||||
g2 = MathUtils.Clamp(g2, 0, 1);
|
||||
b2 = MathUtils.Clamp(b2, 0, 1);
|
||||
}
|
||||
|
||||
public Attachment Attachment {
|
||||
/// <summary>The current attachment for the slot, or null if the slot has no attachment.</summary>
|
||||
get { return attachment; }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user