Exemplo n.º 1
0
//----------------------------------------------------------
void ofPath::scale(float x, float y){
	if(mode==COMMANDS){
		for(int j=0;j<(int)commands.size();j++){
			commands[j].to.x*=x;
			commands[j].to.y*=y;
			if(commands[j].type==Command::bezierTo || commands[j].type==Command::quadBezierTo){
				commands[j].cp1.x*=x;
				commands[j].cp1.y*=y;
				commands[j].cp2.x*=x;
				commands[j].cp2.y*=y;
			}
			if(commands[j].type==Command::arc || commands[j].type==Command::arcNegative){
				commands[j].radiusX *= x;
				commands[j].radiusY *= y;
			}
		}
	}else{
		for(int i=0;i<(int)polylines.size();i++){
			for(int j=0;j<(int)polylines[i].size();j++){
				polylines[i][j].x*=x;
				polylines[i][j].y*=y;
			}
		}
	}
	flagShapeChanged();
}
Exemplo n.º 2
0
//----------------------------------------------------------
void ofPath::close(){
	if(mode==COMMANDS){
		addCommand(Command(Command::close));
	}else{
		lastPolyline().setClosed(true);
	}
	flagShapeChanged();
}
Exemplo n.º 3
0
//----------------------------------------------------------
void ofPath::lineTo(const ofPoint & p){
	if(mode==COMMANDS){
		addCommand(Command(Command::lineTo,p));
	}else{
		lastPolyline().lineTo(p);
	}
	flagShapeChanged();
}
Exemplo n.º 4
0
//----------------------------------------------------------
void ofPath::quadBezierTo(const ofPoint & cp1, const ofPoint & cp2, const ofPoint & p){
	if(mode==COMMANDS){
		addCommand(Command(Command::quadBezierTo,p,cp1,cp2));
	}else{
		lastPolyline().quadBezierTo(cp1,cp2,p,curveResolution);
	}
	flagShapeChanged();
}
Exemplo n.º 5
0
//----------------------------------------------------------
void ofPath::arcNegative(const ofPoint & centre, float radiusX, float radiusY, float angleBegin, float angleEnd){
	if(mode==COMMANDS){
		addCommand(Command(Command::arcNegative,centre,radiusX,radiusY,angleBegin,angleEnd));
	}else{
		lastPolyline().arcNegative(centre,radiusX,radiusY,angleBegin,angleEnd,circleResolution);
	}
	flagShapeChanged();
}
Exemplo n.º 6
0
//----------------------------------------------------------
void ofPath::curveTo(const ofPoint & p){
	if(mode==COMMANDS){
		addCommand(Command(Command::curveTo,p));
	}else{
		lastPolyline().curveTo(p,curveResolution);
	}
	flagShapeChanged();
}
Exemplo n.º 7
0
//----------------------------------------------------------
vector<ofPath::Command> & ofPath::getCommands(){
	if(mode==POLYLINES){
		ofLogWarning("ofPath") << "getCommands(): trying to get path commands from shape with polylines only";
	}else{
		flagShapeChanged();
	}
	return commands;
}
Exemplo n.º 8
0
//----------------------------------------------------------
void ofPath::bezierTo(const glm::vec3 & cp1, const glm::vec3 & cp2, const glm::vec3 & p){
	if(mode==COMMANDS){
		addCommand(Command(Command::bezierTo,p,cp1,cp2));
	}else{
		lastPolyline().bezierTo(cp1,cp2,p,curveResolution);
	}
	flagShapeChanged();
}
Exemplo n.º 9
0
//----------------------------------------------------------
void ofPath::moveTo(const ofPoint & p){
	if(mode==COMMANDS){
		addCommand(Command(Command::moveTo,p));
	}else{
		if(lastPolyline().size()>0) newSubPath();
		lastPolyline().addVertex(p);
	}
	flagShapeChanged();
}
Exemplo n.º 10
0
//----------------------------------------------------------
void ofPath::clear(){
	commands.clear();
	// for performance, instead of clearing the whole vector
	// let one polyline and clear it: avoids instantiation
	polylines.resize(1);
	polylines[0].clear();
	cachedTessellation.clear();
	flagShapeChanged();
}
Exemplo n.º 11
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();
}
Exemplo n.º 12
0
//----------------------------------------------------------
void ofPath::translate(const ofPoint & p){
	if(mode==COMMANDS){
		for(int j=0;j<(int)commands.size();j++){
			commands[j].to += p;
			if(commands[j].type==Command::bezierTo || commands[j].type==Command::quadBezierTo){
				commands[j].cp1 += p;
				commands[j].cp2 += p;
			}
		}
	}else{
		for(int i=0;i<(int)polylines.size();i++){
			for(int j=0;j<(int)polylines[i].size();j++){
				polylines[i][j] += p;
			}
		}
	}
	flagShapeChanged();
}
Exemplo n.º 13
0
//----------------------------------------------------------
void ofPath::rotate(float az, const ofVec3f& axis ){
	if(mode==COMMANDS){
		for(int j=0;j<(int)commands.size();j++){
			commands[j].to.rotate(az,axis);
			if(commands[j].type==Command::bezierTo || commands[j].type==Command::quadBezierTo){
				commands[j].cp1.rotate(az,axis);
				commands[j].cp2.rotate(az,axis);
			}
			if(commands[j].type==Command::arc || commands[j].type==Command::arcNegative){
				commands[j].angleBegin += az;
				commands[j].angleEnd += az;
			}
		}
	}else{
		for(int i=0;i<(int)polylines.size();i++){
			for(int j=0;j<(int)polylines[i].size();j++){
				polylines[i][j].rotate(az,axis);
			}
		}
	}
	flagShapeChanged();
}
Exemplo n.º 14
0
//----------------------------------------------------------
void ofPath::rotate(float az, const glm::vec3& axis ){
	auto radians = ofDegToRad(az);
	if(mode==COMMANDS){
		for(int j=0;j<(int)commands.size();j++){
			commands[j].to = glm::rotate(commands[j].to, radians, axis);
			if(commands[j].type==Command::bezierTo || commands[j].type==Command::quadBezierTo){
				commands[j].cp1 = glm::rotate(commands[j].cp1, radians, axis);
				commands[j].cp2 = glm::rotate(commands[j].cp2, radians, axis);
			}
			if(commands[j].type==Command::arc || commands[j].type==Command::arcNegative){
				commands[j].angleBegin += az;
				commands[j].angleEnd += az;
			}
		}
	}else{
		for(int i=0;i<(int)polylines.size();i++){
			for(int j=0;j<(int)polylines[i].size();j++){
				polylines[i][j] = glm::rotate(toGlm(polylines[i][j]), radians, axis);
			}
		}
	}
	flagShapeChanged();
}