本文整理汇总了C++中geom::Affine::setTranslation方法的典型用法代码示例。如果您正苦于以下问题:C++ Affine::setTranslation方法的具体用法?C++ Affine::setTranslation怎么用?C++ Affine::setTranslation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类geom::Affine
的用法示例。
在下文中一共展示了Affine::setTranslation方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
Inkscape::DrawingItem *SPClipPath::show(Inkscape::Drawing &drawing, unsigned int key) {
Inkscape::DrawingGroup *ai = new Inkscape::DrawingGroup(drawing);
display = sp_clippath_view_new_prepend(display, key, ai);
for ( SPObject *child = firstChild() ; child ; child = child->getNext() ) {
if (SP_IS_ITEM(child)) {
Inkscape::DrawingItem *ac = SP_ITEM(child)->invoke_show(drawing, key, SP_ITEM_REFERENCE_FLAGS);
if (ac) {
/* The order is not important in clippath */
ai->appendChild(ac);
}
}
}
if (clipPathUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX && display->bbox) {
Geom::Affine t = Geom::Scale(display->bbox->dimensions());
t.setTranslation(display->bbox->min());
ai->setChildTransform(t);
}
ai->setStyle(this->style);
return ai;
}
示例2: update
void SPClipPath::update(SPCtx* ctx, unsigned int flags) {
if (flags & SP_OBJECT_MODIFIED_FLAG) {
flags |= SP_OBJECT_PARENT_MODIFIED_FLAG;
}
flags &= SP_OBJECT_MODIFIED_CASCADE;
GSList *l = NULL;
for ( SPObject *child = this->firstChild(); child; child = child->getNext()) {
sp_object_ref(child);
l = g_slist_prepend(l, child);
}
l = g_slist_reverse(l);
while (l) {
SPObject *child = SP_OBJECT(l->data);
l = g_slist_remove(l, child);
if (flags || (child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) {
child->updateDisplay(ctx, flags);
}
sp_object_unref(child);
}
for (SPClipPathView *v = this->display; v != NULL; v = v->next) {
Inkscape::DrawingGroup *g = dynamic_cast<Inkscape::DrawingGroup *>(v->arenaitem);
if (this->clipPathUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX && v->bbox) {
Geom::Affine t = Geom::Scale(v->bbox->dimensions());
t.setTranslation(v->bbox->min());
g->setChildTransform(t);
} else {
g->setChildTransform(Geom::identity());
}
}
}
示例3: draw
//.........这里部分代码省略.........
Geom::CubicBezier fitted_new;
Geom::CubicBezier fitted_new_a;
Geom::Point very_old_version_raw[4];
bezier_fit_cubic(very_old_version_raw, curve_points.data(), curve_points.size(), 0.);
Geom::CubicBezier very_old_bezier(
very_old_version_raw[0],
very_old_version_raw[1],
very_old_version_raw[2],
very_old_version_raw[3]
);
Geom::Path very_old_version_path;
very_old_version_path.append(very_old_bezier);
cairo_set_source_rgba (cr, .7, .7, 0., 1);
cairo_stroke(cr);
cairo_path(cr, very_old_version_path);
cairo_set_source_rgba (cr, 0., 0., .9, 1);
cairo_stroke(cr);
cross_plot(cr, curve_points);
if(1) {
Geom::CubicBezier combination(very_old_bezier);
tm.ask_for_timeslice();
tm.start();
auto new_result_ig_a = experiment::fit_bezier(combination, curve_points);
als_time = tm.lap();
*notify << "Bezier fit a, old algorithm as initial guess, time = " << als_time << std::endl
<< "Worst residual: " << new_result_ig_a.first << " at t=" << new_result_ig_a.second << std::endl;
Geom::Path combination_path;
translation.setTranslation(Geom::Point(300,300));
combination_path.append(combination.transformed(translation));
cairo_set_source_rgba (cr, .0, .0, .9, 1);
cross_plot(cr, curve_points, translation.translation());
cairo_path(cr, combination_path);
draw_text(cr, combination_path.initialPoint(), "old fit as i.g.");
}
{
tm.ask_for_timeslice();
tm.start();
auto new_result = fit_bezier(fitted_new, curve_points);
als_time = tm.lap();
*notify << "Bezier fit, time = " << als_time << std::endl
<< "Worst residual: " << new_result.first << " at t=" << new_result.second << std::endl;
Geom::Path fitted_new_path;
translation.setTranslation(Geom::Point(300,0));
fitted_new_path.append(fitted_new.transformed(translation));
cairo_set_source_rgba (cr, .0, .9, .0, 1);
cross_plot(cr, curve_points, translation.translation());
cairo_path(cr, fitted_new_path);
draw_text(cr, fitted_new_path.initialPoint(), "new fit");
}
{
tm.ask_for_timeslice();
tm.start();
auto new_result_a = experiment::fit_bezier(fitted_new_a, curve_points);
als_time = tm.lap();
*notify << "Bezier fit a, time = " << als_time << std::endl