Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PFont myFont;
- PGraphics myPGraphic;
- color myPGraphicTypeColor = color(0);
- String myText = "LOL";
- int myUnit = 10;
- void setup() {
- size(960,540);
- noStroke();
- myFont = createFont("SourceCodePro-BOld", 200);
- myPGraphic = createGraphics(width,height); // just greates a graphic that is the size of the canvas
- myPGraphic.beginDraw(); //now everything after this will draw to the PGraphic
- myPGraphic.textFont(myFont); // what font to use?
- myPGraphic.textAlign(CENTER, CENTER); // align the text
- myPGraphic.fill(myPGraphicTypeColor); //creating a variable here allows you to change this universally, it's like making a swatch
- 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
- 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
- frameRate(100);
- }
- void draw() {
- //image(myPGraphic, 0, 0);
- fill (random(255));
- int randomX = int(random(width));
- int randomY = int(random(height));
- color myCheckColor = myPGraphic.get(randomX, randomY);
- if (myCheckColor == myPGraphicTypeColor) { // if the pixel color in your PGraphic matches your PGraphicTypeColor... draw an ellipse
- ellipse(randomX,randomY,40,40);
- } else {
- fill(255, 0, 0);
- ellipse(randomX, randomY, random(5), random(5));
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement