Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. PFont myFont;
  2. PGraphics myPGraphic;
  3. color myPGraphicTypeColor = color(0);
  4. String myText = "LOL";
  5. int myUnit = 10;
  6.  
  7. void setup() {
  8. size(960,540);
  9. noStroke();
  10.  
  11. myFont = createFont("SourceCodePro-BOld", 200);
  12. myPGraphic = createGraphics(width,height); // just greates a graphic that is the size of the canvas
  13. myPGraphic.beginDraw(); //now everything after this will draw to the PGraphic
  14. myPGraphic.textFont(myFont); // what font to use?
  15. myPGraphic.textAlign(CENTER, CENTER); // align the text
  16. myPGraphic.fill(myPGraphicTypeColor); //creating a variable here allows you to change this universally, it's like making a swatch
  17. myPGraphic.text(myText, width/2, height/2-40); // "word", location x, location y -- making word a variable up top, again, makes it easier to change later
  18. myPGraphic.endDraw(); // now, all of this has been drawn to the PGraphic. but you have to tell it draw this to the screen under void draw
  19.  
  20.  
  21. frameRate(100);
  22. }
  23.  
  24.  
  25.  
  26.  
  27.  
  28. void draw() {
  29.  
  30. //image(myPGraphic, 0, 0);
  31.  
  32.  
  33.  
  34. fill (random(255));
  35.  
  36. int randomX = int(random(width));
  37. int randomY = int(random(height));
  38. color myCheckColor = myPGraphic.get(randomX, randomY);
  39.  
  40.  
  41. if (myCheckColor == myPGraphicTypeColor) { // if the pixel color in your PGraphic matches your PGraphicTypeColor... draw an ellipse
  42. ellipse(randomX,randomY,40,40);
  43. } else {
  44. fill(255, 0, 0);
  45. ellipse(randomX, randomY, random(5), random(5));
  46. {
  47. }
  48. }
  49.  
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement