예제 #1
0
파일: ofxSvg.cpp 프로젝트: btparker/ofxSvg
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);
        }
    }
}
예제 #2
0
파일: Svg.cpp 프로젝트: 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;
		}
	}
}
예제 #3
0
void ShapeContentFill::pop(ofPath& path)
{
	ofPushStyle();
	path.setFilled(true);
	ofColor prev = path.getFillColor();
	float opacity = prev.a/255.f*opacity_;
	path.setFillColor(ofColor(color_, opacity*255));
	ofEnableBlendMode(blend_mode_);
	path.draw();
	path.setFillColor(prev);
	ofPopStyle();
}
예제 #4
0
void ShapeContentStroke::pop(ofPath& path)
{
	ofPushStyle();
	path.setFilled(false);
	ofColor prev = path.getStrokeColor();
	float opacity = prev.a/255.f*opacity_;
	path.setStrokeColor(ofColor(color_, opacity*255));
	path.setStrokeWidth(stroke_width_);
	ofEnableBlendMode(blend_mode_);
	path.draw();
	path.setStrokeColor(prev);
	ofPopStyle();
}
예제 #5
0
파일: main.cpp 프로젝트: chparsons/ofxGPC
 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);
     
 }
예제 #6
0
 void handlePathDrawStyle(ofPath& p)
 {
     p.setFilled(m_hasFill);
     p.setFillColor(m_fillColor);
     p.setStrokeColor(m_strokeColor);
     if( m_hasStroke )
     {
         p.setStrokeWidth(m_strokeWeight);
     }
     else
     {
         p.setStrokeWidth(0);
     }
 }
예제 #7
0
파일: main.cpp 프로젝트: Doodle3D/Doodle3D
    void keyPressed(int key) {
        switch (key) {
            case '/': case '\\': case '$': case '#': case '|': case '%': case '@': case '^': case '&': case '_': side.setShape(key); break;
            case '3': side.is3D=!side.is3D; break;
            case '<': twists-=.5; break;
            case '>': twists+=.5; break;
            case '\'': twists=0; break;
            case '?': showHelp(); break;
            case 'a': side.toggle(); break;
            case 'b': useSubpathColors=!useSubpathColors; break;
            case 'C': canvas.createCircle(); break;
            case 'c': canvas.clear(); files.unloadFile(); break;
            case 'd': debug=!debug; refreshDebugInfo(); break;
            case 'e': print(true); break;
            case 'f': ofToggleFullscreen(); break;
            case 'k': path.setFilled(!path.isFilled()); path.flagShapeChanged(); break;
            case 'h': objectHeight+=5; if (objectHeight>maxObjectHeight) objectHeight=maxObjectHeight; break;
            case 'H': objectHeight-=5; if (objectHeight<3) objectHeight=3; break;
            case 'G': ultimaker.sendCommand("G28 X0 Y0 Z0\nM84",2); break;
            case 'A': ultimaker.sendCommand("M84"); break;
            case 'T': ultimaker.sendCommand("M109 S230"); break;
            case 'l': files.loadNext(); break;
            case 'L': files.loadPrevious(); break;
            case 'o': files.load(); break;
            case 'p': case 'm': case OF_KEY_RETURN: print(); break;
            case 'q': stop(); break;
//            case 'r': ultimaker.setRelative(); break;
            case 'S': files.save(); break;
            case 's': files.saveAs(); break;
            case '`': showSubPathLines=!showSubPathLines;
            case 't': ultimaker.sendCommand("M105",1); break;
            case 'u': case 'z': canvas.undo(); break;
            case '~': files.deleteCurrentFile(); break;
            case ' ': files.listDir(); break;
            case 'x': files.saveSvg(resourceFolder+"template.svg",documentFolder+"output.svg"); break;
            case 27: if (ultimaker.isThreadRunning()) ultimaker.stopThread(); break;
            case 'n': cloneApp(); break; //run new instance of Doodle3D
            case 'i': cout << getNumInstances() << endl; break;
        }
    }
예제 #8
0
파일: main.cpp 프로젝트: fraco/genArt
 void setup(){
     path.setFilled(false);
     path.hasOutline();
     path.setArcResolution(120);
 }