Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. #include "ofMain.h"
  2.  
  3. class ofApp : public ofBaseApp{
  4. public:
  5.  
  6. float tileCount = 20;
  7. ofVec3f moduleColor = ofVec3f(0);
  8. int moduleAlpha = 100;
  9. int actRandomSeed = 0;
  10. int max_distance = 500;
  11.  
  12. void setup(){
  13. ofEnableSmoothing();
  14.  
  15. }
  16.  
  17. void draw(){
  18. ofBackground(255);
  19. ofNoFill();
  20.  
  21. ofSeedRandom(actRandomSeed);
  22.  
  23. for (int gridY=0; gridY<ofGetHeight(); gridY+=25) {
  24. for (int gridX=0; gridX<ofGetWidth(); gridX+=25) {
  25.  
  26. float diameter = ofDist(mouseX, mouseY, gridX, gridY);
  27. diameter = diameter / max_distance * 40;
  28.  
  29. ofSetLineWidth(3);
  30. ofSetColor(moduleColor.x,moduleColor.y,moduleColor.z, moduleAlpha);
  31.  
  32. ofPushMatrix();
  33. ofTranslate(gridX, gridY,diameter*5);
  34. ofDrawRectangle(0, 0, diameter, diameter);
  35. ofPopMatrix();
  36. }
  37. }
  38. }
  39.  
  40. void mousePressed(int x, int y, int button){
  41. actRandomSeed = (int)ofRandom(100000);
  42. }
  43. };
  44.  
  45.  
  46. //========================================================================
  47. int main( ){
  48. ofSetupOpenGL(600,600,OF_WINDOW); // <-------- setup the GL context
  49.  
  50. // this kicks off the running of my app
  51. // can be OF_WINDOW or OF_FULLSCREEN
  52. // pass in width and height too:
  53. ofRunApp(new ofApp());
  54.  
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement