Created
December 5, 2016 02:13
-
-
Save hcientist/d7293a6a9d84174451cb499d13437ad8 to your computer and use it in GitHub Desktop.
phoenixifyColor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Color phoenixifyColor(Color originalPixelColor) { | |
// https://www.elon.edu/e/university-communications/identity/colors.html | |
final Color PHOENIX_MAROON = new Color(115, 0, 10); | |
final Color PHOENIX_GOLD = new Color(181, 154, 87); | |
// linear phoenixify | |
// final double RED_FACTOR = (PHOENIX_GOLD.getRed() - | |
// PHOENIX_MAROON.getRed()) / MAX_COLOR_VALUE; | |
// final double GREEN_FACTOR = (PHOENIX_GOLD.getGreen() - | |
// PHOENIX_MAROON.getGreen()) / MAX_COLOR_VALUE; | |
// final double BLUE_FACTOR = (PHOENIX_GOLD.getBlue() - | |
// PHOENIX_MAROON.getBlue()) / MAX_COLOR_VALUE; | |
// the simple phoenixify above turned out a little darker than I liked | |
// so I made this version that uses a cube-root, rather than linear mapping | |
final double RED_FACTOR = Math.pow((PHOENIX_GOLD.getRed() - PHOENIX_MAROON.getRed()) / MAX_COLOR_VALUE, | |
1 / 3.0); | |
final double GREEN_FACTOR = Math.pow((PHOENIX_GOLD.getGreen() - PHOENIX_MAROON.getGreen()) / MAX_COLOR_VALUE, | |
1 / 3.0); | |
final double BLUE_FACTOR = Math.pow((PHOENIX_GOLD.getBlue() - PHOENIX_MAROON.getBlue()) / MAX_COLOR_VALUE, | |
1 / 3.0); | |
int phoenixifiedRed = PHOENIX_MAROON.getRed() + (int) (originalPixelColor.getRed() * RED_FACTOR); | |
int phoenixifiedGreen = PHOENIX_MAROON.getGreen() + (int) (originalPixelColor.getGreen() * GREEN_FACTOR); | |
int phoenixifiedBlue = PHOENIX_MAROON.getBlue() + (int) (originalPixelColor.getBlue() * BLUE_FACTOR); | |
if (phoenixifiedRed > MAX_COLOR_VALUE) { | |
phoenixifiedRed = (int) MAX_COLOR_VALUE; | |
} | |
if (phoenixifiedGreen > MAX_COLOR_VALUE) { | |
phoenixifiedGreen = (int) MAX_COLOR_VALUE; | |
} | |
if (phoenixifiedBlue > MAX_COLOR_VALUE) { | |
phoenixifiedBlue = (int) MAX_COLOR_VALUE; | |
} | |
Color phoenixifiedColor = new Color(phoenixifiedRed, phoenixifiedGreen, phoenixifiedBlue); | |
return phoenixifiedColor; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment