-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cb8d7af
commit 7d10a73
Showing
6 changed files
with
798 additions
and
729 deletions.
There are no files selected for viewing
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include "ofApp.h" | ||
#include "ofMain.h" | ||
|
||
int main() { | ||
|
||
ofGLWindowSettings settings; | ||
auto window = ofCreateWindow(settings); | ||
ofRunApp(window, std::make_shared<ofApp>()); | ||
ofRunMainLoop(); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#include "ofApp.h" | ||
|
||
void ofApp::update() { | ||
|
||
// you can check the state of a specific ofParameter | ||
// (wrapper around it's own "hidden Event") | ||
// no listeners/callbacks are required | ||
|
||
if (size.didNotify()) { | ||
ofLogNotice("new size") << size; | ||
} | ||
|
||
if (refresh.didNotify()) { | ||
color = ofColor::fromHsb(ofRandom(360), 128, 128); | ||
ofLogNotice("boosch") << color; | ||
} | ||
|
||
if (animate.didNotify()) { // this is the ofAbstractParameter::did_notify() | ||
if (animate != animating) { // sanity check | ||
animating = animate; | ||
if (animating) { | ||
ofLogNotice("stop animation"); | ||
} else { | ||
ofLogNotice("begin animation"); | ||
size = 0; | ||
} | ||
} | ||
} | ||
|
||
if (auto what = params.parameterChangedE().did_notify()) { // this is the Events::did_notify() | ||
// something happended in params, but you don't know what | ||
} | ||
} | ||
|
||
void ofApp::draw() { | ||
ofBackground(0); | ||
if (animating) { | ||
ofSetColor(color); | ||
ofDrawCircle(ofGetWidth() / 2, ofGetHeight() / 2, size); | ||
size = size + 1; | ||
if (size > 100) size -= 100; | ||
} | ||
ofDrawBitmapString("<a> to toggle automation", 10, 10); | ||
ofDrawBitmapString("<s> to randomize size", 10, 20); | ||
ofDrawBitmapString("<c> to change color", 10, 30); | ||
} | ||
|
||
void ofApp::keyPressed(int key) { | ||
if (key == 'a') animate = !animate; | ||
if (key == 'r') size = ofRandom(50, 100); | ||
if (key == 'c') refresh.trigger(); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#pragma once | ||
|
||
#include "ofMain.h" | ||
|
||
// note: this example, inspired by simpleEvents, is kept voluntarily | ||
// as small as possible to give a sense of the bare minimum requirements | ||
|
||
class ofApp : public ofBaseApp { | ||
|
||
ofParameter<bool> animate { "animate", false }; | ||
ofParameter<void> refresh { "refresh" }; | ||
ofParameter<float> size { "size", 1.0f, 0.0f, 100.0f }; | ||
ofParameterGroup params { "myCallbacksAndSettings", animate, refresh, size }; | ||
|
||
bool animating { false }; | ||
ofColor color { ofColor::white }; | ||
|
||
public: | ||
void update() override; | ||
void draw() override; | ||
void keyPressed(int key) override; | ||
}; |
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
Oops, something went wrong.