Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int drawSpeed = 300; // number of drawn shapes per draw() call
- int drawMode = 0; // move through the drawing modes by clicking the mouse
- color BACKGROUND_COLOR = color(0);
- color PGRAPHICS_COLOR = color(0);
- PGraphics pg;
- void setup() {
- size(1280, 720);
- background(BACKGROUND_COLOR); // start of with a white background
- colorMode(HSB, 360, 100, 100); // change to Hue-Saturation-Brightness color mode
- rectMode(CENTER);
- noStroke();
- pg = createGraphics(width, height, JAVA2D);
- pg.beginDraw();
- pg.textSize(300);
- pg.textAlign(CENTER, CENTER);
- pg.fill(PGRAPHICS_COLOR);
- pg.text("ATOMIC", pg.width/2, pg.height/2);
- pg.endDraw();
- }
- void draw() {
- // This for loop ensures the code is repeated 'drawSpeed' times
- for (int i=0; i<drawSpeed; i++) {
- // pick a random coordinate
- int x = (int) random(width);
- int y = (int) random(height);
- // check if the coordinate is inside the text (in the offscreen PGraphics)
- boolean insideText = (pg.get(x, y) == PGRAPHICS_COLOR);
- // if it is indeed, then draw a shape in the main screen
- if (insideText) {
- // switch based on the current draw mode (move through them by clicking the mouse)
- // each drawing mode has custom settings (stroke, fill, shape, rotation)
- translate(x, y);{
- //switch (drawMode) {
- //case 0:
- float er = random(20, 45);
- color ec = color(random(35), random (65,100), 100);
- noStroke();
- fill(ec);
- ellipse(0, 0, er, er);
- break;
- }
- }
- }
- }
- //void mousePressed() {
- // background(BACKGROUND_COLOR); // clear the screen when changing drawing mode
- // drawMode = ++drawMode%3; // move through 3 drawing modes (0, 1, 2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement