Processing supports different color notations. RGB for colorvalues in Red, Green and Blue, ranging from 0 to 255. HSB for Hue, Saturation, Brightness in different ranges: hue from 0 to 360, the other two from 0 to 100.
// different color notations
size(300,300);
// RGB notation
colorMode(RGB);
color c = color(203,145,245);
background(c);
// HSB notation
colorMode(HSB);
color c2 = color(20,255,255);
fill(c2);
ellipse(120,40,40,40);
for (int g = 0; g < 12; g++) {
fill(g * 12,255,255);
ellipse(g * 20,g * 20,20,20);
}
// hex notation
color r = color(#22ffff);
fill(r);
rect(50,170,30,30);
Hex notation is also used a lot on the internet, mainly in CSS files; they represent a RGB color value in hex. 00 represents 0, FF represents 255. 127 is 7F. Here a small example. You can use for-loops to change color values to make gradients.
Geen opmerkingen:
Een reactie posten