darker/lighter logic

single coil improvement
This commit is contained in:
bancika
2017-01-25 11:48:07 +01:00
parent fc7fd2aed8
commit b7a1ef6664
4 changed files with 16 additions and 4 deletions
@@ -80,6 +80,18 @@ public abstract class AbstractComponent<T> implements IDIYComponent<T> {
return ((int) x / 2) * 2 + 1;
}
/**
* Returns darker color if possible, or lighter if it's already dark
*
* @param color
* @return
*/
protected Color darkerOrLighter(Color color) {
float[] hsb = new float[3];
Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), hsb);
return new Color(Color.HSBtoRGB(hsb[0], hsb[1], hsb[2] > 0.5 ? hsb[2] - 0.25f : hsb[2] + 0.25f));
}
/**
* @param clip
* @return true if none of the control points lie in the clip rectangle.