コード例 #1
0
ファイル: SmartPoly.cpp プロジェクト: KoolJBlack/twspp
SmartPoly::SmartPoly(vector<ofPoint> pts, float r, ofRectangle b, ofPoint cPos) : SmartShape() {
    // Position is derived from bounding ox center
    pos = b.position + ofPoint(b.width/2,b.height/2);
    capturedPos = cPos;
    
    rotation = r;
    boundingBox = b;
    
    // Setup the poly line
    polyLine = ofPolyline();
    path = ofPath();
    for (vector<ofPoint>::iterator it = pts.begin() ; it != pts.end(); ++it){
        ofPoint p = *it;
        // All points in the poly will be stored respective to pos.
        p = p - pos;
        polyLine.addVertex(p);
        path.lineTo(p);
    }
    polyLine.close();
    path.close();
    
    // Updat the control points
    updateControlPoints();
    
    extrusionHeight = 0;
}
コード例 #2
0
 void bezier( float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
 {
     ofPath p = ofPath();
     handlePathDrawStyle(p);
     p.moveTo(ofPoint(x1, y1));
     p.bezierTo(ofPoint(x2, y2), ofPoint(x3, y3), ofPoint(x4, y4));
     p.draw();
 }
コード例 #3
0
 // x1	float: x-coordinate of the first point
 // y1	float: y-coordinate of the first point
 // x2	float: x-coordinate of the second point
 // y2	float: y-coordinate of the second point
 void line( float x1, float y1, float x2, float y2)
 {
     ofPath p = ofPath();
     handlePathDrawStyle(p);
     p.moveTo(x1, y1);
     p.lineTo(x2, y2);
     p.draw();
 }
コード例 #4
0
 // float: x-coordinate of the ellipse
 // float: y-coordinate of the ellipse
 // float: width of the ellipse by default
 // float: height of the ellipse by default
 void ellipse(float x,float y, float width, float height)
 {
     ofPath p = ofPath();
     p.setFillColor(m_fillColor);
     p.setStrokeColor(m_strokeColor);
     p.setStrokeWidth(m_strokeWeight);
     p.ellipse(x,y,width,height);
     p.draw();
 }
コード例 #5
0
 // x      float: x-coordinate of the arc's ellipse
 // y      float: y-coordinate of the arc's ellipse
 // width  float: width of the arc's ellipse by default
 // height float: height of the arc's ellipse by default
 // start  float: angle to start the arc, specified in radians
 // stop   float: angle to stop the arc, specified in radians
 void arc(float x, float y, float width, float height, float start, float stop )
 {
     ofPath p = ofPath();
     handlePathDrawStyle(p);
     p.setCurveResolution(100);
     p.arc(x,y,width*.5,height*.5, degrees(start), degrees(stop));
     p.close();
     p.draw();
 }
コード例 #6
0
 // x1	float: x-coordinate of the first point
 // y1	float: y-coordinate of the first point
 // x2	float: x-coordinate of the second point
 // y2	float: y-coordinate of the second point
 void line( float x1, float y1, float x2, float y2)
 {
     ofPath p = ofPath();
     p.setFillColor(m_fillColor);
     p.setStrokeColor(m_strokeColor);
     p.setStrokeWidth(m_strokeWeight);
     p.moveTo(x1, y1);
     p.lineTo(x2, y2);
     p.draw();
 }
コード例 #7
0
 float bezier( float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
 {
     ofPath p = ofPath();
     p.setFillColor(m_fillColor);
     p.setStrokeColor(m_strokeColor);
     p.setStrokeWidth(m_strokeWeight);
     p.moveTo(ofPoint(x1, y1));
     p.bezierTo(ofPoint(x2, y2), ofPoint(x3, y3), ofPoint(x4, y4));
     p.draw();
 }
コード例 #8
0
 // x      float: x-coordinate of the arc's ellipse
 // y      float: y-coordinate of the arc's ellipse
 // width  float: width of the arc's ellipse by default
 // height float: height of the arc's ellipse by default
 // start  float: angle to start the arc, specified in radians
 // stop   float: angle to stop the arc, specified in radians
 void arc(float x, float y, float width, float height, float start, float stop )
 {
     ofPath p = ofPath();
     p.setFillColor(m_fillColor);
     p.setStrokeColor(m_strokeColor);
     p.setStrokeWidth(m_strokeWeight);
     p.arc(x,y,width*.5,height*.5, degrees(start), degrees(stop));
     p.close();
     p.draw();
 }
コード例 #9
0
 void triangle(float x1, float y1, float x2, float y2, float x3, float y3)
 {
     ofPath p = ofPath();
     handlePathDrawStyle(p);
     p.moveTo(x1, y1);
     p.lineTo(x2, y2);
     p.lineTo(x3, y3);
     p.close();
     p.draw();
 }
コード例 #10
0
void PathManager::generate_path(){
    for(int i = 0; i < num ; i++){
        path.push_back(ofPath());
        path.back().setMode(ofPath::POLYLINES);
        path.back().setStrokeColor(color);
        path.back().setStrokeWidth(width);
        path.back().setFilled(false);
        path.back().setCircleResolution(60);
    }
}
コード例 #11
0
 void rect( float x, float y, float width, float height )
 {
     ofPath p = ofPath();
     handlePathDrawStyle(p);
     p.moveTo(x, y);
     p.lineTo(x+width, y);
     p.lineTo(x+width, y+height);
     p.lineTo(x, y+height);
     p.close();
     p.draw();
 }
コード例 #12
0
 void triangle(float x1, float y1, float x2, float y2, float x3, float y3)
 {
     ofPath p = ofPath();
     p.setFillColor(m_fillColor);
     p.setStrokeColor(m_strokeColor);
     p.setStrokeWidth(m_strokeWeight);
     p.moveTo(x1, y1);
     p.lineTo(x2, y2);
     p.lineTo(x3, y3);
     p.close();
     p.draw();
 }
コード例 #13
0
 void rect( float x, float y, float width, float height )
 {
     ofPath p = ofPath();
     p.setFillColor(m_fillColor);
     p.setStrokeColor(m_strokeColor);
     p.setStrokeWidth(m_strokeWeight);
     p.moveTo(x, y);
     p.lineTo(x+width, y);
     p.lineTo(x+width, y+height);
     p.lineTo(x, y+height);
     p.close();
     p.draw();
 }
コード例 #14
0
ファイル: PMRibbonPainter.cpp プロジェクト: unohee/OFHarmony
void PMRibbonPainter::clear()
{
    path.clear();

    path = ofPath();

    path.setMode(ofPath::POLYLINES);
    path.setStrokeColor(color);
    path.setFilled(false);
    path.setStrokeWidth(1);

    isNewPath = true;
}
コード例 #15
0
ファイル: ofApp.cpp プロジェクト: Poofjunior/ParticleFilter
//--------------------------------------------------------------
void ofApp::drawParticle( float x, float y, float theta)
{
//TODO: rewrite for speed and efficiency!
    ofPath myTri = ofPath();
    myTri.setFillColor(ofColor::cornsilk);
    
    // Create a triangle centered at the origin.
    myTri.triangle(-2, -5, -2, 5, 12, 0);
    // Rotate first, since rotation is about an axis. Then, translate
    myTri.rotate(theta*(180./M_PI), ofVec3f(0,0,1));
    // Scale triangle appropriately.
    myTri.translate(ofPoint((x * pixelsPerMeter_), (y * pixelsPerMeter_), 0));
    myTri.draw();
}
コード例 #16
0
ファイル: Svg.cpp プロジェクト: cviejo/mPD
void Svg::setupDiagram(struct svgtiny_diagram * diagram){

	width = diagram->width;
	height = diagram->height;

	paths.clear();

	for(int i = 0; i < (int)diagram->shape_count; i++){
		if(diagram->shape[i].path){
			paths.push_back(ofPath());
			setupShape(&diagram->shape[i],paths.back());
		}else if(diagram->shape[i].text){
			ofLogWarning("Svg") << "setupDiagram(): text: not implemented yet";
		}
	}
}
コード例 #17
0
void ofxSpline::drawSpline(float strokeWidth, float lineStep, bool drawDirection, ofColor splineColor){
    ofSetLineWidth(3);
    ofPath line = ofPath();
    line.setStrokeColor(splineColor);
    line.setFilled(false);
    line.setStrokeWidth(strokeWidth);
    float lineSteps = 10.0;
    ofVec3f lineStart = this->GetPoint(0,1);
    line.moveTo(lineStart);
    for(int index = 1; index <= this->GetCurveNum(); index++){
        for(int i = 0; i <= lineSteps; i++){
            ofVec3f lineEnd = this->GetPoint(float(i)/lineSteps, index);
            line.lineTo(lineEnd);
            ofSetColor(0, 255, 0);
            if(drawDirection) ofLine(lineEnd, lineEnd + this->GetDirection(float(i)/lineSteps, index));
            lineStart = lineEnd;
        }
    }
    line.draw();
};
コード例 #18
0
void ofxSplineEditor::draw(){
    //drawMarkPoint();
    ofSetLineWidth(3);
    ofPath line = ofPath();
    line.setStrokeColor(ofColor(255,255,255));
    line.setFilled(false);
    line.setStrokeWidth(strokeWidth);
    float lineSteps = 10.0;
    ofVec3f lineStart = spline.GetPoint(0,1);
    line.moveTo(lineStart);
    for(int index = 1; index <= spline.GetCurveNum(); index++){
        for(int i = 0; i <= lineSteps; i++){
            ofVec3f lineEnd = spline.GetPoint(float(i)/lineSteps, index);
            line.lineTo(lineEnd);
            ofSetColor(0, 255, 0);
            if(drawDirectionButton) ofLine(lineEnd, lineEnd + spline.GetDirection(float(i)/lineSteps, index));
            lineStart = lineEnd;
        }
    }
    line.draw();
    ofSetColor(255, 0, 0);
     for(int i = 0; i < spline.GetPointNum(); i++){
         ofSetColor(spline.modeColors[(int)(spline.GetControlPointMode(i))]);
         if(i == editPointIndex){
             ofSetColor(255, 255, 0);
             ofDrawBox(spline.GetPoints().at(i), pointSize * 3);
         }
         ofDrawBox(spline.GetPoints().at(i), pointSize);
         ofSetColor(255, 200, 100);
         line.setStrokeWidth(1.0);
         if(!drawControlLine) continue;
         if(i % 3 == 1){
             ofLine(spline.GetPoints().at(i), spline.GetPoints().at(i - 1));
         }
         if(i % 3 == 2){
             ofLine(spline.GetPoints().at(i), spline.GetPoints().at(i + 1));
         }
    }
}
コード例 #19
0
//--------------------------------------------------------------
void SimpleOpenCVScene::update()
{
    BaseScene::update( ) ; 
    depthCameraManager->update( );
    depthCameraManager->calculateCVOperations() ;
    
    //Set the values to very high so it's overriden easily
    boundingBox = ofRectangle( 40000 , 40000 , 0 , 0 ) ;
    ofxCvContourFinder * c = &depthCameraManager->contourFinder ;
    if ( c->nBlobs > 0 )
    {
        paths.clear() ;
        
        //c++ 11 has some cool new looping tricks like the auto iterator
        for( auto blob = c->blobs.begin() ; blob != c->blobs.end() ; blob++ )
        {
            //Polyline are good for smoothing / resampling CV blobs
            ofPolyline line ;
            
            float nPoint = 0.0f ;
            float nPointInc = 1.0f / ( float ) (*blob).pts.size() ;
            
            for ( auto pt = (*blob).pts.begin() ; pt != (*blob).pts.end() ; pt++ )
            {
                if ( nPoint < completion )
                {
                    //Transform the CV points from pixel space to screenspace
                    line.addVertex( depthCameraManager->cvPointToScreen( (*pt) , ofGetWidth() , ofGetHeight() ) );
                    nPoint += nPointInc ;
                }
            }
           
            
            line = line.getSmoothed( outlineSmoothing ) ;
            
            //Paths are good for storing more complex shapes , colors, and fills
            int index = paths.size() ;
            paths.push_back( ofPath() ) ;
            if ( line.getVertices().size() > 0 )
            {
                paths[ index ].moveTo( line.getVertices()[0] ) ;
            
                for ( auto pt = line.getVertices().begin() ; pt != line.getVertices().end() ; pt++ )
                {
                    paths[ index ].lineTo( (*pt) ) ; 
                }
            }
            
            paths[ index ].close() ;
            
            //if ( completion == 1.0f )
            paths[ index ].setFilled( true ) ;
            float normalized = (float)index / ( (float)( c->nBlobs ) ) ;
            ofColor pathFill = ofColor::fromHsb( normalized * 255.0f , 255 , 255 ) ;
            paths[ index ].setFillColor( pathFill ) ;
            
            ofRectangle bb = line.getBoundingBox() ;
            if ( bb.x < boundingBox.x ) boundingBox.x = bb.x ;
            if ( bb.y > boundingBox.y ) boundingBox.y = bb.y ;
            if ( bb.width > boundingBox.width ) boundingBox.width = bb.width ;
            if ( bb.height > boundingBox.height ) boundingBox.height = bb.height ;
            
        }
    }
}