Skip to content

Instantly share code, notes, and snippets.

View moebiussurfing's full-sized avatar
🌀

moebiusSurfing moebiussurfing

🌀
View GitHub Profile
@moebiussurfing
moebiussurfing / .cpp
Created July 15, 2020 00:13
openFrameworks / easy simple drawTextBoxed helper util
//ofApp.h
ofTrueTypeFont font;
float fontSize;
//--------------------------------------------------------------
void drawTextBoxed(string text, int x, int y, int alpha = 255)
{
ofPushStyle();
int pad = 20;
@moebiussurfing
moebiussurfing / ofApp.h
Last active July 16, 2020 01:09
openframeworks | check if a folder path exist and creates one if not
//check if a folder path exist and creates one if not
//many times when you try to save a file, this is not possible and do not happens bc the container folder do not exist
//--------------------------------------------------------------
void CheckFolder(string _path)
{
ofLogNotice(__FUNCTION__) << _path;
ofDirectory dataDirectory(ofToDataPath(_path, true));
@moebiussurfing
moebiussurfing / ofApp.cpp
Created June 26, 2020 20:55
openFrameworks two ofParameter linked as references
params.setName("myGroupParameters");
params.add(separation.set("separation", 5, 1, 100));
separationREF.makeReferenceTo(separation);
params.add(separationREF.set("separationREF", 5, 1, 100));
//separationREF - separation are linked
@moebiussurfing
moebiussurfing / ofApp.cpp
Created May 28, 2020 03:27
openFrameworks / ImGui helper
// my own helper
template<typename ParameterType>
bool AddParameter(ofParameter<ParameterType>& parameter);
// my own helper
//--------------------------------------------------------------
template<typename ParameterType>
bool ofApp::AddParameter(ofParameter<ParameterType>& parameter)
{
@moebiussurfing
moebiussurfing / ofApp.cpp
Created May 10, 2020 14:17
openFrameworks / soundStream: audioIn / audioOut from maximilian example
//.h
// For drawing
float waveform[4096]; //make this bigger, just in case
int waveIndex;
ofSoundStream soundStream;
/* ofxMaxi*/
void audioIn(ofSoundBuffer& input) override; // not used in this example
void audioOut(ofSoundBuffer& output) override;
@moebiussurfing
moebiussurfing / ofApp.cpp
Last active May 7, 2020 03:41
openFrameworks / check if a data folder is present, create the folder if not.
void ofApp::CheckFolder(string _path)
{
ofDirectory dataDirectory(ofToDataPath(_path, true));
//check if target data folder exist
if (!dataDirectory.isDirectory())
{
ofLogError("__FUNCTION__") << "FOLDER DOES NOT EXIST!";
//create folder
@moebiussurfing
moebiussurfing / ofApp.cpp
Created May 6, 2020 06:02
openFramewokrs / ImGui circular knob
//https://github.com/ocornut/imgui/issues/942#issuecomment-268369298
//put code into ofApp.cpp and use between begin/end:
if (MyKnob("attack", &myKnob, 0.f, 10.f))
{
cout << "knob:" << myKnob << endl;
}
// Implementing a simple custom widget using the public API.
@moebiussurfing
moebiussurfing / ofApp.cpp
Created May 6, 2020 05:48
openFrameworks / ImGui toggle button. styled and with animation
//2 snippets from here:
//https://github.com/ocornut/imgui/issues/1537
//1. styled rounded toggle button with animation
//add into ofApp.cpp
namespace ImGui {
void ToggleButton(const char* str_id, bool* v)
{
ImVec2 p = ImGui::GetCursorScreenPos();
ImDrawList* draw_list = ImGui::GetWindowDrawList();
@moebiussurfing
moebiussurfing / ofApp.cpp
Last active August 4, 2020 10:55
openFrameworks / ofParameterGroup save/load parameters settings to xml
//h
void loadGroup(ofParameterGroup &g, string path);
void saveGroup(ofParameterGroup &g, string path);
//cpp
//--------------------------------------------------------------
@moebiussurfing
moebiussurfing / ofApp.cpp
Last active May 5, 2020 22:28
openFrameworks / template for parameter types / ofxImGui example
template<typename ParameterType>
bool AddParameter(ofParameter<ParameterType>& parameter);
//--------------------------------------------------------------
template<typename ParameterType>
bool ofxImGui::AddParameter(ofParameter<ParameterType>& parameter)
{
auto tmpRef = parameter.get();