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
- }
- void draw() {
- image(myPGraphic, 0, 0);
- fill (255);
- for(int i=0; i < width; i+=myUnit){ // created variable myUnit so that we can change the number easily, up top
- for(int j=0; j < height; j+=myUnit) { // y = 0, keep adding one to y for as long as y is less than 200)
- color myCheckColor = myPGraphic.get(i,j); // checks the color of the pixels in your PGraphic where you were going to draw i and j
- if (myCheckColor == myPGraphicTypeColor) { // if the pixel color in your PGraphic matches your PGraphicTypeColor... draw an ellipse
- ellipse(i,j,5,5);
- } else {
- ellipse(i, j, 2, 2);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement