tagcloud/src/ColorHelper.java

27 wiersze
686 B
Java
Czysty Zwykły widok Historia

2013-03-11 17:16:46 +00:00
import java.awt.*;
2013-03-15 10:27:14 +00:00
/**
* Utility class to transform and parse colors.
*/
2013-03-11 17:16:46 +00:00
public class ColorHelper {
2013-03-15 10:27:14 +00:00
/**
* Transforms a java.awt.Color to processings internal int representation.
*
* @param c the color to be transformed
* @return A processing color value
*/
public static int transform(Color c) {
2013-03-11 17:16:46 +00:00
return (c.getAlpha() << 24) | (c.getRed() << 16) | (c.getGreen() << 8) | c.getBlue();
}
2013-03-15 10:27:14 +00:00
/**
* Decodes a color string in HEX-Values
*
* @param c the color string to be transformed
* @return A processing color value
*/
public static int decodeHex(String c) {
2013-03-11 17:16:46 +00:00
return transform(Color.decode(c));
}
}