Category: Lessons

  • Exercise 50

    /*——– Circle Pattern —————-*/ int margin; int res = 4; int padding; color c [] = { #75a665, #5c801a, #5a7e18, #735742, #afb837, #564311, #32320e }; void setup () { size (700, 700); smooth(); frameRate (10); margin = width/10; padding = width /30; } void draw () { background (237); randomSeed (year() + day() + hour()…

  • Bonus: Glitch

    PImage img; int min = 40, max = 80; int r = 10; void setup() { img = loadImage(“https://s-media-cache-ak0.pinimg.com/736x/2c/f6/a5/2cf6a58f75b368949cf98db03b925f1b.jpg”); size(img.width, img.height); image(img,0,0); } void draw() { int w = (int)random(min, max); int h = int(w*3); int x = (int)random(0, width-w); int y = (int)random(0, height-h); PImage tmp = createImage(w, h, RGB); tmp.loadPixels(); float rd =…

  • Exercise 45

    using rotation and sine cosine functions to draw patterns. float k = 2/7.0; int scaleIt = 400; void setup() { size(800, 800); background(20); colorMode(HSB); strokeWeight(0.01); smooth(); } void draw() { translate(width/2, height/2); //scale(width/2, height/2); float t = frameCount / 20.0; float x = cos(k*t) * sin(t) * scaleIt; float y = cos(k*t) * cos(t) *…

  • Exercise 43

    int num=50, d=100, frames=120; float theta; void setup() { size(540, 540, P2D); blendMode(SCREEN); stroke(255); noStroke(); fill(255); //noFill(); } void draw() { background(0); for (int j=0; j < 3; j++) { if (j==0) fill(255, 0, 0); if (j==1) fill(0, 255, 0); if (j==2) fill(0, 0, 255); for (int i=0; i < num; i++) { float angle…

  • Exercise 42

    int frames = 235, num=30; float theta; void setup() { size(750, 750); rectMode(CENTER); } void draw() { background(20); noFill(); translate(width/2, height/2); for (int i=0; i < num; i++) { pushMatrix(); float offSet=TWO_PI/num*i; rotate(offSet); float sz = map(sin(theta), -1, 1, width*.15, width*.2); float x = map(sin(theta), -1, 1, sz, width*.2); translate(x, 0); pushMatrix(); rotate(theta); stroke(200); if…

  • Exercise 41

    int frames = 220, num=30; float theta; void setup() { size(750, 750); } void draw() { background(20); stroke(#9EC3CE, 255); strokeWeight(2); noFill(); translate(width/2, height/2); for (int i=0; i < num; i++) { pushMatrix(); float offSet=TWO_PI/num*i; rotate(offSet); float sz = map(sin(theta),-1,1,width*.15,width*.2); float x = map(sin(theta), -1, 1, sz, width*.2); translate(x, 0); pushMatrix(); rotate(theta); if (i%2==0) { ellipse(0,…

  • Exercise 40

    Outputting an animation as video takes two steps saving frames of the animation as separate image files compiling the sequence of images into a movie using MovieMaker tool int frames = 200, num=20; float theta; void setup() { size(750, 750); } void draw() { background(20); fill(255, 30); stroke(255, 50); translate(width/2, height/2); for (int i=0; i…

  • Exercise 39

    // global vars int _num = 10; float _angnoise, _radiusnoise; float _xnoise, _ynoise; float _angle = -PI/2; float _radius = 100; float _strokeCol = 254; int _strokeChange = -1; void setup() { size(500, 300); smooth(); frameRate(30); clearBackground(); _angnoise = random(10); _radiusnoise = random(10); _xnoise = random(10); _ynoise = random(10); } void clearBackground() { background(255); }…

  • Exercise 38

    now we randomize the radius using the noise() function size(500,300); background(255); strokeWeight(0.5); smooth(); int centX = 250; int centY = 150; float x, y; for (int i = 0; i

  • Exercise 37

    size(500,300); background(255); strokeWeight(5); smooth(); float radius = 100; int centX = 250; int centY = 150; stroke(0, 30); noFill(); ellipse(centX,centY,radius*2,radius*2); stroke(20, 50, 70); radius = 10; float x, y; float lastx = -999; float lasty = -999; for (float ang = 0; ang -999) { line(x,y,lastx,lasty); } lastx = x; lasty = y; }