0% found this document useful (0 votes)
3K views39 pages

Processing: Repetition I

The document contains code for drawing various shapes using for loops in Processing. It includes lines, ellipses, and rectangles drawn with varying stroke weights, fills, and sizes as the loop progresses. Multiple for loops are nested or combined to draw intersecting or overlapping shapes on a black or white background.

Uploaded by

Gene Kao
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3K views39 pages

Processing: Repetition I

The document contains code for drawing various shapes using for loops in Processing. It includes lines, ellipses, and rectangles drawn with varying stroke weights, fills, and sizes as the loop progresses. Multiple for loops are nested or combined to draw intersecting or overlapping shapes on a black or white background.

Uploaded by

Gene Kao
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 39

Processing

Repetition I
I

03

Control 2: Repetition

size(1000,200);
background(0);
for (int i = 0; i <= 1000; i += 5) {
stroke(i,255,i);
line(i,10,i,190);
}

size(1275,200);
background(0);
smooth();
for (int i = 0; i <= 1275; i += 20) {
stroke(i,255,i);
line(i,10,i+5,190);
}

for (int i = 0; i < 5; i += 1) {


fill(51*(i+1));
ellipse(100,100,200-i*40,200-i*40);
}

fill(51);
ellipse(100,100,200,200);
fill(102);
ellipse(100,100,160,160);
fill(153);
ellipse(100,100,120,120);
fill(204);
ellipse(100,100,80,80);

fill(255);
ellipse(100,100,40,40);

size(200, 200);
line( 20, 20, 20, 180);
line( 40, 20, 40, 180);
line( 60, 20, 60, 180);
line( 80, 20, 80, 180);
line(100, 20, 100, 180);
line(120, 20, 120, 180);
line(140, 20, 140, 180);
line(160, 20, 160, 180);
line(180, 20, 180, 180);

size(200, 200);
for (int i = 20; i < 200; i += 20) {
line(i, 20, i, 180);
}

for (init; test; update) {


statements
}
for (; ; ) {

for (int i = 20; i < 200; i += 20) {


line(i, 20, i, 180);
}

1. ii= 20
2. i < 200
line(i, 20, i, 180);
3. i += 20 ( i = i + 20)
line( 20, 20, 20, 180);
line( 40, 20, 40, 180);

line(180, 20, 180, 180);


?

size(200, 200);
for (int i = 10; i < 200; i += 10) {
line(i, 10, i, 190);
}

size(200, 200);
for (int i = 10; i < 200; i += 10) {
line(10, i, 190, i);
}

size(200, 200);
for (int i = 10; i < 200; i += 10) {
line(10, i, 190, i);
}
for (int i = 10; i < 200; i += 10) {
line(i, 10, i, 190);
}

size(200, 200);
for (int i = 10; i < 200; i += 10) {
line(10, i, 190, i);
line(i, 10, i, 190);
}

size(200, 200);
smooth();
strokeWeight(5);
for (int i = 20; i < 200; i += 20) {
line(i, 20, i + 20, 180);
}

19

0.05

0.95

size(200, 200);
smooth();

for (int i = 10; i < 200; i += 10) {


strokeWeight(i /20);
line(i, 10, i, 190);
}

size(200, 200);
background(255);
smooth();
for (int i = 0; i <= 200; i += 10) {
line(0,i,i,0);
}

size(200, 200);
background(255);
smooth();
for (int i = 0; i <= 400; i += 10) {
line(0,i,i,0);
}

size(200, 200);
background(255);
smooth();
for (int i = 0; i <= 400; i += 10) {
line(0,i,i,0);
line(0,200-i,i,200);
}

size(201, 201);
background(255);
smooth();
for (int i = 0; i <= 200; i += 10) {
line(0,200-i,i,0);
line(i,200,200,200-i);
line(i,200,0,i);
line(i,0,200,i);
}

size(200, 200);
noFill();
for (int i = 0; i < 100; i += 10) {
rect(i, i, 200-2*i, 200-2*i);
}

size(200, 200);
for (int i = 0; i < 100; i += 10) {
fill(i / 100.0 * 255);
rect(i, i, 200-2*i, 200-2*i);
}

size(200, 200);
for (int i = 0; i < 100; i += 10) {
fill(i / 100.0 * 255, i / 100.0 * 255, 0);
rect(i, i, 200-2*i, 200-2*i);
}

size(200, 200);
smooth();
noFill();
for (int i = 10; i < 100; i += 10) {
strokeWeight(i / 10);
rect(i, i, 200 - 2 * i, 200 - 2 * i );
}

size(200, 200);
background(255);
smooth();
ellipseMode(CORNER);
for (int i = 0; i < 100; i += 10) {
fill(i / 100.0 * 255,i / 100.0 * 255,0);
ellipse(i, i, 200-2*i, 200-2*i);
}

size(200, 200);
background(0);
smooth();
noStroke();
ellipseMode(CORNER);
for (int i = 0; i < 100; i += 10) {
fill(i / 100.0 * 255,i / 100.0 * 255,0);
ellipse(i, i, 200-2*i, 200-2*i);
}

Ch. 5 - 6
04/19/2013

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy