Created
June 10, 2016 17:59
-
-
Save ofZach/c66baf5b28da39fcd014377f1a63b21a to your computer and use it in GitHub Desktop.
ovals!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "ofApp.h" | |
vector < vector < float > > energies; | |
//-------------------------------------------------------------- | |
void ofApp::setup(){ | |
ofSetCircleResolution(100); | |
for (int i = 0; i < 5; i++){ | |
int howMany = ofRandom(3, 7); | |
vector < float > energy; | |
for (int j = 0; j < howMany; j++){ | |
energy.push_back( ofRandom(0.05, 1.0)); | |
if (energy[j] < 0.3){ | |
energy[j] = powf(energy[j], 1.2); | |
} | |
} | |
energies.push_back(energy); | |
} | |
} | |
//-------------------------------------------------------------- | |
void ofApp::update(){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::draw(){ | |
float h = ofGetHeight()/energies.size(); | |
for (int i = 0; i < energies.size(); i++){ | |
float total = 0; | |
for (auto a: energies[i]){ | |
total += a; | |
} | |
float pos = 0; | |
for (auto a: energies[i]){ | |
float pct = a / total; | |
ofDrawEllipse( ofPoint(pos + pct*ofGetWidth()/2, i*h + h/2), pct*ofGetWidth(),h); | |
pos += pct * ofGetWidth(); | |
} | |
} | |
} | |
//-------------------------------------------------------------- | |
void ofApp::keyPressed(int key){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::keyReleased(int key){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::mouseMoved(int x, int y ){ | |
energies.clear(); | |
for (int i = 0; i < 5; i++){ | |
int howMany = ofRandom(3, 7); | |
vector < float > energy; | |
for (int j = 0; j < howMany; j++){ | |
energy.push_back( ofRandom(0.05, 1.0)); | |
if (energy[j] < 0.3){ | |
energy[j] = powf(energy[j], 1.2); | |
} | |
} | |
energies.push_back(energy); | |
} | |
} | |
//-------------------------------------------------------------- | |
void ofApp::mouseDragged(int x, int y, int button){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::mousePressed(int x, int y, int button){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::mouseReleased(int x, int y, int button){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::mouseEntered(int x, int y){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::mouseExited(int x, int y){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::windowResized(int w, int h){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::gotMessage(ofMessage msg){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::dragEvent(ofDragInfo dragInfo){ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment