Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float lineOffset = 0; // helper variable to offset eery second line
- float dotSize=40; // size of our dots
- float dotSpacing=90; // the spacing of our dots
- int fileCounter=0; // a counter for file saving
- void setup() {
- colorMode(HSB,100);
- size(1920, 1080); //set screen size
- background(100, 0, 100); // draw background
- noStroke(); // remove outlines
- }
- void draw() {
- }
- void keyPressed() {
- // this is being called when u press a button
- if (key=='d') {
- drawDots();
- }
- if (key=='r') {
- // save the content of the screen to a file
- save("dots" + fileCounter + ".png");
- fileCounter++; //fileCounter = fileCounter + 1
- println("Saved!");
- // randomize fill color
- fill(random(255),random(255),random(255));
- // randomize background color
- background(random(255),random(255),random(255));
- // randomize size
- dotSize=random(10,100);
- // randomize spacing
- dotSpacing=random(dotSize + 5, dotSize + 100);
- }
- }
- void drawDots() {
- background(100,0,100);
- dotSpacing = 45;
- float stretch=random(1,16);
- float colorOffset=random(0,100);
- for (int j=-5; j < 150; j=j+1) { // outer loop for lines
- for (int i=-5; i < 200; i=i+1) { // inner loop for individual circles
- // first we check if the line we are drawing
- // is odd or even
- if (j%2==0) {
- // if even, we offset the entire line
- lineOffset=dotSpacing/2;
- } else {
- lineOffset=0;
- }
- lineOffset=random(200);
- // actually draw the dot
- float dotX=i*dotSpacing+lineOffset;
- float dotY=j*dotSpacing + random(200);
- dotSize = random(30,100);
- float myColor=dotX/width * 100;
- myColor = myColor / stretch;
- myColor = myColor + colorOffset;
- myColor = myColor + random(5);
- myColor = myColor % 100;
- fill(myColor,100-random(10),100, random(50,100));
- ellipse(dotX, dotY, dotSize, dotSize);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement