Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

cleaning up project setup

  • Loading branch information...
commit d9119e5ef291f8bea48a54c2d617fed1c5de61d6 1 parent ea613ec
@joshuajnoble authored
View
BIN  .DS_Store
Binary file not shown
View
BIN  ch08/0803/.DS_Store
Binary file not shown
View
0  ch08/0804/orbitApp.cpp → ch08/0803/orbitApp.cpp
File renamed without changes
View
0  ch08/0804/orbitApp.h → ch08/0803/orbitApp.h
File renamed without changes
View
BIN  ch08/0804/.DS_Store
Binary file not shown
View
53 ch08/0804/MouseVoronoi.cpp
@@ -0,0 +1,53 @@
+
+#include "MouseVoronoi.h"
+
+void MouseVoronoi::setup() {
+ needRedraw = false;
+ ofSetBackgroundAuto(false);
+}
+
+void MouseVoronoi::update() {}
+
+void MouseVoronoi::draw() {
+
+ if (! needRedraw ) return;
+
+ ofBackground(255, 255, 255);
+
+ float w = ofGetWidth();
+ float h = ofGetHeight();
+
+ for( int x=0; x<w && (xs.size() > 0); x+=4 ) {
+ for( int y=0; y<h; y+=4) {
+ int idx = 0;
+ float dd;
+ dd = ofDist(xs[0],ys[0],x,y);
+ for( int i=1; i<d.size(); i++ ) {
+ float d0 = ofDist(xs[i],ys[i],x,y);
+ if( dd > d0 ) {
+ dd = d0;
+ idx = i;
+ }
+ }
+ ofSetColor(c[idx]);
+ ofRect(x, y, 4, 4);
+ }
+ }
+ ofSetColor(255);
+ for( int i=0; i<xs.size(); i++ ) {
+ ofEllipse(xs[i],ys[i],10,10);
+ }
+
+ needRedraw = false;
+}
+
+void MouseVoronoi::mousePressed( int x, int y, int button ) {
+ xs.push_back(mouseX);
+ ys.push_back(mouseY);
+ d.push_back(0);
+ ofColor cl(ofRandom(255),ofRandom(255),ofRandom(255));
+ c.push_back(cl);
+
+ needRedraw = true;
+}
+
View
25 ch08/0804/MouseVoronoi.h
@@ -0,0 +1,25 @@
+#pragma mark once
+
+#include "ofMain.h"
+
+#define NUM_POINTS 24
+
+class MouseVoronoi : public ofBaseApp{
+
+public:
+
+ void setup();
+ void update();
+ void draw();
+
+ void mousePressed( int x, int y, int button );
+
+ vector<float> xs;
+ vector<float> ys;
+ vector<float> d;
+ vector<ofColor> c;
+
+ bool needRedraw;
+
+
+};
View
18 ch08/0804/main.cpp 100755 → 100644
@@ -1,16 +1,12 @@
#include "ofMain.h"
-#include "orbitApp.h"
-#include "ofAppGlutWindow.h"
+#include "MouseVoronoi.h"
-//========================================================================
int main( ){
- ofAppGlutWindow window;
- ofSetupOpenGL(&window, 1024,768, OF_WINDOW); // <-------- setup the GL context
+ // can be oF_WINDOW or oF_FULLSCREEN
+ // pass in width and height too:
+ ofSetupOpenGL(1024,768, OF_WINDOW);// <-------- setup the GL context
+ // this kicks off the running of my app
+ ofRunApp(new MouseVoronoi);
- // this kicks off the running of my app
- // can be OF_WINDOW or OF_FULLSCREEN
- // pass in width and height too:
- ofRunApp( new orbitApp());
-
-}
+}
View
0  ch08/0803/MouseCircleFollow.cpp → ch08/0805/MouseCircleFollow.cpp
File renamed without changes
View
0  ch08/0803/MouseCircleFollow.h → ch08/0805/MouseCircleFollow.h
File renamed without changes
Please sign in to comment.
Something went wrong with that request. Please try again.