Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. PFont myFont; // this variable holds a font
  2. PGraphics myPGraphic; // the variable holds a graphic
  3. color myPGraphicTypeColor = color(0);
  4. PImage myImage;
  5.  
  6. String myText = "MISTLETOE";
  7. int myUnit = 10;
  8.  
  9.  
  10. // this runs once at the begining
  11. void setup() {
  12. size(960, 540);
  13. noStroke();
  14. myImage = loadImage("myGraphic.jpg");
  15. myFont = createFont("SourceCodePro-Regular", 100);
  16. myPGraphic = createGraphics(width, height);
  17. myPGraphic.beginDraw();
  18. myPGraphic.fill(myPGraphicTypeColor);
  19. //myPGraphic.rect(0, 0, width/2, height);
  20. //myPGraphic.fill(255);
  21. //myPGraphic.rect(width/2, 0, width/2, height);
  22. myPGraphic.textFont(myFont);
  23. myPGraphic.textAlign(CENTER,CENTER);
  24. //myPGraphic.fill(myPGraphicTypeColor);
  25. myPGraphic.text(myText,width*.5,height*.5-30);
  26. myPGraphic.endDraw();
  27.  
  28.  
  29. frameRate(100);
  30.  
  31.  
  32. //for (int y = 0; y < height; y+=myUnit) {
  33. // for (int x = 0; x < width; x+=myUnit) {
  34.  
  35.  
  36. // color myCheckColor = myPGraphic.get(x, y);
  37. // print(myCheckColor);
  38.  
  39. // if(myPGraphic.get(x, y) == myPGraphicTypeColor){
  40. // ellipse(x, y, 5, 5);
  41. // } else {
  42. // ellipse(x, y, 2, 2);
  43. //}
  44.  
  45. //}
  46. }
  47. //}
  48.  
  49. //this runs forever
  50. void draw() {
  51. //image(myPGraphic, 0, 0);
  52. //image(myImage,0,0);
  53.  
  54. int randomX = int(random(width));
  55. int randomY = int(random(height));
  56. color myCheckColor = myPGraphic.get(randomX, randomY);
  57. print(myCheckColor);
  58.  
  59. if (myCheckColor == myPGraphicTypeColor) {
  60. fill(0, 255, 0);
  61. ellipse(randomX, randomY, 15, 15);
  62. fill(255, 0, 0);
  63. ellipse(randomX+10, randomY+10, 10, 10);
  64. }
  65. //else {
  66. //fill(255, 0, 0);
  67. //ellipse(randomX, randomY, 50, 50);
  68.  
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement