当前位置: 首页>>代码示例>>C++>>正文


C++ ofColor::setBrightness方法代码示例

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


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

示例1: 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

示例2: 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

示例3: extrudeMesh

//--------------------------------------------------------------
ofMesh pen::extrudeMesh(ofMesh mesh, ofColor color){ 
    
    ofMesh side; 
    float depth = 50; 
    color.setBrightness(250);
    
    vector<ofPoint> points = mesh.getVertices();
    int k;
    
    if (points.size() > 4){
        ofPoint p1 = points[0];
        ofPoint p2 = points[1];
        
        side.addVertex(p1);
        side.addColor(color);
        side.addVertex(p2);
        side.addColor(color);
        side.addVertex(ofPoint(p1.x, p1.y, p1.z-depth));
        side.addColor(color);
        side.addVertex(ofPoint(p1.x, p1.y, p1.z-depth));
        side.addColor(color);
        side.addVertex(ofPoint(p2.x, p2.y, p2.z-depth));
        side.addColor(color);
        side.addVertex(p2);
        side.addColor(color);
        
        for(k=0; k<points.size()-2; k++)
        {
            
            ofPoint p1 = points[k+0];
            ofPoint p2 = points[k+2];
            
            side.addVertex(p1);
            side.addColor(color);
            side.addVertex(p2);
            side.addColor(color);
            side.addVertex(ofPoint(p1.x+5, p1.y, p1.z-depth));
            side.addColor(color);
            if (ofRandom(0,25) < 1)
                color.setBrightness(ofMap(k, 0, points.size(), 100, 50));
            else 
                color.setBrightness(ofMap(k, 0, points.size(), 150, 100));
            side.addVertex(ofPoint(p1.x+5, p1.y, p1.z-depth));
            side.addColor(color);
            side.addVertex(ofPoint(p2.x+5, p2.y, p2.z-depth));
            side.addColor(color);
            side.addVertex(p2);
            side.addColor(color);
        }
        
        p1 = points[points.size()-2];
        p2 = points[points.size()-1];
        side.addVertex(p1);
        side.addColor(color);
        side.addVertex(p2);
        side.addColor(color);
        side.addVertex(ofPoint(p1.x, p1.y, p1.z-depth));
        side.addColor(color);
        side.addVertex(ofPoint(p1.x, p1.y, p1.z-depth));
        side.addColor(color);
        side.addVertex(ofPoint(p2.x, p2.y, p2.z-depth));
        side.addColor(color);
        side.addVertex(p2);
        side.addColor(color);
    }
    return side;
    
}
开发者ID:VictorSigma,项目名称:LSC-Graffiti-Wall,代码行数:69,代码来源:pen.cpp


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