package com.haxademic.core.draw.color;

import processing.core.PApplet;

import com.haxademic.core.app.P;

public class ColorUtil {
	
	public static int colorWithIntAndAlpha( PApplet p, int color, int alpha ) {
//		float a = (color >> 24) & 0xFF;
//		float r = color >> 16 & 0xFF;  // Faster way of getting red(argb)
//		float g = color >> 8 & 0xFF;   // Faster way of getting green(argb)
//		float b = color & 0xFF;          // Faster way of getting blue(argb)

//		float r = color >> 16 & 0xFF;  // Faster way of getting red(argb)
//		float g = color >> 8 & 0xFF;   // Faster way of getting green(argb)
//		float b = color & 0xFF;          // Faster way of getting blue(argb)

//		float r = p.red(color);
//		float g = p.green(color);
//		float b = p.blue(color);
		
//		return p.color(r, g, b, alpha);
		
		// from: http://processing.org/discourse/beta/num_1261125421.html
		return (color & 0xffffff) | (alpha << 24); 
	}
	
	public static int colorFromHex( String hex ) {
		return P.unhex("FF"+hex.substring(1));
	}
}

@@ -208,732 +208,470 @@
 ) %7B%0A
-//%09%09float a = (color %3E%3E 24) & 0xFF;%0A//%09%09float r = color %3E%3E 16 & 0xFF;  // Faster way of getting red(argb)%0A//%09%09float g = color %3E%3E 8 & 0xFF;   // Faster way of getting green(argb)%0A//%09%09float b = color & 0xFF;          // Faster way of getting blue(argb)%0A%0A//%09%09float r = color %3E%3E 16 & 0xFF;  // Faster way of getting red(argb)%0A//%09%09float g = color %3E%3E 8 & 0xFF;   // Faster way of getting green(argb)%0A//%09%09float b = color & 0xFF;          // Faster way of getting blue(argb)%0A%0A//%09%09float r = p.red(color);%0A//%09%09float g = p.green(color);%0A//%09%09float b = p.blue(color);%0A%09%09%0A//%09%09return p.color(r, g, b, alpha);%0A%09%09%0A%09%09// from: http://processing.org/discourse/beta/num_1261125421.html%0A%09%09return (color & 0xffffff) %7C (alpha %3C%3C 24); %0A%09
+%09%09// from: http://processing.org/discourse/beta/num_1261125421.html%0A%09%09return (color & 0xffffff) %7C (alpha %3C%3C 24); %0A%09%7D%0A%09%0A%09public static int colorFromHex( String hex ) %7B%0A%09%09return P.unhex(%22FF%22+hex.substring(1));%0A%09%7D%0A%09%0A%09public final static int alphaFromColorInt( int c ) %7B return (c %3E%3E 24) & 0xFF; %7D%0A%09public final static int redFromColorInt( int c ) %7B return (c %3E%3E 16) & 0xFF;%09%7D%0A%09public final static int greenFromColorInt( int c ) %7B return (c %3E%3E 8)  & 0xFF; 
 %7D%0A
-%09%0A
 %09public 
 stat
@@ -658,32 +658,38 @@
 0xFF; %7D%0A%09public 
+final 
 static int color
@@ -687,79 +687,55 @@
 int 
-colorFromHex( String hex
+blueFromColorInt( int c
  ) %7B
-%0A%09%09
+ 
 return 
-P.unhex(%22FF%22+hex.substring(1));
+c & 0xFF; %7D
 %0A%09
-%7D
 %0A%7D%0A

Add r,g,b-from-int color extractor methods