本文整理汇总了C++中geom::Rect::expandBy方法的典型用法代码示例。如果您正苦于以下问题:C++ Rect::expandBy方法的具体用法?C++ Rect::expandBy怎么用?C++ Rect::expandBy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类geom::Rect
的用法示例。
在下文中一共展示了Rect::expandBy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: transshift
/** Feeds path-creating calls to the cairo context translating them from the Path, with the given transform and shift */
static void
feed_path_to_cairo (cairo_t *ct, Geom::Path const &path, Geom::Affine trans, Geom::OptRect area, bool optimize_stroke, double stroke_width)
{
if (!area)
return;
if (path.empty())
return;
// Transform all coordinates to coords within "area"
Geom::Point shift = area->min();
Geom::Rect view = *area;
view.expandBy (stroke_width);
view = view * (Geom::Affine)Geom::Translate(-shift);
// Pass transformation to feed_curve, so that we don't need to create a whole new path.
Geom::Affine transshift(trans * Geom::Translate(-shift));
Geom::Point initial = path.initialPoint() * transshift;
cairo_move_to(ct, initial[0], initial[1] );
for(Geom::Path::const_iterator cit = path.begin(); cit != path.end_open(); ++cit) {
feed_curve_to_cairo(ct, *cit, transshift, view, optimize_stroke);
}
if (path.closed()) {
if (!optimize_stroke) {
cairo_close_path(ct);
} else {
cairo_line_to(ct, initial[0], initial[1]);
/* We cannot use cairo_close_path(ct) here because some parts of the path may have been
clipped and not drawn (maybe the before last segment was outside view area), which
would result in closing the "subpath" after the last interruption, not the entire path.
However, according to cairo documentation:
The behavior of cairo_close_path() is distinct from simply calling cairo_line_to() with the equivalent coordinate
in the case of stroking. When a closed sub-path is stroked, there are no caps on the ends of the sub-path. Instead,
there is a line join connecting the final and initial segments of the sub-path.
The correct fix will be possible when cairo introduces methods for moving without
ending/starting subpaths, which we will use for skipping invisible segments; then we
will be able to use cairo_close_path here. This issue also affects ps/eps/pdf export,
see bug 168129
*/
}
}
}
示例2: _pickItem
/**
* Get the item under the specified point.
* Searches the tree for the first item in the Z-order which is closer than
* @a delta to the given point. The pick should be visual - for example
* an object with a thick stroke should pick on the entire area of the stroke.
* @param p Search point
* @param delta Maximum allowed distance from the point
* @param sticky Whether the pick should ignore visibility and sensitivity.
* When false, only visible and sensitive objects are considered.
* When true, invisible and insensitive objects can also be picked.
*/
DrawingItem *
DrawingItem::pick(Geom::Point const &p, double delta, unsigned flags)
{
// Sometimes there's no BBOX in state, reason unknown (bug 992817)
// I made this not an assert to remove the warning
if (!(_state & STATE_BBOX) || !(_state & STATE_PICK)) {
g_warning("Invalid state when picking: STATE_BBOX = %d, STATE_PICK = %d",
_state & STATE_BBOX, _state & STATE_PICK);
return NULL;
}
// ignore invisible and insensitive items unless sticky
if (!(flags & PICK_STICKY) && !(_visible && _sensitive))
return NULL;
bool outline = _drawing.outline();
if (!_drawing.outline()) {
// pick inside clipping path; if NULL, it means the object is clipped away there
if (_clip) {
DrawingItem *cpick = _clip->pick(p, delta, flags | PICK_AS_CLIP);
if (!cpick) return NULL;
}
// same for mask
if (_mask) {
DrawingItem *mpick = _mask->pick(p, delta, flags);
if (!mpick) return NULL;
}
}
Geom::OptIntRect box = (outline || (flags & PICK_AS_CLIP)) ? _bbox : _drawbox;
if (!box) {
return NULL;
}
Geom::Rect expanded = *box;
expanded.expandBy(delta);
if (expanded.contains(p)) {
return _pickItem(p, delta, flags);
}
return NULL;
}
示例3: infinity
static double
sp_canvas_bpath_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item)
{
SPCanvasBPath *cbp = SP_CANVAS_BPATH (item);
if ( !cbp->curve ||
((cbp->stroke_rgba & 0xff) == 0 && (cbp->fill_rgba & 0xff) == 0 ) ||
cbp->curve->get_segment_count() < 1)
return Geom::infinity();
double width = 0.5;
Geom::Rect viewbox = item->canvas->getViewbox();
viewbox.expandBy (width);
double dist = Geom::infinity();
pathv_matrix_point_bbox_wind_distance(cbp->curve->get_pathvector(), cbp->affine, p, NULL, NULL, &dist, 0.5, &viewbox);
if (dist <= 1.0) {
*actual_item = item;
}
return dist;
}