Advertisement
Guest User

Untitled

a guest
Feb 19th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. int drawSpeed = 300; // number of drawn shapes per draw() call
  2. int drawMode = 0; // move through the drawing modes by clicking the mouse
  3. color BACKGROUND_COLOR = color(0);
  4. color PGRAPHICS_COLOR = color(0);
  5.  
  6. PGraphics pg;
  7.  
  8. void setup() {
  9.  
  10. size(1280, 720);
  11. background(BACKGROUND_COLOR); // start of with a white background
  12. colorMode(HSB, 360, 100, 100); // change to Hue-Saturation-Brightness color mode
  13. rectMode(CENTER);
  14. noStroke();
  15.  
  16.  
  17.  
  18. pg = createGraphics(width, height, JAVA2D);
  19. pg.beginDraw();
  20. pg.textSize(300);
  21. pg.textAlign(CENTER, CENTER);
  22. pg.fill(PGRAPHICS_COLOR);
  23. pg.text("ATOMIC", pg.width/2, pg.height/2);
  24. pg.endDraw();
  25. }
  26.  
  27. void draw() {
  28.  
  29. // This for loop ensures the code is repeated 'drawSpeed' times
  30. for (int i=0; i<drawSpeed; i++) {
  31. // pick a random coordinate
  32. int x = (int) random(width);
  33. int y = (int) random(height);
  34. // check if the coordinate is inside the text (in the offscreen PGraphics)
  35. boolean insideText = (pg.get(x, y) == PGRAPHICS_COLOR);
  36. // if it is indeed, then draw a shape in the main screen
  37. if (insideText) {
  38. // switch based on the current draw mode (move through them by clicking the mouse)
  39. // each drawing mode has custom settings (stroke, fill, shape, rotation)
  40.  
  41.  
  42. translate(x, y);{
  43. //switch (drawMode) {
  44. //case 0:
  45. float er = random(20, 45);
  46. color ec = color(random(35), random (65,100), 100);
  47. noStroke();
  48. fill(ec);
  49. ellipse(0, 0, er, er);
  50. break;
  51. }
  52. }
  53. }
  54. }
  55. //void mousePressed() {
  56. // background(BACKGROUND_COLOR); // clear the screen when changing drawing mode
  57. // drawMode = ++drawMode%3; // move through 3 drawing modes (0, 1, 2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement