From 89b29177ba6804abdd7b9d8f720a44440bd5fcac Mon Sep 17 00:00:00 2001 From: NathanSweet Date: Thu, 13 Feb 2014 12:25:38 +0100 Subject: [PATCH] Better color computation. --- .../spine/attachments/MeshAttachment.java | 15 ++++++--------- .../spine/attachments/RegionAttachment.java | 11 ++++------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/spine-libgdx/src/com/esotericsoftware/spine/attachments/MeshAttachment.java b/spine-libgdx/src/com/esotericsoftware/spine/attachments/MeshAttachment.java index d5da4b653..19fc5d9d9 100644 --- a/spine-libgdx/src/com/esotericsoftware/spine/attachments/MeshAttachment.java +++ b/spine-libgdx/src/com/esotericsoftware/spine/attachments/MeshAttachment.java @@ -69,17 +69,14 @@ public class MeshAttachment extends Attachment { Skeleton skeleton = slot.getSkeleton(); Color skeletonColor = skeleton.getColor(); Color slotColor = slot.getColor(); - Color regionColor = color; - float r = skeletonColor.r * slotColor.r * regionColor.r; - float g = skeletonColor.g * slotColor.g * regionColor.g; - float b = skeletonColor.b * slotColor.b * regionColor.b; - float a = skeletonColor.a * slotColor.a * regionColor.a * 255; + Color meshColor = color; + float a = skeletonColor.a * slotColor.a * meshColor.a * 255; float multiplier = premultipliedAlpha ? a : 255; float color = NumberUtils.intToFloatColor( // - ((int)(a) << 24) // - | ((int)(b * multiplier) << 16) // - | ((int)(g * multiplier) << 8) // - | ((int)(r * multiplier))); + ((int)a << 24) // + | ((int)(skeletonColor.b * slotColor.b * meshColor.b * multiplier) << 16) // + | ((int)(skeletonColor.g * slotColor.g * meshColor.g * multiplier) << 8) // + | (int)(skeletonColor.r * slotColor.r * meshColor.r * multiplier)); float[] worldVertices = this.worldVertices; FloatArray verticesArray = slot.getAttachmentVertices(); diff --git a/spine-libgdx/src/com/esotericsoftware/spine/attachments/RegionAttachment.java b/spine-libgdx/src/com/esotericsoftware/spine/attachments/RegionAttachment.java index 47e83a9a3..a49efefcb 100644 --- a/spine-libgdx/src/com/esotericsoftware/spine/attachments/RegionAttachment.java +++ b/spine-libgdx/src/com/esotericsoftware/spine/attachments/RegionAttachment.java @@ -149,16 +149,13 @@ public class RegionAttachment extends Attachment { Color skeletonColor = skeleton.getColor(); Color slotColor = slot.getColor(); Color regionColor = color; - float r = skeletonColor.r * slotColor.r * regionColor.r; - float g = skeletonColor.g * slotColor.g * regionColor.g; - float b = skeletonColor.b * slotColor.b * regionColor.b; float a = skeletonColor.a * slotColor.a * regionColor.a * 255; float multiplier = premultipliedAlpha ? a : 255; float color = NumberUtils.intToFloatColor( // - ((int)(a) << 24) // - | ((int)(b * multiplier) << 16) // - | ((int)(g * multiplier) << 8) // - | ((int)(r * multiplier))); + ((int)a << 24) // + | ((int)(skeletonColor.b * slotColor.b * regionColor.b * multiplier) << 16) // + | ((int)(skeletonColor.g * slotColor.g * regionColor.g * multiplier) << 8) // + | (int)(skeletonColor.r * slotColor.r * regionColor.r * multiplier)); float[] vertices = this.vertices; float[] offset = this.offset;