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
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user