Color-theory palette generation and interpolation in C++ (with or without openFrameworks).
Branches ahead of master
These branches have commits not yet on master — could be unmerged fixes or work in progress worth a look.
README
ofxColorTheory

ofxColorTheory started as an openFrameworks addon, but the core library is generic C++ and can be used without openFrameworks.What It Does
Generates color palettes from classic color-theory rules:
- Analogous
- Complementary
- SplitComplementary
- Compound
- FlippedCompound
- Monochrome
- Tetrad
- Triad
ColorSpace::Rgb, ColorSpace::Hsb, ColorSpace::Lch).Use With Plain C++ (No openFrameworks)
The library is template-based and works with any color type
T that provides the required interface.Required Interface For T
Your color type must provide:
static float limit()- channels:
r,g,b float getHue() constfloat getHueAngle() const(degrees 0..360)float getSaturation() constfloat getBrightness() constvoid setHue(float)void setSaturation(float)void setBrightness(float)static T fromHsb(float hue, float sat, float bri)T& lerp(const T& other, float amt)
Minimal Usage
#include "ColorWheelSchemes.h"
int main() {
auto scheme = ofxColorTheory::ColorWheelSchemes_<MyColor>::make(ofxColorTheory::ColorRule::Triad);
scheme->setPrimaryColor(MyColor(/ ... /));
scheme->regenerate();
auto palette = scheme->interpolate(64, ofxColorTheory::ColorSpace::Lch);
}C++-Only Example In This Repo
A full standalone example (custom color type + palette generation + console output) is available at:
examples/cpp_only/main.cpp
Build and run it:
cd examples/cpp_only
make runBuild (Plain C++)
c++ -std=c++17 -I./src your_app.cpp src/ColorUtil.cpp -o your_appUse With openFrameworks
#include "ColorWheelSchemes.h"
auto scheme = ofxColorTheory::ColorWheelSchemes_<ofColor>::make(ofxColorTheory::ColorRule::Triad);
scheme->setPrimaryColor(ofColor::orange);
scheme->regenerate();
std::vector<ofColor> palette = scheme->interpolate(64, ofxColorTheory::ColorSpace::Lch);API Notes
- Factory returns fresh instances (
std::unique_ptr) to avoid shared mutable state. - Use
ColorWheelSchemes_<T>::make(...). ColorScheme_andColorWheelScheme_have virtual destructors and checked accessors.- Integer color-space constants remain for compatibility, but
ColorSpaceis preferred.
Tests
Standalone C++ smoke tests (no openFrameworks required):
cd tests
make run
ofxAddons