/* A program for generating tileable colorful bubble textures. Written by Greg Batha */ import processing.pdf.*; ArrayList circles; void setup(){ colorMode(HSB); size(800, 800); background(255); smooth(); circles = new ArrayList(); //beginRecord(PDF, "bubbles.pdf"); background(255); drawTexture(); //endRecord(); } void draw(){ } public void drawTexture(){ for(int i = 0; i < height; i++){ Circle circle = new Circle((int)random(10, 30), (int)random(width), i); circle.display(); //checks to see if it goes over any edges and will draw another circle as the repeater //checks left and right if(circle.x + circle.diameter/2 + circle.weight/2 > width){ circle.display(circle.x - width, circle.y); } else if(circle.x - circle.diameter/2 - circle.weight/2 < 0){ circle.display(width + circle.x, circle.y); } //checks top and bottom if(circle.y + circle.diameter/2 + circle.weight/2 > height){ circle.display(circle.x, circle.y - width); } else if(circle.y - circle.diameter/2 - circle.weight/2 < 0){ circle.display(circle.x, height + circle.y); } } } public void mouseClicked(){ background(255); drawTexture(); } public class Circle{ int diameter; int x, y; color col; int weight; public Circle(int diameterIn, int xIn, int yIn){ diameter = diameterIn; x = xIn; y = yIn; weight = (int)(diameter/10)*2; col = color(random(255), random(150, 255), random(50, 255)); } public void fall(){ y++; } public void display(){ strokeWeight(weight); stroke(col); ellipse(x, y, diameter, diameter); } //alternate display method that displays the circle at an inputted x y position public void display(int xin, int yin){ strokeWeight(weight); stroke(col); ellipse(xin, yin, diameter, diameter); } }