Skip to content

Instantly share code, notes, and snippets.

View moebiussurfing's full-sized avatar
🌀

moebiusSurfing moebiussurfing

🌀
View GitHub Profile
@moebiussurfing
moebiussurfing / imgui_color_gradient.cpp
Created June 27, 2021 20:42 — forked from galloscript/imgui_color_gradient.cpp
Gradient color generator and editor for ImGui
//
// imgui_color_gradient.cpp
// imgui extension
//
// Created by David Gallardo on 11/06/16.
#include "imgui_color_gradient.h"
#include "imgui_internal.h"
namespace ImGui
{
static bool SelectFile(const std::string &path, std::string &selected, const std::vector<std::string> &ext={}) {
bool ret = false;
if(ofFile(path).isDirectory()) {
if(TreeNode(ofFilePath::getBaseName(path).c_str())) {
ofDirectory dir;
if(!ext.empty()) {
dir.allowExt("");
for(auto &&e : ext) {
@moebiussurfing
moebiussurfing / ofApp.cpp
Last active March 9, 2021 03:10
ImGui layout widgets filling width
if (ofxImGui::BeginWindow("TEST", mainSettings, flags)){
ImGui::BeginGroup();
{
int numRows = 2;
int numWidgets = 3;
float spcx =ImGui::GetStyle().ItemSpacing.x;
float spcy =ImGui::GetStyle().ItemSpacing.y;
float maxWidth = ImGui::GetContentRegionAvail().x - spcx;
@moebiussurfing
moebiussurfing / ofApp.cpp
Last active January 5, 2021 20:19
openFrameworks / ofParameters cast
// casting ofParameters
float v = static_cast<ofParameter<float>&>(parameter);
ofParameter<float> prop = static_cast<ofParameter<float>&>(parameter);
ofParameter<float> prop = parameter.cast<float>();
//which internally does the static cast you are using now.
//https://forum.openframeworks.cc/t/ofparametergroup-best-practices/18752/8
//--
@moebiussurfing
moebiussurfing / ofApp.cpp
Created January 5, 2021 20:18
openFrameworks | ofxImGui fbo + image + texture + clickable
//.h
ofTexture tex;
ofFbo fbo;
void quantizerRefreshImage();
//.cpp
//setup
bool b = ofGetUsingArbTex();
ofDisableArbTex();
@moebiussurfing
moebiussurfing / gist:c5ee135ad6624cf41f43de732b7df65e
Last active October 16, 2020 19:37
openFrameworks ofParameter pointers
//pass parameter as reference?
//https://forum.openframeworks.cc/t/its-posible-to-pass-reference-to-an-ofparameter-float-as-a-simple-c-float-type/34301
ofParameter<float> fParam;
ofxPrintMyVars::addFloat("myFloat", (float*)&fParam.get());
//-
ofApp.cpp
setup()
@moebiussurfing
moebiussurfing / CaptureWindow.h
Created September 10, 2020 22:24
openFrameworks / CaptureWindow.h : realtime video capturer for Windows. Using ofxFFmpegRecorder & ofxFastFboReader
#pragma once
#include "ofMain.h"
//TODO: BUG: when enabled antialias 16 or RGBF32 recording goes grey...?
//windows ffmpeg screen recorder
#ifdef TARGET_WIN32
#include "ofxFFmpegRecorder.h"
#include "ofxFastFboReader.h"
@moebiussurfing
moebiussurfing / ofApp.cpp
Last active August 22, 2020 16:55
openFrameworks / get a widget/parameter from and ofxGuiGroup
//https://forum.openframeworks.cc/t/can-iterate-though-all-ofxgui-elements/35047/11
//https://forum.openframeworks.cc/t/its-posible-to-avoid-ofxgui-float-ofxslider-label-style-2-8e-15-to-0-000028/35953/2
gui.setup(parameters);
//iterate through all elements of this gui
for (int i = 0; i < gui.getNumControls(); i++) {
auto control = gui.getControl(i);
//check if one of the elements might be a parameterGroup; i.e. parameter contains multiple items
@moebiussurfing
moebiussurfing / ofApp.cpp
Created August 5, 2020 22:59
openFrameworks / customize ofxGui theme dark theme
//ofxGui theme
//.cpp
//setup
setTheme_ofxGui();
//ofApp.h
void setTheme_ofxGui()
{
string pathFont = "assets/fonts/overpass-mono-bold.otf";
@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
//--------------------------------------------------------------