¡Esta es una revisión vieja del documento!
float w = ofGetWidth(); float h = ofGetHeight(); float cx = w/2; float cy = h/2; img.allocate(w,h,OF_IMAGE_COLOR); for (float y=0; y<h; y++) { for (float x=0; x<w; x++) { float angle = atan2(y-cy,x-cy)+PI; float dist = ofDist(x,y,cx,cy); float hue = angle/TWO_PI*255; float sat = ofMap(dist,0,w/4,0,255,true); float bri = ofMap(dist,w/4,w/2,255,0,true); img.setColor(x,y,ofColor::fromHsb(hue,sat,bri)); } } img.reloadTexture();
ofColor ofxGetPixelColor(ofBaseHasPixels &img, int x, int y, int w, int h, int bpp=3) { ofColor c; int i = y*w*bpp + x*bpp; c.r = img.getPixels()[i+0]; c.g = img.getPixels()[i+1]; c.b = img.getPixels()[i+2]; if (bpp==4) c.a = img.getPixels()[i+3]; return c; } ofColor ofxGetPixelColor(int x, int y) { ofImage img; img.grabScreen(x,y,1,1); return ofxGetPixelColor(img,0,0,1,1); }
ofBackground( 255, 255, 255 );
// Rango de negro a rojo
for ( int i=0; i<256; i++ ) {
ofColor color = ofColor::red;
color.setBrightness( i );
ofSetColor( color );
ofLine( i, 0, i, 50 );
}
// Rango de blanco a rojo
for ( int i=0; i<256; i++ ) {
ofColor color = ofColor::red;
color.setSaturation( i );
ofSetColor( color );
ofLine( i, 80, i, 130 );
}
// Toda escala de colores
for ( int i=0; i<256; i++ ) {
ofColor color = ofColor::red;
color.setHue( i );
ofSetColor( color );
ofLine( i, 160, i, 210 );
}