//-------------------------------------------------------------- void ofApp::setup(){ int totalVertices = 5; float yInc = (ofGetHeight()-100)/totalVertices; for (int i = 0; i<= totalVertices; i++) { points.push_back(ofDefaultVec3(ofGetWidth()*0.5f, ofGetHeight() - (yInc * i + 50),0)); vertices.push_back(draggableVertex(points.back().x, points.back().y)); ofFloatColor c; c.setHsb(ofRandom(1), 1, 1 ); colors.push_back(c); weights.push_back(100); } fatLine.setFeather(2); fatLine.add(points, colors, weights); fatLine.printDebug(); bDrawDebug = false; }
void ofx2DFormMapping::updateForms() { shapes.clear(); for (unsigned int i = 0; i < parent_projector->shapeCount(); i++) { ofPtr<ofx2DMappingObject> obj = parent_projector->getMappingObject(i); if(ofPtr<ofx2DMappingShape> shape = std::dynamic_pointer_cast<ofx2DMappingShape>(obj)) { mappableShape ms; ms.color = shape->color; ms.polyline.clear(); ms.dst.clear(); ms.src.clear(); ofPolyline line = shape->polyline; for(unsigned int j = 0; j < line.size(); j++) { ms.polyline.push_back(draggableVertex()); ms.polyline[j].x = line[j].x*mapping_rect_dst.width+mapping_rect_dst.x; ms.polyline[j].y = line[j].y*mapping_rect_dst.height+mapping_rect_dst.y; ms.polyline[j].bOver = false; ms.polyline[j].bBeingDragged = false; ms.polyline[j].radius = 6; } for(int j = 0; j < 4; j++) { ms.dst.push_back(ofPoint()); ms.dst[j].x = shape->dst[j].x*mapping_rect_dst.width+mapping_rect_dst.x; ms.dst[j].y = shape->dst[j].y*mapping_rect_dst.height+mapping_rect_dst.y; } if(ofPtr<ofx2DMappingContentShape> cshape = std::dynamic_pointer_cast<ofx2DMappingContentShape>(shape)) { for(int j = 0; j < 4; j++) { ms.src.push_back(draggableVertex()); ms.src[j].x = cshape->src[j].x*mapping_rect_src.width+mapping_rect_src.x; ms.src[j].y = cshape->src[j].y*mapping_rect_src.height+mapping_rect_src.y; ms.src[j].bOver = false; ms.src[j].bBeingDragged = false; ms.src[j].radius = 6; } } shapes.push_back(ms); } else { if(ofPtr<ofx2DMappingPoint> point = std::dynamic_pointer_cast<ofx2DMappingPoint>(obj)) { mappableShape ms; ms.color = point->color; ms.src.clear(); ms.dst.clear(); ms.polyline.clear(); draggableVertex v; v.x = point->pos.x*mapping_rect_dst.width+mapping_rect_dst.x; v.y = point->pos.y*mapping_rect_dst.height+mapping_rect_dst.y; v.bOver = false; v.bBeingDragged = false; v.radius = 13; ms.polyline.push_back(v); shapes.push_back(ms); } } } updateSourceBackground(); }