Patterns

First pattern:

int x = 0;
void setup() {
size (800, 800);
}

void draw() {
background(115,191,188);
noStroke();

for (int i=0; i<width; i = i + 40)
{
for (int j=0; j<height; j = j + 20)
{
fill(1,118,115);
rect(i,j, 20,20);
}
}

for (int i=0; i<width; i = i + 40)
{
for (int j=0; j<height; j = j + 60)
{
fill(248,174,134);
quad(i,j+10, i+20,j, i+40,j+10, i+20,j+20);
}
}
for (int i=0; i<width; i = i + 40)
{
for (int j=0; j<height; j = j + 60)
{
fill(248,174,134);
quad(i-20,j+40, i,j+30, i+20,j+40, i,j+50);
}
}
saveFrame(“cubes.jpg”);
}

cubes

Second pattern:

void setup() {
size(600, 600);
}

void draw() {

// strokeWeight(5);
stroke(42,201,225);
background(232,10,47);

for (int gridY=0; gridY< 600; gridY+=100) {
for (int gridX=0; gridX< 600; gridX+=100) {

int x1 = 50;
int y1 = 50;
int x2 = 0;
int y2 = 0;

for(int side = 0; side < 4; side++) {
for(int i=0; i< 10; i++) {

if(side == 0){
x2 += 10;
y2 = 0;
}
if(side == 1){
x2 = 100;
y2 += 10;
}
if(side == 2){
x2 -= 10;
y2 = 100;
}
if(side == 3){
x2 = 0;
y2 -= 10;
}
line(x1+gridX, y1+gridY, x2+gridX, y2+gridY);
}
}
}
}
//saveFrame(“rays.jpg”);
}

Third pattern:

void setup() {
size(600, 600);
}

void draw() {
background(238,240,47);

for (int i=0; i<width; i+=60)
{
for (int j=0; j<height; j+=60)
{
fill(232,10,47);
stroke(42,201,225);
strokeWeight(3);
pushMatrix();
translate(i, j);
// rotate(frameCount / 100.0);
star(0, 0, 20, 200, 5);
popMatrix();
}
}
}
void star(float x, float y, float radius1, float radius2, int npoints) {
float angle = TWO_PI / npoints;
float halfAngle = angle/2.0;
beginShape();
for (float a = 0; a < TWO_PI; a += angle) {
float sx = x + cos(a) * radius2;
float sy = y + sin(a) * radius2;
vertex(sx, sy);
sx = x + cos(a+halfAngle) * radius1;
sy = y + sin(a+halfAngle) * radius1;
vertex(sx, sy);
}
endShape(CLOSE);

saveFrame(“stars2.jpg”);
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s