本文整理汇总了C++中ofPath类的典型用法代码示例。如果您正苦于以下问题:C++ ofPath类的具体用法?C++ ofPath怎么用?C++ ofPath使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ofPath类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mousePointerStraight
void pathFactory::mousePointerStraight(ofPath &p, float x_dim, float y_dim, float t_size){
vector<ofPoint> tpoints;
float tw = 0.3;
float sw = 0.074;
float cl = 1;
float al = 0.74;
float bl = 0.55;
tpoints.push_back(ofPoint(0,0));
tpoints.push_back(ofPoint(-tw,al));//a1
tpoints.push_back(ofPoint(-sw,bl)); // b1
tpoints.push_back(ofPoint(-sw,cl)); //c1
tpoints.push_back(ofPoint(sw,cl));//c2
tpoints.push_back(ofPoint(sw,bl)); // b2
tpoints.push_back(ofPoint(tw,al)); //a2
tpoints.push_back(ofPoint(0,0));
for(int i = 0; i < tpoints.size(); i++){
tpoints[i] *= ofVec2f(x_dim, y_dim);
tpoints[i] *= t_size;
p.lineTo(tpoints[i]);
}
p.close();
}
示例2: push
void ShapeContentRect::push(ofPath& path)
{
vector<ofPath::Command>& command = path.getCommands();
int command_count_prev = command.size();
path.rectRounded(pos_-size_/2.f, size_.x, size_.y, roundness_);
command_count_ = command.size() - command_count_prev;
}
示例3: rectangle
// Temporary fix until OF 0.8.0
static void rectangle(ofPath & path, const ofRectangle & r){
path.moveTo(r.getTopLeft());
path.lineTo(r.getTopRight());
path.lineTo(r.getBottomRight());
path.lineTo(r.getBottomLeft());
path.close();
}
示例4: ofxGetBoundingBox
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;
}
示例5: append
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();
}
示例6: pop
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();
}
示例7: handlePathDrawStyle
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);
}
}
示例8: ofSetCurrentRenderer
void ofSetCurrentRenderer(ofPtr<ofBaseRenderer> renderer_){
renderer = renderer_;
renderer->setupGraphicDefaults();
if(renderer->rendersPathPrimitives()){
shape.setMode(ofPath::PATHS);
}else{
shape.setMode(ofPath::POLYLINES);
}
shape.setUseShapeColor(false);
ofSetStyle(currentStyle);
}
示例9: ofxSimplifyPath
void ofxSimplifyPath(ofPath &path, int iterations, float amount) {
for (int iteration=0; iteration<iterations; iteration++) {
vector<ofSubPath> &subpaths = path.getSubPaths();
for (int i=0; i<subpaths.size(); i++) {
vector<ofSubPath::Command> &commands = subpaths[i].getCommands();
if (commands.size()<amount) continue;
for (int j=0; j<commands.size()-1; j++) {
if (commands[j].to.distance(commands[j+1].to)<3) {
commands[j].to = (commands[j].to+commands[j+1].to)/2;
commands.erase(commands.begin()+j+1);
}
}
}
}
path.flagShapeChanged();
}
示例10: roundedRect
void pathFactory::roundedRect(ofPath &p, float x_dim, float y_dim, float t_size){
ofRectangle r;
r.setFromCenter(0,0, x_dim * t_size, y_dim * t_size);
p.rectRounded(r, t_size/10);
}
示例11: ofSetCurrentRenderer
void ofSetCurrentRenderer(ofPtr<ofBaseRenderer> renderer_,bool setDefaults){
renderer = renderer_;
if(renderer->rendersPathPrimitives()){
shape.setMode(ofPath::COMMANDS);
}else{
shape.setMode(ofPath::POLYLINES);
}
shape.setUseShapeColor(false);
if(setDefaults){
renderer->setupGraphicDefaults();
ofSetStyle(currentStyle);
ofBackground(currentStyle.bgColor);
}
}
示例12: addPath
bool Clipper::addPath(const ofPath& paths,
ClipperLib::PolyType PolyTyp,
bool autoClose,
ClipperLib::cInt scale)
{
return addPolylines(paths.getOutline(), PolyTyp, autoClose, scale);
}
示例13: ofxSimplifyPath
void ofxSimplifyPath(ofPath &path, int iterations, float amount, float distance) { //wat doet amount?? should be distance???
for (int iteration=0; iteration<iterations; iteration++) {
vector<ofSubPath> &subpaths = path.getSubPaths();
for (int i=0; i<subpaths.size(); i++) {
vector<ofSubPath::Command> &commands = subpaths[i].getCommands();
if (commands.size()<amount) continue;
for (int j=1; j<commands.size()-2; j++) { //laat eerste en laatste punt met rust
if (commands[j].to.distance(commands[j+1].to)<distance) {
commands[j].to = (commands[j].to+commands[j+1].to)/2;
commands.erase(commands.begin()+j+1);
}
}
}
}
path.flagShapeChanged();
}
示例14: setupShape
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;
}
}
}
示例15: ofxGetPointsFromPath
vector<ofPoint*> ofxGetPointsFromPath(ofPath &path) {
vector<ofPoint*> points;
vector<ofSubPath> &subpaths = path.getSubPaths();
for (int i=0; i<subpaths.size(); i++) {
vector<ofSubPath::Command> &commands = subpaths[i].getCommands();
for (int j=0; j<commands.size(); j++) {
points.push_back(&commands[j].to);
}
}
return points;
}