Created
January 11, 2017 22:53
-
-
Save staceymakes/4ad98a84570ce8fdba50c7e8b6366fed to your computer and use it in GitHub Desktop.
Basic Processing Class - Go down sketch by sketch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //DRAW A RECT | |
| //DRAW AN ELLIPSE/CIRCLE//////// | |
| void setup() { | |
| size(500,400); | |
| background(0); | |
| } | |
| void draw() { | |
| rect(100,100,100,100); | |
| } | |
| ///////////////// | |
| //DRAW AN ELLIPSE/CIRCLE//////// | |
| void setup() { | |
| size(500,400); | |
| background(0); | |
| } | |
| void draw() { | |
| ellipse(100,100,100,100); | |
| } | |
| ////////////////////// | |
| //COLOR AN ITEM grayscale/////////////////////// | |
| void setup() { | |
| size(500,400); | |
| background(0); | |
| } | |
| void draw() { | |
| ellipse(100,100,100,100); | |
| fill(100); | |
| } | |
| // COLOR AN ITEM RED ///////////////// | |
| void setup() { | |
| size(500,400); | |
| background(0); | |
| } | |
| void draw() { | |
| ellipse(100,100,100,100); | |
| fill(255,0,0); | |
| } | |
| // COLOR AN ITEM RANDOMLY!!!!///////////// | |
| void setup() { | |
| size(500,400); | |
| background(0); | |
| } | |
| void draw() { | |
| ellipse(100,100,100,100); | |
| fill(random(255),random(255),random(255)); | |
| } | |
| // COLOR AN ITEM and AFFECT THE STROKE///////////// | |
| void setup() { | |
| size(500,400); | |
| background(0); | |
| } | |
| void draw() { | |
| ellipse(100,100,100,100); | |
| stroke(255); | |
| strokeWeight(5); | |
| fill(random(255),random(255),random(255)); | |
| } | |
| //////////////////////////////////////////////////////////// | |
| // NOW LETS DO MULTIPLES OF ITEMS //////////////////////// | |
| //DRAW CIRCLES //////////////////////////////////////////// | |
| void setup() { | |
| size(500,400); | |
| background(0); | |
| } | |
| void draw() { | |
| for( int i=0;i<width;i++){ | |
| ellipse(random(width),random(height),random(100),random(100)); | |
| } | |
| } | |
| ////////////////////////////////////////////////////////// | |
| //////////////////////////////////////////// | |
| //Draw Circles affected by the mouse | |
| //////////////////////////////////////////// | |
| void setup() { | |
| size(500,400); | |
| background(random(255), random(255), random(255)); | |
| fill(random(255), random(255), random(255)); | |
| } | |
| void draw() { | |
| float diameter = random(50); | |
| ellipse(mouseX, mouseY, diameter, diameter); | |
| } | |
| ///////////////////////////////////////// | |
| //DRAW ONLY WHEN THE MOUSE IS PRESSED/// | |
| //////////////////////////////////////// | |
| void setup() { | |
| size(500,400); | |
| background(0); | |
| } | |
| void draw() { | |
| if (mousePressed) { | |
| ellipse(mouseX,mouseY,60,60); | |
| } | |
| } | |
| //////////////////////////////////////////////////////// | |
| //////////////////////////////////////////////////////// | |
| //DRAW LINES FROM THE CORNERS TO MOUSE | |
| ////////////////////////////////////// | |
| void setup() { | |
| size(600, 400); | |
| background(9,35,54); | |
| stroke(233,249,247, 30); | |
| } | |
| void draw() { | |
| line(mouseX, mouseY,0, 0 ); | |
| line(mouseX, mouseY,600, 400 ); | |
| line(mouseX, mouseY,600, 0 ); | |
| line(mouseX, mouseY,0, 400 ); | |
| line(mouseX, mouseY,300, 0 ); | |
| line(mouseX, mouseY,300, 400 ); | |
| line(mouseX, mouseY,0, 200 ); | |
| line(mouseX, mouseY, 600,200); | |
| } | |
| void mousePressed() { | |
| //RESETS THE BACKGROUND - wipes the canvas | |
| background(9,35,54); | |
| } | |
| ///////////////////////////////// | |
| ////////////////////////////////////// | |
| //LINES DRAWING - good for frame rate | |
| void setup() { | |
| size(640, 360); | |
| background(0); | |
| strokeWeight(20); | |
| frameRate(30); | |
| } | |
| void draw() { | |
| for (int i = 0; i < width; i++) { | |
| float r = random(255); | |
| stroke(r); | |
| line(i, 0, w, height); | |
| } | |
| } | |
| //LOAD IMAGE AND DRAW IT WITH CIRCLES NOW YO//// | |
| //////////////////////////////////////////////// | |
| void setup() { | |
| size(640, 360); | |
| //reference an image that is local and set the size of the canvas the same | |
| img = loadImage("trump.jpg"); | |
| imageMode(CENTER); | |
| noStroke(); | |
| background(255); | |
| } | |
| void draw() { | |
| int x = int(random(img.width)); | |
| int y = int(random(img.height)); | |
| color pix = img.get(x, y); | |
| fill(pix, 128); | |
| ellipse(x, y, 10,10); | |
| } | |
| /////////////////////////////////////// | |
| // POINTELLIZE - LOAD IMAGE AND GET COLOR | |
| // AFFECTED BY THE MOUSE POSITION | |
| // YOU NEED AN IMAGE FOR THIS | |
| //////////////////////////////////////////// | |
| PImage img; | |
| int smallPoint, largePoint; | |
| void setup() { | |
| size(640, 360); | |
| img = loadImage("trump.jpg"); | |
| smallPoint = 4; | |
| largePoint = 40; | |
| imageMode(CENTER); | |
| noStroke(); | |
| background(255); | |
| } | |
| void draw() { | |
| float pointillize = map(mouseX, 0, width, smallPoint, largePoint); | |
| int x = int(random(img.width)); | |
| int y = int(random(img.height)); | |
| color pix = img.get(x, y); | |
| fill(pix, 128); | |
| ellipse(x, y, pointillize, pointillize); | |
| } | |
| //////////////////////////////////////////////////////// | |
| //DISTANCE | |
| /////////////////////////////////////////////////////////// | |
| float max_distance; | |
| void setup() { | |
| size(640, 360); | |
| noStroke(); | |
| max_distance = dist(0, 0, width, height); | |
| } | |
| void draw() { | |
| background(0); | |
| for(int i = 0; i <= width; i += 20) { | |
| for(int j = 0; j <= height; j += 20) { | |
| float size = dist(mouseX, mouseY, i, j); | |
| size = size/max_distance * 66; | |
| ellipse(i, j, size, size); | |
| } | |
| } | |
| } | |
| //MOUSE PRESS////////////////////////////////// | |
| /////////////////////////////////////////////////// | |
| void setup() { | |
| size(640, 360); | |
| fill(126); | |
| background(102); | |
| } | |
| void draw() { | |
| if (mousePressed) { | |
| stroke(255); | |
| } else { | |
| stroke(0); | |
| } | |
| line(mouseX-66, mouseY, mouseX+66, mouseY); | |
| line(mouseX, mouseY-66, mouseX, mouseY+66); | |
| } | |
| ////////////////////////////////////////////////////// | |
| //SAVE IMAGE ON KEYPRESS////////////////////////////// | |
| void keyPressed(){ | |
| if (key == ' ') { | |
| saveFrame("line-######.png"); | |
| } | |
| } | |
| // QUICK LITTLE SNIPPETS ////////////////////////// | |
| ////////////////////////////////////////////////////// | |
| // set a random color | |
| fill(random(255),random(255),random(255)); | |
| //set the stroke weight | |
| strokeWeight(10); | |
| // Place a square somewhere random | |
| rect(random(width),random(height),random(width),random(height)); | |
| fill(random(255)); | |
| //draw a circle | |
| ellipse(10,10,100,100); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment