Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Conrad Menchine's pointillism effect generator
- //hold down the left mouse button to draw points
- //shitty enum
- static int FUR = 1;
- static int SQUARES = 2;
- static int BEZ = 3; //bezier
- static int CIRCLES = 4;
- static int RAND = 5;
- int mode = BEZ;
- int dotSize = 16;
- int minDotSize = 4; //used for circle effect
- float dotSkew = 0.6; //used for circle effect
- PImage photo;
- void setup(){
- photo = loadImage("lake.jpg"); //load your own photo
- size(1400,800);
- noStroke();
- }
- void genPoints(){
- for(int i = 0; i < 1000; i++) dot(random(width), random(height));
- }
- void draw(){
- if(mousePressed) genPoints(); //shame on me
- }
- void dot(float x, float y){
- //Why didn't I use a switch/case? Because I'm a dingus, that's why
- if(mode == FUR){
- color dotCol = photo.get((int)x,(int)y);
- fill(dotCol);
- beginShape();
- curveVertex(x + random(dotSize*2), y);
- curveVertex(x, y + random(dotSize*2));
- curveVertex(x - random(dotSize*2), y);
- curveVertex(x, y - random(dotSize*2));
- endShape();
- }
- if(mode == SQUARES){
- color dotCol = photo.get((int)x,(int)y);
- fill(dotCol);
- beginShape();
- vertex(x + random(dotSize), y);
- vertex(x, y + random(dotSize));
- vertex(x - random(dotSize), y);
- vertex(x, y - random(dotSize));
- endShape();
- }
- if(mode == BEZ){
- color dotCol = photo.get((int)x,(int)y);
- fill(dotCol);
- float f1 = random(dotSize);
- float f2 = random(dotSize);
- float f3 = random(dotSize);
- float f4 = random(dotSize);
- beginShape();
- vertex(x + f1, y);
- //bezierVertex(x + f1, y, x, y + f2, x - f3, y);
- bezierVertex(x, y + f2, x - f3, y, x, y - f4);
- bezierVertex(x - f3, y, x, y - f4, x + f1, y);
- bezierVertex(x, y - f4, x + f1, y, x, y + f2);
- endShape();
- }
- if(mode == CIRCLES){
- color dotCol = photo.get((int)x,(int)y);
- fill(dotCol);
- ellipse(x,y, random(dotSize, minDotSize), random(minDotSize * dotSkew, dotSize * dotSkew));
- }
- if(mode == RAND){
- //just draws all of them and maybe selects itself sometimes too/ who cares; it works.
- mode = (int) random(RAND); //that's 5 for those of you following along at home
- dot(x,y); //wowie, recursion! I haven't seen that used since my last programming class and literally never anywhere else!
- mode = RAND;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement