vector<ofColor> ofxColourTheory::createRangeFromCompound(ofColor src) {
    vector<ofColor> colList;
    colList.push_back(src);
    bool isFlipped = ofRandomf()>.5;
    
    int direction = isFlipped ? -1 : 1;
    
    ofColor c = rotateRYB(src,30 * direction);
    c.setBrightness(wrap(c.getBrightness()/255.0f, 0.25f, 0.6f, 0.25f)*255.0f);
    colList.push_back(c);
    
    c = rotateRYB(src,30 * direction);
    c.setSaturation(wrap(c.getSaturation()/255.0f, 0.4f, 0.1f, 0.4f)*255.0f);
    c.setBrightness(wrap(c.getBrightness()/255.0f, 0.4f, 0.2f, 0.4f)*255.0f);
    colList.push_back(c);
    
    c = rotateRYB(src,160 * direction);
    c.setSaturation(wrap(c.getSaturation()/255.0f, 0.25f, 0.1f, 0.25f)*255.0f);
    c.setBrightness(max(0.2f*255, c.getBrightness()*255));
    colList.push_back(c);
    
    c = rotateRYB(src,150 * direction);
    c.setSaturation(wrap(c.getSaturation()/255.0f, 0.1f, 0.8f, 0.1f)*255.0f);
    c.setBrightness(wrap(c.getBrightness()/255.0f, 0.3f, 0.6f, 0.3f)*255.0f);
     colList.push_back(c);
    
    c = rotateRYB(src,150 * direction);
    c.setSaturation(wrap(c.getSaturation()/255.0f, 0.1f, 0.8f, 0.1f)*255.0f);
    c.setBrightness(wrap(c.getBrightness()/255.0f, 0.4f, 0.2f, 0.4f)*255.0f);
     
     
    // colors.add(c);
    
    return colList;
}
vector<ofColor> ofxColourTheory::createRangeFromAnalogous(ofColor src){
    
    
    vector<ofVec2f> tones;
    tones.push_back(ofVec2f(1, 2.2f));
    tones.push_back(ofVec2f(2, 1));
    tones.push_back(ofVec2f(-1, -0.5f));
    tones.push_back(ofVec2f(-2, 1));
    
    float contrast = 0.25f;
    float theta = 10 *PI / 180.0;
        
    contrast = clipNormalized(contrast);
    
    vector<ofColor> colList;
    colList.push_back(src);
    
    
    for (int i=0;i<tones.size();i++) {
        ofColor c = rotateRYB(src,(int) (theta * tones[i].x));
        float t = 0.44f - tones[i].y * 0.1f;
        if ((float) src.getBrightness()/255.0 - contrast * tones[i].y < t) {
            c.setBrightness(t*255.0);
        } else {
            c.setBrightness(src.getBrightness() - (contrast * tones[i].y)*255.0);
        }
        c.setSaturation(c.getSaturation()-0.05f*255.0);
        colList.push_back(c);
    }
    return colList;
}
vector<ofColor> ofxColourTheory::createRangeFromSplitComplementary(ofColor src) {
    vector<ofColor> colList;
    colList.push_back(src);
    
    
    ofColor a = rotateRYB(src,150);
    a.setBrightness(a.getBrightness()+0.1f*255.0f);
    colList.push_back(a);
    
    ofColor b = rotateRYB(src,210);
    b.setBrightness(b.getBrightness()+0.1f*255.0f);
    colList.push_back(b);
    
    
    return colList;
}
vector<ofColor> ofxColourTheory::createRangeFromRightSplitComplementary(ofColor src) {
    ofColor right = getComplement(src);
    right = rotateRYB(right,30);
    right.setBrightness(right.getBrightness()+0.1f*255.0f);
    vector<ofColor> colList = createRangeFromComplementary(src);
    
    for (int i = 3; i < 6; i++) {
        ofColor c = colList[i];
        c.setHue(right.getHue());
    }
    return colList;
}
示例#5
0
ofColor getComplement(ofColor col){
    return rotateRYB(col,180);
}