← Back

ofxColorTheory

github.com/kasparsj/ofxColorTheory · @kasparsj
OF 0.12 Algorithms Graphics

Color-theory palette generation and interpolation in C++ (with or without openFrameworks).

18 1 Last commit 3mo ago Created 8y ago

Branches ahead of master

These branches have commits not yet on master — could be unmerged fixes or work in progress worth a look.

codex/meshled-include-guards 1 commit ahead · last commit 3mo ago

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:

Interpolation supports RGB, HSB, and CIELCh (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:

A complete reference implementation is in tests/color_theory_tests.cpp.

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 run


Build (Plain C++)



c++ -std=c++17 -I./src your_app.cpp src/ColorUtil.cpp -o your_app


Use 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



Tests



Standalone C++ smoke tests (no openFrameworks required):

cd tests
make run

Get this addon

HTTPS
SSH