本文整理汇总了C++中ofPolyline::getVertices方法的典型用法代码示例。如果您正苦于以下问题:C++ ofPolyline::getVertices方法的具体用法?C++ ofPolyline::getVertices怎么用?C++ ofPolyline::getVertices使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofPolyline
的用法示例。
在下文中一共展示了ofPolyline::getVertices方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw
//-----------------------------------------------------------------------------------
void ofxCairoTexture::draw(ofPolyline & poly){
cairo_new_path(cr);
for(int i=0;i<(int)poly.size();i++){
cairo_line_to(cr,poly.getVertices()[i].x,poly.getVertices()[i].y);
}
if(poly.isClosed())
cairo_close_path(cr);
cairo_stroke( cr );
}
示例2: draw
void ofCairoRenderer::draw(const ofPolyline & poly) const{
cairo_new_path(cr);
for(int i=0;i<(int)poly.size();i++){
cairo_line_to(cr,poly.getVertices()[i].x,poly.getVertices()[i].y);
}
if(poly.isClosed())
cairo_close_path(cr);
cairo_stroke( cr );
}
示例3: draw
void ofCairoRenderer::draw(ofPolyline & poly){
ofPushStyle();
cairo_new_path(cr);
for(int i=0;i<(int)poly.size();i++){
cairo_line_to(cr,poly.getVertices()[i].x,poly.getVertices()[i].y);
}
if(poly.isClosed())
cairo_close_path(cr);
ofPopStyle();
}
示例4: interpolatePolyLine
void testApp::interpolatePolyLine(ofPolyline& a, ofPolyline& b, ofPolyline& out, float delta){
if(a.getVertices().size() != b.getVertices().size()){
ofLogError("Polylines did not match in size");
return;
}
out.clear();
for(int i = 0; i < a.getVertices().size(); i++){
out.addVertex( a.getVertices()[i].getInterpolated(b.getVertices()[i], delta) );
}
}
示例5: draw
void ropeMesh::draw(ofPolyline stroke){
if (stroke.hasChanged()) {
mesh.clear();
mesh.setMode(OF_PRIMITIVE_TRIANGLE_STRIP);
vector < ofPoint > pts = stroke.getVertices();
for (int i = 0; i < pts.size(); i++){
int i_m_1 = MAX(i-1,0);
int i_p_1 = MIN(i+1, pts.size()-1);
ofPoint pta = pts[i_m_1];
ofPoint ptb = pts[i];
ofPoint ptc = pts[i_p_1];
ofPoint diff = ptc - pta;
float angle = atan2(diff.y, diff.x);
angle += PI/2;
float width = 3; //diff.length();
ofPoint offsetA;
offsetA.x = ptb.x + width * cos(angle);
offsetA.y = ptb.y + width * sin(angle);
ofPoint offsetB;
offsetB.x = ptb.x - width * cos(angle);
offsetB.y = ptb.y - width * sin(angle);
ofSetColor(123,94,65);
ofLine(offsetA, offsetB);
mesh.addVertex(offsetA);
mesh.addVertex(offsetB);
}
ofSetColor(197,155,108);
ofFill();
mesh.draw();
ofSetRectMode(OF_RECTMODE_CENTER);
if (stroke.size()>0) {
top[num].draw(stroke.getVertices()[stroke.size()-1], width, height);
}
}
}
示例6:
bool operator==(const ofPolyline& lhs, const ofPolyline& rhs)
{
vector<ofPoint> vertices1 = lhs.getVertices();
vector<ofPoint> vertices2 = rhs.getVertices();
if(vertices1.size() != vertices2.size()) return false;
else {
for(int i = 0; i < vertices1.size(); i++) {
if(vertices1[i] != vertices2[i]) return false;
}
}
return true;
}
示例7: draw
//----------------------------------------------------------
void ofGLRenderer::draw(ofPolyline & poly){
if(!poly.getVertices().empty()) {
// use smoothness, if requested:
if (bSmoothHinted) startSmoothing();
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, sizeof(ofVec3f), &poly.getVertices()[0].x);
glDrawArrays(poly.isClosed()?GL_LINE_LOOP:GL_LINE_STRIP, 0, poly.size());
// use smoothness, if requested:
if (bSmoothHinted) endSmoothing();
}
}
示例8: makeStroke
void Plant::makeStroke(int i,
float min,
float max,
ofPolyline ¢erLine,
ofPolyline *line1,
ofPolyline *line2
){
ofVec2f v = centerLine.getTangentAtIndex(i);
float length = ofMap(i, 0, centerLine.size()-1, max, min) ;
float angle = 90;
float hackValue = 0.8;
if(i==0 || i == centerLine.size()-1){
ofVec2f p = centerLine.getVertices()[i] + v.rotate(angle)*length*hackValue;
ofVec2f v2 = centerLine.getTangentAtIndex(i);
ofVec2f p2 = centerLine.getVertices()[i] + v2.rotate(-angle)*length*hackValue;
line1->lineTo(p);
line2->lineTo(p2);
}
if(i>0 && i < centerLine.size()-1){
makeCorner(line1, centerLine, i, angle, length);
makeCorner(line2, centerLine, i, -angle, length);
}
if(i == centerLine.size()-1){
ofVec2f v = centerLine.getTangentAtIndex(i);
float length = ofMap(i, 0, centerLine.size()-1, min, min) ;
ofVec2f _p2 = centerLine.getVertices()[i] + v.rotate(90)*length*hackValue;
ofVec2f _p1 = centerLine.getVertices()[i] + v.rotate(180)*length*hackValue;
ofVec2f _p3 = _p1 + (_p2 - _p1)/2;
ofVec2f _delta = _p2 - _p1;
ofVec2f pCenter = _p3 - _delta.getPerpendicular()*min;
ofVec2f pLeft = pCenter - _delta/2;
ofVec2f pRight = pCenter + _delta/2;
line2->bezierTo(_p1, pLeft, pCenter);
line1->bezierTo(_p2, pRight, pCenter);
// ofSetColor(ofColor::yellow);
// ofDrawCircle(p1, 5);
// ofSetColor(ofColor::red);
// ofDrawCircle(p2, 5);
// ofSetColor(ofColor::blueViolet);
// ofDrawCircle(p3, 5);
// ofSetColor(ofColor::darkMagenta);
// ofDrawCircle(pCenter, 5);
// ofSetColor(ofColor::lightPink);
// ofDrawCircle(pLeft, 5);
// ofSetColor(ofColor::lightSkyBlue);
// ofDrawCircle(pRight, 5);
}
}
示例9: setFromPolyline
//--------------------------------------------------------------
void ofxFatLine::setFromPolyline(ofPolyline & poly){
// ofxFatLine();
setGlobalColor(ofGetStyle().color);
setGlobalWidth(ofGetStyle().lineWidth);
if (!poly.getVertices().empty()){
addVertices(poly.getVertices());
for (int i = 0; i <getVertices().size(); i++) {
addColor(globalColor);
addWeight(globalWidth);
}
update();
//*/
}
}
示例10: addLaserPolyline
void LaserManager::addLaserPolyline(const ofPolyline& line, ColourSystem* coloursystem, float intens){
if((line.getVertices().size()==0)||(line.getPerimeter()<0.1)) return;
shapes.push_back(new LaserPolyline(line, coloursystem, intens));
}
示例11: setup
void Path3D::set(ofPolyline &polyline){
setup(); // incase path hasn't been set up yet
ptIndex = 0;
reverse = true;
direction = 1;
// ignore the first and last points for the centroid
for (int i=1; i<polyline.getVertices().size()-1; i++){
centroid += polyline.getVertices()[i];
}
centroid /= polyline.getVertices().size()-2;
path = polyline;
buildPerpFrames(path);
}
示例12: draw
//--------------------------------------------------------------
void testApp::draw(){
ofBackgroundGradient(ofColor(10,10,10), ofColor(0,0,0) );
/*particleA.draw();
particleB.draw();
particleC.draw();
*/
if (temp.getVertices().size() > 500){
temp.getVertices().erase(temp.getVertices().begin());
}
ofEnableAlphaBlending();
//temp.draw();
glBegin(GL_LINE_STRIP);
for (int i = 0; i < temp.getVertices().size(); i++){
float pct = ofMap(i, 0, temp.getVertices().size()-1, 0,1);
ofSetColor(255,255,255,255*pct);
glVertex2f(temp.getVertices()[i].x, temp.getVertices()[i].y);
}
glEnd();
ofEndShape();
}
示例13: ofPolyline_to_Polygon
//--------------------------------------------------------------
ClipperLib::Polygon ofxClipper::ofPolyline_to_Polygon(ofPolyline& polyline) {
vector<ofPoint> verts = polyline.getVertices();
vector<ofPoint>::iterator iter;
ClipperLib::Polygon polygon;
for(iter = verts.begin(); iter != verts.end(); iter++) {
ClipperLib::IntPoint ip((*iter).x * clipperGlobalScale,
(*iter).y * clipperGlobalScale);
polygon.push_back(ip);
}
return polygon;
}
示例14:
int XBScene1::findIntersectionHorizontal(ofPolyline &line, int posX)
{
//loop through polyline points, left to right, when posX changes from higher to lower from the x component of the polyline point
vector<ofPoint> vertices = line.getVertices();
for (int i = 0; i < vertices.size(); i++) {
if (posX > vertices[i].x)
continue;
else
return i;
}
}
示例15: getCentroid2D
ofPoint getCentroid2D(ofPolyline temp){
vector < ofPoint > pts = temp.getVertices();
ofPoint midPt;
midPt.set(0,0,0);
for (int i = 0; i <pts.size(); i++){
midPt+= pts[i];
}
midPt /= MAX(1, pts.size());
return midPt;
}