Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 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.  
  22.  
  23.  
  24.  
  25. void draw() {
  26.  
  27. image(myPGraphic, 0, 0);
  28.  
  29.  
  30.  
  31. fill (255);
  32. for(int i=0; i < width; i+=myUnit){ // created variable myUnit so that we can change the number easily, up top
  33. for(int j=0; j < height; j+=myUnit) { // y = 0, keep adding one to y for as long as y is less than 200)
  34. color myCheckColor = myPGraphic.get(i,j); // checks the color of the pixels in your PGraphic where you were going to draw i and j
  35.  
  36.  
  37. if (myCheckColor == myPGraphicTypeColor) { // if the pixel color in your PGraphic matches your PGraphicTypeColor... draw an ellipse
  38. ellipse(i,j,5,5);
  39. } else {
  40. ellipse(i, j, 2, 2);
  41. }
  42. }
  43. }
  44.  
  45.  
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement