Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PFont myFont; // this variable holds a font
- PGraphics myPGraphic; // the variable holds a graphic
- color myPGraphicTypeColor = color(0);
- PImage myImage;
- String myText = "FUN";
- int myUnit = 10;
- // This is a list of all of the individual dots you create
- ArrayList<MyDotClass> myDotClassList;
- float myEasingFast = 0.05;
- // this runs once at the begining
- void setup() {
- size(960, 540);
- noStroke();
- colorMode(HSB);
- //myImage = loadImage("myGraphic.jpg");
- myDotClassList = new ArrayList<MyDotClass>(); // Initialize the arraylist
- myFont = createFont("SourceCodePro-Regular", 400);
- myPGraphic = createGraphics(width, height);
- myPGraphic.beginDraw();
- //myPGraphic.fill(0);
- //myPGraphic.rect(0, 0, width/2, height);
- //myPGraphic.fill(255);
- //myPGraphic.rect(width/2, 0, width/2, height);
- myPGraphic.textFont(myFont);
- myPGraphic.textAlign(CENTER, CENTER);
- myPGraphic.fill(myPGraphicTypeColor);
- myPGraphic.text(myText, width*.5, height*.5-50);
- myPGraphic.endDraw();
- for (int y = 0; y < height; y+=myUnit) {
- for (int x = 0; x < width; x+=myUnit) {
- color myCheckColor = myPGraphic.get(x, y);
- if (myCheckColor == myPGraphicTypeColor) {
- //ellipse(x, y, 5, 5);
- myDotClassList.add(new MyDotClass(x, y)); // add an instance of our class to the ArrayList
- }
- }
- }
- }
- //this runs forever
- void draw() {
- fill(0, 0, 0);
- rect(0, 0, width, height);
- //image(myPGraphic, 0, 0);
- //image(myImage,0,0);
- //int randomX = int(random(width));
- //int randomY = int(random(height));
- //color myCheckColor = myPGraphic.get(randomX, randomY);
- ////print(myCheckColor);
- //if (myPGraphic.get(randomX, randomY) == myPGraphicTypeColor) {
- // fill(0, 255, 0);
- // ellipse(randomX, randomY, 50, 50);
- //} else {
- // fill(255, 0, 0);
- // ellipse(randomX, randomY, 50, 50);
- //}
- for (MyDotClass myClassInstance : myDotClassList) {
- //if (!mousePressed) myClassInstance.myGoUpAndDown();
- //if (mousePressed) myClassInstance.myGoHome();
- myClassInstance.myUpdate();
- myClassInstance.myDisplay();
- }
- }
- //void mousePressed() {
- //}
- class MyDotClass {
- float myX, myY;
- float myXOrigin, myYOrigin;
- float myXDistance, myYDistance;
- float mySin;
- // constructor
- MyDotClass(float myXTemp, float myYTemp) {
- myXOrigin = myX = myXTemp;
- myYOrigin = myY = myYTemp;
- mySin = random(-.5, .5);
- }
- void myUpdate() {
- }
- void myDisplay() {
- //fill(255);
- int myHue = int(map(myY,0,height,150,0));
- fill(myHue,255,255);
- ellipse(myX, myY, 5, 5);
- }
- void myGoUpAndDown() {
- myY+=mySin;
- }
- void myGoHome() {
- myXDistance = myXOrigin - myX;
- myX += myXDistance * myEasingFast;
- myYDistance = myYOrigin - myY;
- myY += myYDistance * myEasingFast;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement