From 13b74c92a1e13292c2e72cb349cd4afafefe618f Mon Sep 17 00:00:00 2001 From: Mike Thomas Date: Mon, 12 Jul 2010 21:10:52 +0000 Subject: [PATCH] Colorization's range makes far more sense as inclusive rather than exclusive. In particular, it means if you have a color-class with a range of 0.0,0.0,0.0 it will match exactly the target color, which is surely what you meant for it to do. git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@946 ed5b42cb-e716-0410-a449-f6a68f950b19 --- src/as/com/threerings/media/image/Colorization.as | 8 ++++---- src/java/com/threerings/media/image/Colorization.java | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/as/com/threerings/media/image/Colorization.as b/src/as/com/threerings/media/image/Colorization.as index 716bb8c8..b4d1fb66 100644 --- a/src/as/com/threerings/media/image/Colorization.as +++ b/src/as/com/threerings/media/image/Colorization.as @@ -35,7 +35,7 @@ public class Colorization public var rootColor :uint; /** The range around the root color that will be colorized (in - * delta-hue, delta-saturation, delta-value. */ + * delta-hue, delta-saturation, delta-value. Note that this range is inclusive. */ public var range :Array; /** The adjustments to make to hue, saturation and value. */ @@ -101,14 +101,14 @@ public class Colorization { // check to see that this color is sufficiently "close" to the // root color based on the supplied distance parameters - if (distance(fhsv[0], _fhsv[0], Short.MAX_VALUE) >= + if (distance(fhsv[0], _fhsv[0], Short.MAX_VALUE) > range[0] * Short.MAX_VALUE) { return false; } // saturation and value don't wrap around like hue - if (Math.abs(_hsv[1] - hsv[1]) >= range[1] || - Math.abs(_hsv[2] - hsv[2]) >= range[2]) { + if (Math.abs(_hsv[1] - hsv[1]) > range[1] || + Math.abs(_hsv[2] - hsv[2]) > range[2]) { return false; } diff --git a/src/java/com/threerings/media/image/Colorization.java b/src/java/com/threerings/media/image/Colorization.java index 4416929b..ec8e7273 100644 --- a/src/java/com/threerings/media/image/Colorization.java +++ b/src/java/com/threerings/media/image/Colorization.java @@ -38,7 +38,7 @@ public class Colorization public Color rootColor; /** The range around the root color that will be colorized (in - * delta-hue, delta-saturation, delta-value. */ + * delta-hue, delta-saturation, delta-value. Note that this is inclusive. */ public float[] range; /** The adjustments to make to hue, saturation and value. */ @@ -104,14 +104,14 @@ public class Colorization { // check to see that this color is sufficiently "close" to the // root color based on the supplied distance parameters - if (distance(fhsv[0], _fhsv[0], Short.MAX_VALUE) >= + if (distance(fhsv[0], _fhsv[0], Short.MAX_VALUE) > range[0] * Short.MAX_VALUE) { return false; } // saturation and value don't wrap around like hue - if (Math.abs(_hsv[1] - hsv[1]) >= range[1] || - Math.abs(_hsv[2] - hsv[2]) >= range[2]) { + if (Math.abs(_hsv[1] - hsv[1]) > range[1] || + Math.abs(_hsv[2] - hsv[2]) > range[2]) { return false; }