• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ ofColor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中ofColor的典型用法代码示例。如果您正苦于以下问题:C++ ofColor类的具体用法?C++ ofColor怎么用?C++ ofColor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ofColor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: clipNormalized

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;
}
开发者ID:alexiswolfish,项目名称:ofxColourTheory,代码行数:31,代码来源:ofxColourTheory.cpp


示例2: rotateRYB

ofColor rotateRYB(ofColor col,int theta) {
    
    float h = (float) col.getHue()/255.0 * 360;
    vector<float> hsb;
    hsb.push_back((float) col.getHue()/255.0) ;
    hsb.push_back((float) col.getSaturation()/255.0) ;
    hsb.push_back((float) col.getBrightness()/255.0) ;
    theta %= 360;
    
    float resultHue = 0;
    
    vector<ofVec2f> RYB_WHEEL = getRYB_WHEEL();
    
    for (int i = 0; i < RYB_WHEEL.size() - 1; i++) {
        ofVec2f p = RYB_WHEEL[i];
        ofVec2f q = RYB_WHEEL[i + 1];
        if (q.y < p.y) {
            q.y += 360;
        }
        if (p.y <= h && h <= q.y) {
            resultHue = p.x + (q.x - p.x) * (h - p.y) / (q.y - p.y);
            break;
        }
    }
    
    //fmod = %, ie remainder
    
    // And the user-given angle (e.g. complement).
    resultHue = fmod((resultHue + theta),360);
    
    // For the given angle, find out what hue is
    // located there on the artistic color wheel.
    for (int i = 0; i < RYB_WHEEL.size() - 1; i++) {
        ofVec2f p = RYB_WHEEL[i];
        ofVec2f q = RYB_WHEEL[i + 1];
        if (q.y < p.y) {
            q.y += 360;
        }
        if (p.x <= resultHue && resultHue <= q.x) {
            h = p.y + (q.y - p.y) * (resultHue - p.x) / (q.x - p.x);
            break;
        }
    }
    
    hsb[0] = fmod(h, 360) / 360.0f;
    
    ofColor newCol;
    newCol.setHsb(hsb[0]*255, hsb[1]*255, hsb[2]*255);
    return newCol;
}
开发者ID:jeonghopark,项目名称:Experiments,代码行数:50,代码来源:Prototype01.cpp


示例3: computeColor

//--------------------------------------------------------------
void DevicePacket::computeColor(const ofColor& deviceColor, bool isColor, bool isInvert)
{
	float volume = isInvert ? 1.0f-m_volume : m_volume;

	if (isColor)
	{
		m_color.setHue(deviceColor.getHue());
		m_color.setSaturation(deviceColor.getSaturation());
		m_color.setBrightness(volume*255.0f);
	}
	else
	{
		m_color.set(volume*255.0f,volume*255.0f,volume*255.0f);
	}
}
开发者ID:v3ga,项目名称:murmur,代码行数:16,代码来源:device.cpp


示例4: parseHsb

 void parseHsb(ofColor & color, string attribute) {
     double h = m_settings.getAttribute(attribute, "hue", 0.0);
     double s = m_settings.getAttribute(attribute, "saturation", 0.0);
     double b = m_settings.getAttribute(attribute, "brightness", 0.0);
     double a = m_settings.getAttribute(attribute, "alpha", 1.0);
     color.setHsb(h * 255.f, s * 255.f, b * 255.f, a * 255.f);
 }
开发者ID:davidbeermann,项目名称:timely-matter,代码行数:7,代码来源:AppConfig.hpp


示例5: getNoiseAround

//--------------------------------------------------------------
ofColor ColorUtil::getNoiseAround( ofColor c, float radius, float seedValue )
{
	float hue, saturation, brightness;
	
	c.getHsb(hue, saturation, brightness);

	float noise = (ofNoise(seedValue) * (radius * 2)) - radius;
	hue = hue + noise;
	if (hue < 0) 
		hue = 255.0f + hue;
	if (hue > 255.0) 
		hue = hue - 255.0f;
	
	c.setHsb(hue, saturation, brightness);

	return (c);
}
开发者ID:antoniomechas,项目名称:ondaDump,代码行数:18,代码来源:ColorUtil.cpp


示例6: getNoiseAroundMax

//--------------------------------------------------------------
ofColor ColorUtil::getNoiseAroundMax( ofColor c, float radius )
{

	float hue, saturation, brightness;
	
	c.getHsb(hue, saturation, brightness);

	hue = hue + radius;
	if (hue < 0) 
		hue = 255.0f + hue;
	if (hue > 255.0) 
		hue = hue - 255.0f;
	
	c.setHsb(hue, saturation, brightness);

	return (c);

}
开发者ID:antoniomechas,项目名称:ondaDump,代码行数:19,代码来源:ColorUtil.cpp


示例7: getImage

//--------------------------------------------------------------
// create a visual representation of the simulation
void Rd::getImage(ofImage & image, const ofColor & c1, const ofColor & c2){
	unsigned char * pixels = image.getPixels();
	for(int indexImg = 0, indexA = 0; indexA < A.size(); indexImg += 3, indexA++){
		ofColor c = c1.getLerped(c2, A[indexA] * A[indexA]);
		pixels[indexImg] = c.r;
		pixels[indexImg + 1] = c.b;
		pixels[indexImg + 2] = c.g;
	}
	image.update();
}
开发者ID:danielmorena,项目名称:OF_GenerativeTypography,代码行数:12,代码来源:Rd.cpp


示例8: distanceBetween

float distanceBetween(ofColor a,ofColor b) {
    float hue = a.getHue()/255.0f *TWO_PI;
    float hue2 = b.getHue()/255.0f * TWO_PI;
    ofVec3f v1((cos(hue) * a.getSaturation()/255.0f),
               (sin(hue) * a.getSaturation()/255.0f), a.getBrightness()/255.0f);
    ofVec3f v2((cos(hue2) * b.getSaturation()/255.0f),
               (sin(hue2) * b.getSaturation()/255.0f), b.getBrightness()/255.0f);
    return v1.distance(v2);
}
开发者ID:jeonghopark,项目名称:Experiments,代码行数:9,代码来源:SingleBrush.cpp


示例9: setColor

void ofPixels::setColor(int x, int y, ofColor color) {
	int index = getPixelIndex(x, y);

	if( bytesPerPixel == 1 ){
		pixels[index] = color.getBrightness();
	}else if( bytesPerPixel == 3 ){
		pixels[index] = color.r;
		pixels[index+1] = color.g;
		pixels[index+2] = color.b;
	}else if( bytesPerPixel == 4 ){
		pixels[index] = color.r;
		pixels[index+1] = color.g;
		pixels[index+2] = color.b;
		pixels[index+3] = color.a;
	}
}
开发者ID:apexcode,项目名称:openFrameworks,代码行数:16,代码来源:ofPixels.cpp


示例10: makeParticleForPipe

void EffectPipeOrganLines :: makeParticleForPipe(int pipeindex, ofColor col) {
	if(pipeOrganData == NULL) return;
	
	ParticleSystemManager& psm = *(ParticleSystemManager::instance());
	ParticleSystem &ps = *psm.getParticleSystem();
	
	ParticleSystemSettings pss;
	pss.emitLifeTime = 0.1;
	pss.emitMode = PARTICLE_EMIT_BURST;
	pss.emitCount = 1;
	pss.renderer = new ParticleRendererLaser();
	pss.speedMin = 600 ;
	pss.speedMax = 650;
	pss.drag = 0.9;
	//pss.gravity.set(0,500,0);
	
	pss.sizeStartMin = pss.sizeStartMax = 1;
	pss.sizeChangeRatio = 0.1;
	//pss.emitShape = &explodeMesh;
	pss.directionYVar = pss.directionZVar = 0;
	pss.directionY = 0;
	pss.directionX = -35;
	
	pss.hueStartMin = pss.hueStartMax = col.getHue();
	pss.hueChange = 0;
	pss.saturationMin = pss.saturationMax = 255;
	pss.saturationEnd = 255;
	pss.brightnessStartMin = pss.brightnessStartMax =pss.brightnessEnd = 255;
	pss.lifeMin = pss.lifeMax = 0.5;
	pss.shimmerMin = 0;
	pss.timeSpeed = 0.7;
	//pss.doNotScale = true;
	
	ps.pos = pipeOrganData->pipes[pipeindex].top;
	ps.init(pss);
	
	
	
}
开发者ID:imclab,项目名称:LaserShow,代码行数:39,代码来源:EffectPipeOrganLines.cpp


示例11: createCircle

//--------------------------------------------------------------
ofMesh pen::createCircle(float x, float y, float radius, ofColor color){
    
    float sides = 30;
    ofMesh mesh;
	mesh.setMode(OF_PRIMITIVE_TRIANGLE_FAN);
    
    color.setBrightness(ofRandom(100,250));
    
    for(int i=0; i<=sides; i++){
        
        float pointRatio = i/sides; 
        float xSteps = cos(pointRatio*2*PI);
        float ySteps = sin(pointRatio*2*PI);
        float pointX = x + xSteps * radius;
        float pointY = y + ySteps * radius;
        
        mesh.addVertex(ofPoint(pointX, pointY));
        mesh.addColor(color);
    }
    
    
    return mesh;
}
开发者ID:VictorSigma,项目名称:LSC-Graffiti-Wall,代码行数:24,代码来源:pen.cpp


示例12: ofEnableSmoothing


//.........这里部分代码省略.........
        if (devices[i].bAvailable) {
            ofLogNotice() << devices[i].id << ": " << devices[i].deviceName;
        } else {
            ofLogNotice() << devices[i].id << ": " << devices[i].deviceName << " - unavailable ";
        }
    }
    
    for (int i = 0; i < devices.size(); i++) {
        if (!devices[i].deviceName.find("USB")) {
            cout << devices[i].id << endl;
            pcCams.push_back(devices[i].id);
        }
    }
    

    vidGrabber.setDeviceID(pcCams[0]);
//    vidGrabber.setDeviceID(0);

    vidGrabber.initGrabber(320,240);
    
    vidGrabber1.setDeviceID(pcCams[1]);
//    vidGrabber1.setDeviceID(0);

    vidGrabber1.initGrabber(320,240);
    
    colorImg1.allocate(320,240);
    grayImage1.allocate(320,240);
    grayBg1.allocate(320,240);
    grayDiff1.allocate(320,240);
    
    colorImg.allocate(320,240);
    grayImage.allocate(320,240);
    grayBg.allocate(320,240);
    grayDiff.allocate(320,240);
    
    bLearnBackground = true;
    bLearnBackground1 = true;
    threshold = 80;
    drawOne = false;
    
    bottomSwarm.a = 1.1f;
    bottomSwarm.b = (curWidth/4.0);
    bottomSwarm.c = 100.0;
    bottomSwarm.bVel = 1.0;
    
    xPos = 0;
    yPos = 0;
    zPos = 0;
    
    cam.setPosition(result["region0"]["ring0"]["point0"][0].asFloat(),result["region0"]["ring0"]["point0"][1].asFloat(),result["region0"]["ring0"]["point0"][2].asFloat());
    cam.lookAt(ofVec3f(result["region0"]["ring1"]["point0"][0].asFloat(),result["region0"]["ring1"]["point0"][1].asFloat(),result["region0"]["ring1"]["point0"][2].asFloat()));
    cam.rotate(ofRadToDeg(PI/2), 1.0, 0.0, 0.0);
    cam.setFov(32.0);
    
    sphereZPos = 25.9297;
    sphereXPos = 364.928;
    
    for (int i = 0; i < 20; i++) {
        spheresXPos[i] = ofRandom(result["region0"]["ring0"]["point0"][0].asFloat()-500, result["region0"]["ring0"]["point0"][0].asFloat()+500.0);
        spheresZPos[i] = ofRandom(result["region0"]["ring0"]["point0"][2].asFloat()-100.0, result["region0"]["ring0"]["point0"][2].asFloat()+100.0);
    }
    
    /* LIGHTING */
    ofSetSmoothLighting(true);

    pointLight.setDiffuseColor( ofColor(0.f, 255.f, 0.f));
    
    pointLight.setSpecularColor( ofColor(255.f, 255.f, 255.f));
    pointLight.setPosition(result["region0"]["ring0"]["point0"][0].asFloat(),result["region0"]["ring0"]["point0"][1].asFloat(),result["region0"]["ring0"]["point0"][2].asFloat());
    
    material.setShininess( 64 );
    
    colorHue = ofRandom(0, 250);
    colorHue2 = ofRandom(0, 250);
    
    lightColor.setBrightness( 180.f );
    lightColor.set(250,250,210);
    
    materialColor.setBrightness(250.f);
    materialColor.set(100,100,100);
    
    lightColor.setHue(colorHue);
    pointLight.setDiffuseColor(lightColor);
    
    materialColor.setHue(colorHue);
    material.setSpecularColor(materialColor);
    
    
    materialColor.set(255.0,0.0,0.0);
    columnMaterial.setSpecularColor(materialColor);
    
    materialColor.set(55.0,55.0,55.0);
    peopleMaterial.setSpecularColor(materialColor);
    
    cameraColor1.set(0.0, 0.0, 255.0);
    cameraColor2.set(0.0, 0.0, 255.0);
    columnColor.set(255, 0, 0);
    activeColor.set(0.0,0.0,255.0);

}
开发者ID:Future-Cities-Lab,项目名称:DCOpenFrameworks,代码行数:101,代码来源:ofApp.cpp


示例13: lineToMesh

//--------------------------------------------------------------
ofMesh pen::lineToMesh(ofPolyline line,ofColor color, float thicknessOffset, ofVec2f positionOffset){ 
    ofMesh mesh;
    mesh.setMode(OF_PRIMITIVE_TRIANGLE_STRIP); 
    vector<ofPoint> points = line.getVertices();
    
    int brightness = 255;
    
    for(int i = 1; i < points.size(); i++){
		ofVec2f thisPoint = ofVec2f(points[i-1].x,points[i-1].y);
		ofVec2f nextPoint = ofVec2f(points[i].x,points[i].y);
		ofVec2f direction = (nextPoint - thisPoint);
		float distance = direction.length();
        
		ofVec2f unitDirection = direction.normalized();
		ofVec2f toTheLeft = unitDirection.getRotated(-90);
		ofVec2f toTheRight = unitDirection.getRotated(90);
        
		float thickness = ofMap(thisPoint.y, 0, ofGetScreenHeight(), 5, 40);
        thickness += thicknessOffset;
        
        if (thicknessOffset == 0)
            color.setBrightness(ofMap(i, 0, points.size(), 250, 200));
        
		ofVec2f leftPoint = thisPoint+toTheLeft*thickness;
		ofVec2f rightPoint = thisPoint+toTheRight*thickness;
        
        if (thicknessOffset > 0 && i == 1){
            ofVec2f tempLeftPoint = leftPoint;
            ofVec2f tempRightPoint = rightPoint;
            
            tempLeftPoint -= unitDirection * (thickness/2);
            tempRightPoint -= unitDirection * (thickness/2);
            
            mesh.addVertex(ofVec2f(tempLeftPoint.x + positionOffset.x, tempLeftPoint.y + positionOffset.y));
            mesh.addColor(color);
            mesh.addVertex(ofVec2f(tempRightPoint.x + positionOffset.x, tempRightPoint.y + positionOffset.y));
            mesh.addColor(color);
        }
        
		mesh.addVertex(ofVec2f(leftPoint.x, leftPoint.y + positionOffset.y));
        mesh.addColor(color);
		mesh.addVertex(ofVec2f(rightPoint.x, rightPoint.y + positionOffset.y));
        mesh.addColor(color);
        
        if (thicknessOffset > 0 && i == points.size()-1){
            
            leftPoint += unitDirection * (thickness/3) + positionOffset;
            rightPoint += unitDirection * (thickness/3) + positionOffset;
            
            mesh.addVertex(leftPoint);
            mesh.addColor(color);
            mesh.addVertex(rightPoint);
            mesh.addColor(color);
        }
        
        
        //Add arrow
        if (i == points.size()-1 ){
          
            leftPoint = thisPoint+toTheLeft*thickness*1.5;
            rightPoint = thisPoint+toTheRight*thickness*1.5;

            mesh.addVertex(leftPoint);
            mesh.addColor(color);
            
            mesh.addVertex(rightPoint);
            mesh.addColor(color);
     
            
            mesh.addVertex(nextPoint + unitDirection * thickness*2.5);
            mesh.addColor(color);
        }
        
        
    }
    
    return mesh;
}
开发者ID:VictorSigma,项目名称:LSC-Graffiti-Wall,代码行数:79,代码来源:pen.cpp


示例14: sortHue

//--------------------------------------------------------------
// sort by hue function
bool sortHue( ofColor a, ofColor b){
	return( a.getHue() < b.getHue() );
}
开发者ID:flyingoctopus,项目名称:generative.design.oF,代码行数:5,代码来源:testApp.cpp


示例15: sortBrightness

//--------------------------------------------------------------
// sort by brightness function
bool sortBrightness( ofColor a, ofColor b){
	return( a.getBrightness() < b.getBrightness() );
}
开发者ID:flyingoctopus,项目名称:generative.design.oF,代码行数:5,代码来源:testApp.cpp


示例16: sortSaturation

//--------------------------------------------------------------
// sort by saturation function
bool sortSaturation( ofColor a, ofColor b){
	return( a.getSaturation() < b.getSaturation() );
}
开发者ID:flyingoctopus,项目名称:generative.design.oF,代码行数:5,代码来源:testApp.cpp


示例17: sortColorFunction

//--------------------------------------------------------------
//Sort function for stl::sort http://www.cplusplus.com/reference/algorithm/sort/
bool sortColorFunction (ofColor i,ofColor j) {
    return (i.getBrightness()<j.getBrightness());
}
开发者ID:jotaemepereira,项目名称:TDI-2014-5,代码行数:5,代码来源:testApp.cpp


示例18: resetDrawSettings

 void resetDrawSettings()
 {
     m_inSetup = false;
     fill(m_defaultFillColor.getHex());
     stroke(m_defaultStrokeColor.getHex());
     strokeWeight(m_defaultStrokeWeight);
     m_hasFill = m_defaultHasFill;
     m_hasStroke = m_defaultHasStroke;
     ofEnableBlendMode(OF_BLENDMODE_ALPHA);
     smooth(2);
     width = ofGetWidth();
     height = ofGetHeight();
     pmouseX = ofGetPreviousMouseX();
     pmouseY = ofGetPreviousMouseY();
     keyPressed = ofGetKeyPressed();
     mousePressed = ofGetMousePressed();
     mouseButton = NONE;
     if( ofGetMousePressed(0) )
         mouseButton = LEFT;
     else if(ofGetMousePressed(1))
         mouseButton = RIGHT;
     
     
     ofSetCircleResolution(100);
     ofSetCurveResolution(100);
 }
开发者ID:JosephLaurino,项目名称:ofx-experiments,代码行数:26,代码来源:processing.cpp


示例19: intializeBackground

void GamePanel::intializeBackground() {
  last = ofGetElapsedTimeMillis();
  col.setHsb(0,255,255);
  col2.setHsb(0,255,255);
  col3.setHsb(0,255,255);
  col4.setHsb(0,255,255);
  counter = 0;
}
开发者ID:DJDeezy,项目名称:Xcode_Projects,代码行数:8,代码来源:GamePanel.cpp


示例20: backgroundUpdate

void GamePanel::backgroundUpdate() {
  if(ofGetElapsedTimeMillis() - last > 50) {
    
    col.setHue(counter % 256);
    col2.setHue((counter + 60) % 256);
    col3.setHue((counter + 120) % 256);
    col4.setHue((counter + 180) % 256);
    counter += 1;
    last = ofGetElapsedTimeMillis();
  }
}
开发者ID:DJDeezy,项目名称:Xcode_Projects,代码行数:11,代码来源:GamePanel.cpp



注:本文中的ofColor类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ofEasyCam类代码示例发布时间:2022-05-31
下一篇:
C++ ofBuffer类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap