Ejemplo n.º 1
0
ofRectangle ofxGetBoundingBox(ofPath &path) {
  ofRectangle rect;
  for (int i=0; i<path.getOutline().size(); i++) {
    ofRectangle b = path.getOutline().at(i).getBoundingBox();
    if (i==0) rect = b;
    else rect.growToInclude(b);
  }
  return rect;
}
Ejemplo n.º 2
0
//----------------------------------------------------------
void ofGLRenderer::draw(ofPath & shape){
	ofColor prevColor;
	if(shape.getUseShapeColor()){
		prevColor = ofGetStyle().color;
	}
	if(shape.isFilled()){
		ofMesh & mesh = shape.getTessellation();
		if(shape.getUseShapeColor()){
			setColor( shape.getFillColor() * ofGetStyle().color,shape.getFillColor().a/255. * ofGetStyle().color.a);
		}
		draw(mesh);
	}
	if(shape.hasOutline()){
		float lineWidth = ofGetStyle().lineWidth;
		if(shape.getUseShapeColor()){
			setColor( shape.getStrokeColor() * ofGetStyle().color, shape.getStrokeColor().a/255. * ofGetStyle().color.a);
		}
		setLineWidth( shape.getStrokeWidth() );
		vector<ofPolyline> & outlines = shape.getOutline();
		for(int i=0; i<(int)outlines.size(); i++)
			draw(outlines[i]);
		setLineWidth(lineWidth);
	}
	if(shape.getUseShapeColor()){
		setColor(prevColor);
	}
}
Ejemplo n.º 3
0
//----------------------------------------------------------
void ofGLRenderer::draw(const ofPath & shape) const{
	ofColor prevColor;
	if(shape.getUseShapeColor()){
		prevColor = ofGetStyle().color;
	}
	ofGLRenderer * mut_this = const_cast<ofGLRenderer*>(this);
	if(shape.isFilled()){
		const ofMesh & mesh = shape.getTessellation();
		if(shape.getUseShapeColor()){
			mut_this->setColor( shape.getFillColor(),shape.getFillColor().a);
		}
		draw(mesh,OF_MESH_FILL);
	}
	if(shape.hasOutline()){
		float lineWidth = ofGetStyle().lineWidth;
		if(shape.getUseShapeColor()){
			mut_this->setColor( shape.getStrokeColor(), shape.getStrokeColor().a);
		}
		mut_this->setLineWidth( shape.getStrokeWidth() );
		const vector<ofPolyline> & outlines = shape.getOutline();
		for(int i=0; i<(int)outlines.size(); i++)
			draw(outlines[i]);
		mut_this->setLineWidth(lineWidth);
	}
	if(shape.getUseShapeColor()){
		mut_this->setColor(prevColor);
	}
}
Ejemplo n.º 4
0
bool Clipper::addPath(const ofPath& paths,
                      ClipperLib::PolyType PolyTyp,
                      bool autoClose,
                      ClipperLib::cInt scale)
{
    return addPolylines(paths.getOutline(), PolyTyp, autoClose, scale);
}
Ejemplo n.º 5
0
void ofPath::append(const ofPath & path){
	if(mode==COMMANDS){
		for(auto & command: path.getCommands()){
			addCommand(command);
		}
	}else{
		for(auto & poly: path.getOutline()){
			polylines.push_back(poly);
		}
	}
	flagShapeChanged();
}
Ejemplo n.º 6
0
//--------------------------------------------------------------
ofPath ofApp::resamplePath(ofPath path, float spacing){
	ofPath resampledPath;
	vector <ofPolyline> polylines = path.getOutline();
	for(int j = 0; j < polylines.size(); j++){
		ofPolyline spacePoly = polylines[j].getResampledBySpacing(spacing);
		resampledPath.moveTo(spacePoly[0]);
		for(int k = 1; k < spacePoly.size(); k++){
			resampledPath.lineTo(spacePoly[k]);
		}
		resampledPath.lineTo(spacePoly[0]);
	}
	return resampledPath;
}
Ejemplo n.º 7
0
bool ofxEpilog::send(ofPath path)
{
    //
    // TODO([email protected]): test again and finish implementation
    //
    
    if (!tcp_client.isConnected())
    {
        return false;
    }
    
    ofBuffer buffer;
    
    vector<ofPolyline> line = path.getOutline();
    for (int i=0; i<line.size(); i++)
    {
        if(!send(line[i]))
            return false;
    }
    return true;
}
Ejemplo n.º 8
0
//--------------------------------------------------------------
ofMesh ofApp::createMeshFromPath(ofPath path, float thickness){
	ofMesh mesh;
	// get outline of original path (for sides)
	vector <ofPolyline> outline = path.getOutline();
	// add front to mesh
	mesh.append(path.getTessellation());
	// get number of vertices in original path
	int numVerts = mesh.getNumVertices();
	// define offset based on thickness
	ofVec3f offset = ofVec3f(0, 0, -thickness);
	// translate path
	path.translate(offset);
	// add back to mesh
	mesh.append(path.getTessellation());
	// add sides to mesh (via indices)
	for(int j = 0; j < outline.size(); j++){
		int outlineSize = outline[j].getVertices().size();
		vector <int> outlineIndices;
		for(int i = 1; i < outlineSize; i++){
			ofVec3f & v = outline[j].getVertices()[i];
			int originalIndex = -1;
			for(int k = 0; k < numVerts; k++){
				if(v.match(mesh.getVertices()[k])){
					originalIndex = k;
					break;
				}
			}
			outlineIndices.push_back(originalIndex);
		}
		for(int i = 0; i < outlineIndices.size(); i++){
			const int a = outlineIndices[i];
			const int b = outlineIndices[(i + 1) % outlineIndices.size()];
			const int c = outlineIndices[i] + numVerts;
			const int d = outlineIndices[(i + 1) % outlineIndices.size()] + numVerts;
			mesh.addTriangle(a, b, c);
			mesh.addTriangle(c, b, d);
		}
	}
	return mesh;
}
Ejemplo n.º 9
0
//--------------------------------------------------------------
//--------------------------------------------------------------
//--------------------------------------------------------------
void ofxClipper::ofPath_to_Polygons(ofPath& path,ClipperLib::Polygons& polygons) {
    return ofxPolylines_to_Polygons(path.getOutline(),polygons);
}
Ejemplo n.º 10
0
ClipperLib::Paths Clipper::toClipper(const ofPath& path, ClipperLib::cInt scale)
{
    return toClipper(path.getOutline(), scale);
}