本文整理汇总了C++中SPCurve::curveto方法的典型用法代码示例。如果您正苦于以下问题:C++ SPCurve::curveto方法的具体用法?C++ SPCurve::curveto怎么用?C++ SPCurve::curveto使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPCurve
的用法示例。
在下文中一共展示了SPCurve::curveto方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sp_dropper_context_setup
static void sp_dropper_context_setup(SPEventContext *ec)
{
SPDropperContext *dc = SP_DROPPER_CONTEXT(ec);
if (((SPEventContextClass *) parent_class)->setup) {
((SPEventContextClass *) parent_class)->setup(ec);
}
/* TODO: have a look at sp_dyna_draw_context_setup where the same is done.. generalize? at least make it an arcto! */
SPCurve *c = new SPCurve();
const double C1 = 0.552;
c->moveto(-1,0);
c->curveto(-1, C1, -C1, 1, 0, 1 );
c->curveto(C1, 1, 1, C1, 1, 0 );
c->curveto(1, -C1, C1, -1, 0, -1 );
c->curveto(-C1, -1, -1, -C1, -1, 0 );
c->closepath();
dc->area = sp_canvas_bpath_new(sp_desktop_controls(ec->desktop), c);
c->unref();
sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(dc->area), 0x00000000,(SPWindRule)0);
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(dc->area), 0x0000007f, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
sp_canvas_item_hide(dc->area);
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (prefs->getBool("/tools/dropper/selcue")) {
ec->enableSelectionCue();
}
if (prefs->getBool("/tools/dropper/gradientdrag")) {
ec->enableGrDrag();
}
}
示例2: sp_spray_context_setup
static void sp_spray_context_setup(SPEventContext *ec)
{
SPSprayContext *tc = SP_SPRAY_CONTEXT(ec);
if (((SPEventContextClass *) parent_class)->setup) {
((SPEventContextClass *) parent_class)->setup(ec);
}
{
/* TODO: have a look at sp_dyna_draw_context_setup where the same is done.. generalize? at least make it an arcto! */
SPCurve *c = new SPCurve();
const double C1 = 0.552;
c->moveto(-1,0);
c->curveto(-1, C1, -C1, 1, 0, 1 );
c->curveto(C1, 1, 1, C1, 1, 0 );
c->curveto(1, -C1, C1, -1, 0, -1 );
c->curveto(-C1, -1, -1, -C1, -1, 0 );
c->closepath();
tc->dilate_area = sp_canvas_bpath_new(sp_desktop_controls(ec->desktop), c);
c->unref();
sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(tc->dilate_area), 0x00000000,(SPWindRule)0);
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(tc->dilate_area), 0xff9900ff, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
sp_canvas_item_hide(tc->dilate_area);
}
tc->is_drawing = false;
tc->_message_context = new Inkscape::MessageContext((ec->desktop)->messageStack());
sp_event_context_read(ec, "distrib");
sp_event_context_read(ec, "width");
sp_event_context_read(ec, "ratio");
sp_event_context_read(ec, "tilt");
sp_event_context_read(ec, "rotation_variation");
sp_event_context_read(ec, "scale_variation");
sp_event_context_read(ec, "mode");
sp_event_context_read(ec, "population");
sp_event_context_read(ec, "force");
sp_event_context_read(ec, "mean");
sp_event_context_read(ec, "standard_deviation");
sp_event_context_read(ec, "usepressure");
sp_event_context_read(ec, "Scale");
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (prefs->getBool("/tools/spray/selcue")) {
ec->enableSelectionCue();
}
if (prefs->getBool("/tools/spray/gradientdrag")) {
ec->enableGrDrag();
}
}
示例3: set_shape
void SPStar::set_shape() {
// perhaps we should convert all our shapes into LPEs without source path
// and with knotholders for parameters, then this situation will be handled automatically
// by disabling the entire stack (including the shape LPE)
if (hasBrokenPathEffect()) {
g_warning ("The star shape has unknown LPE on it! Convert to path to make it editable preserving the appearance; editing it as star will remove the bad LPE");
if (this->getRepr()->attribute("d")) {
// unconditionally read the curve from d, if any, to preserve appearance
Geom::PathVector pv = sp_svg_read_pathv(this->getRepr()->attribute("d"));
SPCurve *cold = new SPCurve(pv);
this->setCurveInsync( cold, TRUE);
this->setCurveBeforeLPE(cold);
cold->unref();
}
return;
}
SPCurve *c = new SPCurve ();
bool not_rounded = (fabs (this->rounded) < 1e-4);
// note that we pass randomized=true to sp_star_get_xy, because the curve must be randomized;
// other places that call that function (e.g. the knotholder) need the exact point
// draw 1st segment
c->moveto(sp_star_get_xy (this, SP_STAR_POINT_KNOT1, 0, true));
if (this->flatsided == false) {
if (not_rounded) {
c->lineto(sp_star_get_xy (this, SP_STAR_POINT_KNOT2, 0, true));
} else {
c->curveto(sp_star_get_curvepoint (this, SP_STAR_POINT_KNOT1, 0, NEXT),
sp_star_get_curvepoint (this, SP_STAR_POINT_KNOT2, 0, PREV),
sp_star_get_xy (this, SP_STAR_POINT_KNOT2, 0, true));
}
}
// draw all middle segments
for (gint i = 1; i < sides; i++) {
if (not_rounded) {
c->lineto(sp_star_get_xy (this, SP_STAR_POINT_KNOT1, i, true));
} else {
if (this->flatsided == false) {
c->curveto(sp_star_get_curvepoint (this, SP_STAR_POINT_KNOT2, i - 1, NEXT),
sp_star_get_curvepoint (this, SP_STAR_POINT_KNOT1, i, PREV),
sp_star_get_xy (this, SP_STAR_POINT_KNOT1, i, true));
} else {
c->curveto(sp_star_get_curvepoint (this, SP_STAR_POINT_KNOT1, i - 1, NEXT),
sp_star_get_curvepoint (this, SP_STAR_POINT_KNOT1, i, PREV),
sp_star_get_xy (this, SP_STAR_POINT_KNOT1, i, true));
}
}
if (this->flatsided == false) {
if (not_rounded) {
c->lineto(sp_star_get_xy (this, SP_STAR_POINT_KNOT2, i, true));
} else {
c->curveto(sp_star_get_curvepoint (this, SP_STAR_POINT_KNOT1, i, NEXT),
sp_star_get_curvepoint (this, SP_STAR_POINT_KNOT2, i, PREV),
sp_star_get_xy (this, SP_STAR_POINT_KNOT2, i, true));
}
}
}
// draw last segment
if (!not_rounded) {
if (this->flatsided == false) {
c->curveto(sp_star_get_curvepoint (this, SP_STAR_POINT_KNOT2, sides - 1, NEXT),
sp_star_get_curvepoint (this, SP_STAR_POINT_KNOT1, 0, PREV),
sp_star_get_xy (this, SP_STAR_POINT_KNOT1, 0, true));
} else {
c->curveto(sp_star_get_curvepoint (this, SP_STAR_POINT_KNOT1, sides - 1, NEXT),
sp_star_get_curvepoint (this, SP_STAR_POINT_KNOT1, 0, PREV),
sp_star_get_xy (this, SP_STAR_POINT_KNOT1, 0, true));
}
}
c->closepath();
/* Reset the shape'scurve to the "original_curve"
* This is very important for LPEs to work properly! (the bbox might be recalculated depending on the curve in shape)*/
this->setCurveInsync( c, TRUE);
this->setCurveBeforeLPE( c );
if (hasPathEffect() && pathEffectsEnabled()) {
SPCurve *c_lpe = c->copy();
bool success = this->performPathEffect(c_lpe);
if (success) {
this->setCurveInsync( c_lpe, TRUE);
}
c_lpe->unref();
}
c->unref();
}
示例4: spdc_concat_colors_and_flush
void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed)
{
// Concat RBG
SPCurve *c = dc->green_curve;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
// Green
dc->green_curve = new SPCurve();
while (dc->green_bpaths) {
sp_canvas_item_destroy(SP_CANVAS_ITEM(dc->green_bpaths->data));
dc->green_bpaths = g_slist_remove(dc->green_bpaths, dc->green_bpaths->data);
}
// Blue
c->append_continuous(dc->blue_curve, 0.0625);
dc->blue_curve->reset();
sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(dc->blue_bpath), NULL);
// Red
if (dc->red_curve_is_valid) {
c->append_continuous(dc->red_curve, 0.0625);
}
dc->red_curve->reset();
sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(dc->red_bpath), NULL);
if (c->is_empty()) {
c->unref();
return;
}
// Step A - test, whether we ended on green anchor
if ( forceclosed || ( dc->green_anchor && dc->green_anchor->active ) ) {
// We hit green anchor, closing Green-Blue-Red
dc->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Path is closed."));
c->closepath_current();
// Closed path, just flush
spdc_flush_white(dc, c);
c->unref();
return;
}
// Step B - both start and end anchored to same curve
if ( dc->sa && dc->ea
&& ( dc->sa->curve == dc->ea->curve )
&& ( ( dc->sa != dc->ea )
|| dc->sa->curve->is_closed() ) )
{
// We hit bot start and end of single curve, closing paths
dc->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Closing path."));
if (dc->sa->start && !(dc->sa->curve->is_closed()) ) {
c = reverse_then_unref(c);
}
if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 ||
prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){
dc->overwrite_curve->append_continuous(c, 0.0625);
c->unref();
dc->overwrite_curve->closepath_current();
if(dc->sa){
dc->white_curves = g_slist_remove(dc->white_curves, dc->sa->curve);
dc->white_curves = g_slist_append(dc->white_curves, dc->overwrite_curve);
}
}else{
dc->sa->curve->append_continuous(c, 0.0625);
c->unref();
dc->sa->curve->closepath_current();
}
spdc_flush_white(dc, NULL);
return;
}
// Step C - test start
if (dc->sa) {
SPCurve *s = dc->sa->curve;
dc->white_curves = g_slist_remove(dc->white_curves, s);
if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 ||
prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){
s = dc->overwrite_curve;
}
if (dc->sa->start) {
s = reverse_then_unref(s);
}
s->append_continuous(c, 0.0625);
c->unref();
c = s;
} else /* Step D - test end */ if (dc->ea) {
SPCurve *e = dc->ea->curve;
dc->white_curves = g_slist_remove(dc->white_curves, e);
if (!dc->ea->start) {
e = reverse_then_unref(e);
}
if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 ||
prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){
e = reverse_then_unref(e);
Geom::CubicBezier const * cubic = dynamic_cast<Geom::CubicBezier const*>(&*e->last_segment());
SPCurve *lastSeg = new SPCurve();
if(cubic){
lastSeg->moveto((*cubic)[0]);
lastSeg->curveto((*cubic)[1],(*cubic)[3],(*cubic)[3]);
if( e->get_segment_count() == 1){
e = lastSeg;
}else{
//.........这里部分代码省略.........
示例5: spdc_check_for_and_apply_waiting_LPE
static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, SPCurve *curve)
{
using namespace Inkscape::LivePathEffect;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (item && SP_IS_LPE_ITEM(item)) {
bool simplify = prefs->getInt(tool_name(dc) + "/simplify", 0);
if(simplify){
double tol = prefs->getDoubleLimited("/tools/freehand/pencil/tolerance", 10.0, 1.0, 100.0);
tol = tol/(100.0*(102.0-tol));
std::ostringstream ss;
ss << tol;
spdc_apply_simplify(ss.str(), dc, item);
sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false);
}
if (prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1) {
Effect::createAndApply(SPIRO, dc->desktop->doc(), item);
}
if (prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2) {
Effect::createAndApply(BSPLINE, dc->desktop->doc(), item);
}
SPShape *sp_shape = dynamic_cast<SPShape *>(item);
if (sp_shape) {
curve = sp_shape->getCurve();
}
//Store the clipboard path to apply in the future without the use of clipboard
static Geom::PathVector previous_shape_pathv;
shapeType shape = (shapeType)prefs->getInt(tool_name(dc) + "/shape", 0);
bool shape_applied = false;
SPCSSAttr *css_item = sp_css_attr_from_object(item, SP_STYLE_FLAG_ALWAYS);
const char *cstroke = sp_repr_css_property(css_item, "stroke", "none");
static SPItem *bend_item;
#define SHAPE_LENGTH 10
#define SHAPE_HEIGHT 10
if(shape == LAST_APPLIED){
shape = previous_shape_type;
if(shape == CLIPBOARD || shape == BEND_CLIPBOARD){
shape = LAST_APPLIED;
}
}
switch (shape) {
case NONE:
// don't apply any shape
break;
case TRIANGLE_IN:
{
// "triangle in"
std::vector<Geom::Point> points(1);
points[0] = Geom::Point(0., SHAPE_HEIGHT/2);
spdc_apply_powerstroke_shape(points, dc, item);
shape_applied = true;
break;
}
case TRIANGLE_OUT:
{
// "triangle out"
guint curve_length = curve->get_segment_count();
std::vector<Geom::Point> points(1);
points[0] = Geom::Point((double)curve_length, SHAPE_HEIGHT/2);
spdc_apply_powerstroke_shape(points, dc, item);
shape_applied = true;
break;
}
case ELLIPSE:
{
// "ellipse"
SPCurve *c = new SPCurve();
const double C1 = 0.552;
c->moveto(0, SHAPE_HEIGHT/2);
c->curveto(0, (1 - C1) * SHAPE_HEIGHT/2, (1 - C1) * SHAPE_LENGTH/2, 0, SHAPE_LENGTH/2, 0);
c->curveto((1 + C1) * SHAPE_LENGTH/2, 0, SHAPE_LENGTH, (1 - C1) * SHAPE_HEIGHT/2, SHAPE_LENGTH, SHAPE_HEIGHT/2);
c->curveto(SHAPE_LENGTH, (1 + C1) * SHAPE_HEIGHT/2, (1 + C1) * SHAPE_LENGTH/2, SHAPE_HEIGHT, SHAPE_LENGTH/2, SHAPE_HEIGHT);
c->curveto((1 - C1) * SHAPE_LENGTH/2, SHAPE_HEIGHT, 0, (1 + C1) * SHAPE_HEIGHT/2, 0, SHAPE_HEIGHT/2);
c->closepath();
spdc_paste_curve_as_freehand_shape(c->get_pathvector(), dc, item);
c->unref();
shape_applied = true;
break;
}
case CLIPBOARD:
{
// take shape from clipboard;
Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get();
if(cm->paste(SP_ACTIVE_DESKTOP,true) == true){
SPItem * pasted_clipboard = dc->selection->singleItem();
if(pasted_clipboard){
Inkscape::XML::Node *pasted_clipboard_root = pasted_clipboard->getRepr();
Inkscape::XML::Node *path = sp_repr_lookup_name(pasted_clipboard_root, "svg:path", -1); // unlimited search depth
if ( path != NULL ) {
//.........这里部分代码省略.........
示例6: SPCurve
void
LPESimplify::generateHelperPathAndSmooth(Geom::PathVector &result)
{
if(steps < 1) {
return;
}
Geom::PathVector tmp_path;
Geom::CubicBezier const *cubic = NULL;
for (Geom::PathVector::iterator path_it = result.begin(); path_it != result.end(); ++path_it) {
if (path_it->empty()) {
continue;
}
Geom::Path::iterator curve_it1 = path_it->begin(); // incoming curve
Geom::Path::iterator curve_it2 = ++(path_it->begin());// outgoing curve
Geom::Path::iterator curve_endit = path_it->end_default(); // this determines when the loop has to stop
SPCurve *nCurve = new SPCurve();
if (path_it->closed()) {
// if the path is closed, maybe we have to stop a bit earlier because the
// closing line segment has zerolength.
const Geom::Curve &closingline =
path_it->back_closed(); // the closing line segment is always of type
// Geom::LineSegment.
if (are_near(closingline.initialPoint(), closingline.finalPoint())) {
// closingline.isDegenerate() did not work, because it only checks for
// *exact* zero length, which goes wrong for relative coordinates and
// rounding errors...
// the closing line segment has zero-length. So stop before that one!
curve_endit = path_it->end_open();
}
}
if(helper_size > 0) {
drawNode(curve_it1->initialPoint());
}
nCurve->moveto(curve_it1->initialPoint());
Geom::Point start = Geom::Point(0,0);
while (curve_it1 != curve_endit) {
cubic = dynamic_cast<Geom::CubicBezier const *>(&*curve_it1);
Geom::Point point_at1 = curve_it1->initialPoint();
Geom::Point point_at2 = curve_it1->finalPoint();
Geom::Point point_at3 = curve_it1->finalPoint();
Geom::Point point_at4 = curve_it1->finalPoint();
if(start == Geom::Point(0,0)) {
start = point_at1;
}
if (cubic) {
point_at1 = (*cubic)[1];
point_at2 = (*cubic)[2];
}
if(path_it->closed() && curve_it2 == curve_endit) {
point_at4 = start;
}
if(curve_it2 != curve_endit) {
cubic = dynamic_cast<Geom::CubicBezier const *>(&*curve_it2);
if (cubic) {
point_at4 = (*cubic)[1];
}
}
Geom::Ray ray1(point_at2, point_at3);
Geom::Ray ray2(point_at3, point_at4);
double angle1 = Geom::deg_from_rad(ray1.angle());
double angle2 = Geom::deg_from_rad(ray2.angle());
if((smooth_angles >= std::abs(angle2 - angle1)) && !are_near(point_at4,point_at3) && !are_near(point_at2,point_at3)) {
double dist = Geom::distance(point_at2,point_at3);
Geom::Angle angleFixed = ray2.angle();
angleFixed -= Geom::Angle::from_degrees(180.0);
point_at2 = Geom::Point::polar(angleFixed, dist) + point_at3;
}
nCurve->curveto(point_at1, point_at2, curve_it1->finalPoint());
cubic = dynamic_cast<Geom::CubicBezier const *>(nCurve->last_segment());
if (cubic) {
point_at1 = (*cubic)[1];
point_at2 = (*cubic)[2];
if(helper_size > 0) {
if(!are_near((*cubic)[0],(*cubic)[1])) {
drawHandle((*cubic)[1]);
drawHandleLine((*cubic)[0],(*cubic)[1]);
}
if(!are_near((*cubic)[3],(*cubic)[2])) {
drawHandle((*cubic)[2]);
drawHandleLine((*cubic)[3],(*cubic)[2]);
}
}
}
if(helper_size > 0) {
drawNode(curve_it1->finalPoint());
}
++curve_it1;
++curve_it2;
}
if (path_it->closed()) {
nCurve->closepath_current();
}
tmp_path.push_back(nCurve->get_pathvector()[0]);
nCurve->reset();
delete nCurve;
}
//.........这里部分代码省略.........