本文整理汇总了C++中Path2D::reverse方法的典型用法代码示例。如果您正苦于以下问题:C++ Path2D::reverse方法的具体用法?C++ Path2D::reverse怎么用?C++ Path2D::reverse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Path2D
的用法示例。
在下文中一共展示了Path2D::reverse方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void Shape2D::add_rect(const Rectf &rect, const Angle &angle, bool reverse)
{
Path2D path;
Pointf point_1(rect.left, rect.top);
Pointf point_2(rect.right, rect.top);
Pointf point_3(rect.right, rect.bottom);
Pointf point_4(rect.left, rect.bottom);
if (angle.to_radians() != 0.0f)
{
Pointf center = rect.get_center();
point_1.rotate(center, angle);
point_2.rotate(center, angle);
point_3.rotate(center, angle);
point_4.rotate(center, angle);
}
path.add_line_to(point_1);
path.add_line_to(point_2);
path.add_line_to(point_3);
path.add_line_to(point_4);
if (reverse)
path.reverse();
add_path(path);
}
示例2: center
void Shape2D::add_rounded_rect(const Pointf &origin, const Sizef &size, float cap_rounding, const Angle &angle, bool reverse)
{
// sanitize rounding values
float tmp_rounding = cap_rounding;
float min_rounding = min(size.width/2.0f, size.height/2.0f);
if( tmp_rounding >= (min_rounding-0.01f) ) // 0.01: hysterezis for floating point errors
{
tmp_rounding = min_rounding-0.01f; // avoid duplicating curve endpoints
}
Path2D path;
Pointf center(origin.x + size.width / 2.0f, origin.y + size.height / 2.0f);
// top right curve
Shape2D_Impl::add_rotated_curve(path, center, angle,
Pointf(origin.x + size.width-tmp_rounding, origin.y),
Pointf(origin.x + size.width, origin.y),
Pointf(origin.x + size.width, origin.y + tmp_rounding));
// bottom right curve
Shape2D_Impl::add_rotated_curve(path, center, angle,
Pointf(origin.x + size.width, origin.y + size.height-tmp_rounding),
Pointf(origin.x + size.width, origin.y + size.height),
Pointf(origin.x + size.width-tmp_rounding, origin.y + size.height));
// bottom left curve
Shape2D_Impl::add_rotated_curve(path, center, angle,
Pointf(origin.x + tmp_rounding, origin.y + size.height),
Pointf(origin.x, origin.y + size.height),
Pointf(origin.x, origin.y + size.height-tmp_rounding));
// top left curve
Shape2D_Impl::add_rotated_curve(path, center, angle,
Pointf(origin.x, origin.y +tmp_rounding),
Pointf(origin.x, origin.y),
Pointf(origin.x + tmp_rounding, origin.y));
if (reverse)
path.reverse();
add_path(path);
}
示例3: max
void Shape2D::add_ellipse(const Pointf ¢er, const Pointf &radius, bool reverse)
{
float offset_x = 0;
float offset_y = 0;
int max_radius = max(radius.x, radius.y);
int rotationcount = max(5, (max_radius - 3));
float halfpi = 1.5707963267948966192313216916398f;
float turn = halfpi / rotationcount;
offset_x = center.x;
offset_y = -center.y;
Path2D path;
rotationcount *= 4;
std::vector<Pointf> points;
points.resize(rotationcount);
for(int i = 0; i < rotationcount ; i++)
{
float pos1 = radius.x * cos(i * turn);
float pos2 = radius.y * sin(i * turn);
points[i].x = (center.x + pos1);
points[i].y = (center.y + pos2);
}
path.add_line_to(points);
if (reverse)
path.reverse();
add_path(path);
}