Skip to content

Instantly share code, notes, and snippets.

@wlievens
Created October 23, 2015 20:49
Show Gist options
  • Save wlievens/41a50583e7da1e11c621 to your computer and use it in GitHub Desktop.
Save wlievens/41a50583e7da1e11c621 to your computer and use it in GitHub Desktop.
final double maxDistance = Util.distance(centerX, chief, 0, 0);
final float[] hsb = new float[3];
for (int y = 0; y < size; ++y)
{
for (int x = 0; x < size; ++x)
{
final int oldARGB = image.getRGB(x, y);
final int oldA = (oldARGB >> 24) & 0xFF;
final int oldR = (oldARGB >> 16) & 0xFF;
final int oldG = (oldARGB >> 8) & 0xFF;
final int oldB = (oldARGB >> 0) & 0xFF;
Color.RGBtoHSB(oldR, oldG, oldB, hsb);
final double factor = 1.2 - 0.9 * Math.pow(Util.distance(centerX, chief, x, y) / maxDistance, 1.5);
hsb[2] = Util.clamp(hsb[2] * (float)factor, 0, 1);
final int newRGB = Color.HSBtoRGB(hsb[0], hsb[1], hsb[2]) & 0x00FFFFFF;
image.setRGB(x, y, (oldA << 24) | newRGB);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment