ProcessingClass_08_Random_亂數

Class Room in OpenProcessing

Random

image2

size(300, 300);
background(255);

for (int i = 5; i < 300; i += 5) {
	line(0, i, 300, i);
}

==============================================================================

image3

size(300, 300);
background(255);

for (int i = 5; i < 300; i += 5) {
	line(random(100), i, random(200,300), i);
}

==============================================================================
image4

size(300, 300);
background(255);
float v = 0.0;
float inc = 0.01;

for (int i = 0; i < 300; i += 2) {
  float n = noise(v) * 300;
  line(0,i,n, i);
  v = v + inc;
}

==============================================================================
image5

size(300, 300);
background(255);
float v = 0.0;
float inc = 0.01;

for (int i = 0; i < 300; i += 2) {
  float n = noise(v) * 250;
  line(0,i,n, i);
  line(2 * n, i, 300, i);
  v = v + inc;
}

==============================================================================
image6

size(300, 300);
background(255);
float v = 0.0;
float inc = 0.01;
smooth();

for (int i = -50; i < 300; i += 5) {
  float n = noise(v) * 250;
  line(0,i,n,i);

  line(n, i, 1.25 * n, i + 30);
  line(1.25 * n, i + 30, 2 * n, i);

  line(2 * n, i, 300, i);
  v = v + inc;
}

==============================================================================
image7

size(300, 300);
background(255);
float v = 0.0;
float inc = 0.01;
smooth();
noFill();

for (int i = -50; i < 300; i += 5) {
  float n = noise(v) * 100;
  bezier(0,i,1.25 * n, i + 30, 1.25 * n, i + 30, 300, i);
  v = v + inc;
}

==============================================================================
image8

image9

Interactive Link

int n = 300;

void setup() {
 size(n,n); 
 background(255);
 noFill();
}

void draw() {
  bezier(random(n),random(n),random(n),random(n),
        random(n),random(n),random(n),random(n));
}

==============================================================================
image10

Interactive Link

int n = 300;

void setup() {
 size(n,n);
 background(255);
 noFill();
 smooth();
 frameRate(10);
}

void draw() {
 strokeWeight(random(1,6));
 stroke(random(64,255),random(64,255),random(64,255));
 bezier(random(n),random(n),random(n),random(n),
        random(n),random(n),random(n),random(n));
}

==============================================================================
image11

image12

Interactive Link

int n = 300;

void setup() {
 size(n,n); 
 background(255);
 smooth();
 frameRate(5);
}

void draw() {
  float r = random(n);
  fill(random(255),random(255),random(255));
  ellipse(random(n),random(n),r,r);
}

==============================================================================
image13

image14

Interactive Link

int n = 300;

void setup() {
 size(n,n); 
 background(255);
 smooth();
 frameRate(5);
 noStroke();
}

void draw() {
  float x = random(n);
  fill(random(255),random(255),random(255),random(255));
  ellipse(random(n),random(n),x,x);
}

==============================================================================

image15

size(300,300);

smooth();
strokeWeight(10);
stroke(0, 130);

for (int i = 0; i <= 50; i ++) {
  line(0, random(300), 300, random(300));
}

==============================================================================
image16

size(300,300);

smooth();
strokeWeight(10);
stroke(0, 130);

for (int i = 0; i <= 50; i ++) {
  strokeWeight(random(10));
  stroke(random(255));
  line(0, random(300), 300, random(300));
}

==============================================================================
image17

size(300,300);

smooth();
strokeWeight(10);
stroke(0, 130);

for (int i = 0; i <= 50; i ++) {
  strokeWeight(random(20));
  stroke(random(255), random(255), random(255));
  line(0, random(300), 300, random(300));
}

==============================================================================
image18

size(300,300);
background(0);
stroke(255, 60);

for (int i = 0; i < 300; i++) {
  strokeWeight(random(10));
  line(i-20, 300, i+0.5*random(100), 0);
}

==============================================================================
image19

size(300,300);
background(0);
stroke(255, 60);

for (int i = 0; i < 300; i++) {
  strokeWeight(random(10));
  line(i-20, 300, i+5*random(100), 0);
}

==============================================================================
image20

size(200,200);
noStroke();
for (int i = 0; i < 200; i += 10) {
  for (int j = 0; j < 200; j += 10) {
  fill((i+j) * 0.7);
  rect(i, j, 10, 10);
  }
}

==============================================================================
image21

size(300,300);

float xnoise = 0.0;
float ynoise = 0.0;
float inc = 0.015;

for (int y = 0; y < height; y++) {
  for (int x = 0; x < width; x++) {
    float gray = noise(xnoise, ynoise) * 255;
    stroke(gray);
    point(x, y);
    xnoise = xnoise + inc;
}
  xnoise = 0;
  ynoise = ynoise + inc;
}

==============================================================================

Leave a comment