Esempio n. 1
0
// Temporary fix until OF 0.8.0
static void rectangle(ofPath & path, const ofRectangle & r){
	path.moveTo(r.getTopLeft());
	path.lineTo(r.getTopRight());
	path.lineTo(r.getBottomRight());
	path.lineTo(r.getBottomLeft());
	path.close();
}
Esempio n. 2
0
void pathFactory::mousePointerStraight(ofPath &p, float x_dim, float y_dim, float t_size){

    vector<ofPoint> tpoints;

    float tw = 0.3;
    float sw = 0.074;
    float cl = 1;
    float al = 0.74;
    float bl = 0.55;

    tpoints.push_back(ofPoint(0,0));
    tpoints.push_back(ofPoint(-tw,al));//a1
    tpoints.push_back(ofPoint(-sw,bl)); // b1
    tpoints.push_back(ofPoint(-sw,cl)); //c1
    tpoints.push_back(ofPoint(sw,cl));//c2
    tpoints.push_back(ofPoint(sw,bl)); // b2
    tpoints.push_back(ofPoint(tw,al)); //a2
    tpoints.push_back(ofPoint(0,0));


    for(int i = 0; i < tpoints.size(); i++){
        tpoints[i] *= ofVec2f(x_dim, y_dim);
        tpoints[i] *= t_size;
        p.lineTo(tpoints[i]);
    }

    p.close();

}
Esempio n. 3
0
void ofxSVG::setupShape(struct svgtiny_shape * shape, ofPath & path){
	float * p = shape->path;

	path.setFilled(false);

	if(shape->fill != svgtiny_TRANSPARENT){
		path.setFilled(true);
		path.setFillHexColor(shape->fill);
        ofColor color = path.getFillColor();
        color.a = shape->opacity*255;
        path.setColor(color);

		path.setPolyWindingMode(OF_POLY_WINDING_ODD);
    }

	if(shape->stroke != svgtiny_TRANSPARENT){
		path.setStrokeWidth(shape->stroke_width);
		path.setStrokeHexColor(shape->stroke);
	}

	for(int i = 0; i < (int)shape->path_length;){
		if(p[i] == svgtiny_PATH_MOVE){
			path.moveTo(p[i + 1], p[i + 2]);
			i += 3;
		}
		else if(p[i] == svgtiny_PATH_CLOSE){
			path.close();

			i += 1;
		}
		else if(p[i] == svgtiny_PATH_LINE){
			path.lineTo(p[i + 1], p[i + 2]);
			i += 3;
		}
		else if(p[i] == svgtiny_PATH_BEZIER){
			path.bezierTo(p[i + 1], p[i + 2],
						   p[i + 3], p[i + 4],
						   p[i + 5], p[i + 6]);
			i += 7;
		}
		else{
			ofLogError("ofxSVG") << "setupShape(): SVG parse error";
			i += 1;
		}
	}
    ofRectangle pathBoundingBox = getBoundingBoxOfPath(path);
    if(pathBoundingBox.getArea() != 0.0){
        if(boundingBox.getArea() == 0.0){
            boundingBox = pathBoundingBox;
        }
        else{
            boundingBox.growToInclude(pathBoundingBox);
        }
    }
}
Esempio n. 4
0
 void setup(){
     ofBackground(0);
     
     path.moveTo(0,0);
     path.lineTo(120, 150);
     path.lineTo(180, 100);
     path.lineTo(300, 300);
     path.lineTo(300, 400);
     path.close();
     path.setFilled(false);
     path.setStrokeWidth(1);
     
     path2.moveTo(100,50);
     path2.lineTo(200, 250);
     path2.lineTo(150, 500);
     path2.close();
     path2.setFilled(false);
     path2.setStrokeWidth(1);
     
     unioned = ofxGPC::getPolygonClip(ofxGPC::UNION, path, path2);
     diffed = ofxGPC::getPolygonClip(ofxGPC::DIFF, path, path2);
     
 }
Esempio n. 5
0
File: Svg.cpp Progetto: cviejo/mPD
void Svg::setupShape(struct svgtiny_shape * shape, ofPath & path){

	float* p = shape->path;

	path.setFilled(false);

	if(shape->fill != svgtiny_TRANSPARENT){
		path.setFilled(true);
		path.setFillHexColor(shape->fill);
		path.setPolyWindingMode(OF_POLY_WINDING_NONZERO);
    }

	if(shape->stroke != svgtiny_TRANSPARENT){
		path.setStrokeWidth(shape->stroke_width);
		path.setStrokeHexColor(shape->stroke);
	}

	for(int i = 0; i < (int)shape->path_length;){
		if(p[i] == svgtiny_PATH_MOVE){
			path.moveTo(p[i + 1], p[i + 2]);
			i += 3;
		}
		else if(p[i] == svgtiny_PATH_CLOSE){
			path.close();

			i += 1;
		}
		else if(p[i] == svgtiny_PATH_LINE){
			path.lineTo(p[i + 1], p[i + 2]);
			i += 3;
		}
		else if(p[i] == svgtiny_PATH_BEZIER){
			path.bezierTo(p[i + 1], p[i + 2],
						   p[i + 3], p[i + 4],
						   p[i + 5], p[i + 6]);
			i += 7;
		}
		else{
			ofLogError("Svg") << "setupShape(): SVG parse error";
			i += 1;
		}
	}
}