mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
Changes to Color examples
This commit is contained in:
+1
-1
@@ -6,7 +6,7 @@
|
||||
int dim = 40;
|
||||
|
||||
void setup() {
|
||||
size(200, 200);
|
||||
size(640, 360);
|
||||
background(0);
|
||||
smooth();
|
||||
noStroke();
|
||||
@@ -1,46 +0,0 @@
|
||||
/**
|
||||
* Reading.
|
||||
*
|
||||
* An image is recreated from its individual component colors.
|
||||
* The many colors of the image are created through modulating the
|
||||
* red, green, and blue values. This is an exageration of an LCD display.
|
||||
*/
|
||||
|
||||
size(200, 200);
|
||||
noStroke();
|
||||
background(0);
|
||||
|
||||
// Load an image from the data directory
|
||||
PImage img = loadImage("cait.jpg");
|
||||
img.loadPixels();
|
||||
|
||||
// figure out how big to make each block based on
|
||||
// the sketch area and the size of the input image
|
||||
int eachW = width / img.width;
|
||||
int eachH = height / img.height;
|
||||
int each = min(eachW, eachH);
|
||||
// vertical stripes will be a third as wide
|
||||
int stripeW = each / 3;
|
||||
// make sure the block size is a multiple of 3
|
||||
each = 3 * stripeW;
|
||||
|
||||
int left = (width - (img.width * each)) / 2;
|
||||
int top = (height - (img.height * each)) / 2;
|
||||
|
||||
for (int y = 0; y < img.height; y++) {
|
||||
int y1 = top + y*each;
|
||||
|
||||
for (int x = 0; x < img.width; x++) {
|
||||
int pixel = img.get(x, y);
|
||||
int x1 = left + x*each;
|
||||
|
||||
fill(red(pixel), 0, 0);
|
||||
rect(x1 + stripeW*0, y1, stripeW, each);
|
||||
|
||||
fill(0, green(pixel), 0);
|
||||
rect(x1 + stripeW*1, y1, stripeW, each);
|
||||
|
||||
fill(0, 0, blue(pixel));
|
||||
rect(x1 + stripeW*2, y1, stripeW, each);
|
||||
}
|
||||
}
|
||||
@@ -13,8 +13,8 @@ float fillGap = 2.5;
|
||||
color c;
|
||||
|
||||
void setup() {
|
||||
size(200, 200);
|
||||
background(200,200,200);
|
||||
size(640, 360);
|
||||
background(200);
|
||||
noLoop();
|
||||
}
|
||||
|
||||
@@ -23,13 +23,13 @@ void draw() {
|
||||
// Reset angle to 0, so waves stack properly
|
||||
angle = 0;
|
||||
// Increasing frequency causes more gaps
|
||||
frequency+=.006;
|
||||
for (float j=0; j<width+75; j++){
|
||||
py = i+sin(radians(angle))*amplitude;
|
||||
angle+=frequency;
|
||||
frequency+=.002;
|
||||
for (float j = 0; j < width+75; j++){
|
||||
py = i + sin(radians(angle)) * amplitude;
|
||||
angle += frequency;
|
||||
c = color(abs(py-i)*255/amplitude, 255-abs(py-i)*255/amplitude, j*(255.0/(width+50)));
|
||||
// Hack to fill gaps. Raise value of fillGap if you increase frequency
|
||||
for (int filler = 0; filler<fillGap; filler++){
|
||||
for (int filler = 0; filler < fillGap; filler++){
|
||||
set(int(j-filler), int(py)-filler, c);
|
||||
set(int(j), int(py), c);
|
||||
set(int(j+filler), int(py)+filler, c);
|
||||
|
||||
Reference in New Issue
Block a user