本文整理汇总了C++中Path2D::add_curve方法的典型用法代码示例。如果您正苦于以下问题:C++ Path2D::add_curve方法的具体用法?C++ Path2D::add_curve怎么用?C++ Path2D::add_curve使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Path2D
的用法示例。
在下文中一共展示了Path2D::add_curve方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void Shape2D_Impl::add_rotated_curve(Path2D &path, const Pointf ¢er, const Angle &angle, Pointf point_1, Pointf point_2, Pointf point_3)
{
if (angle.to_radians() != 0.0f)
{
point_1.rotate(center, angle);
point_2.rotate(center, angle);
point_3.rotate(center, angle);
}
BezierCurve curve;
curve.add_control_point(point_1);
curve.add_control_point(point_2);
curve.add_control_point(point_3);
path.add_curve(curve);
}
示例2: load_glyph_outline
Shape2D FontEngine_Freetype::load_glyph_outline(int c, int &out_advance_x)
{
out_advance_x = 0;
FT_UInt glyph_index;
glyph_index = FT_Get_Char_Index( face, FT_ULong(c) );
FT_Error error = FT_Load_Glyph( face, glyph_index, FT_LOAD_DEFAULT );
if ( error )
{
throw Exception("freetype: error loading glyph");
}
FT_Glyph glyph;
error = FT_Get_Glyph( face->glyph, &glyph );
if ( error )
{
throw Exception("freetype: error getting glyph");
}
FT_OutlineGlyph ft_outline_glyph_rec = (FT_OutlineGlyph)glyph;
FT_Outline ft_outline = ft_outline_glyph_rec->outline;
Shape2D outline;
// cl_write_console_line(string_format("Num contours: %1", ft_outline.n_contours));
for( int cont = 0; cont < ft_outline.n_contours; cont++ )
{
// cl_write_console_line(string_format("Num points in contour %1: %2", cont, ft_outline.contours[0]+1));
Path2D contour;
// debug: dump contents of points array to terminal
// for( int i = 0; i <= ft_outline.contours[cont]; ++i )
// {
// FT_Vector pos = ft_outline.points[i];
// cl_write_console_line(string_format("dump points[%1]: (%2,%3) \t type: %4", i, pos.x, pos.y, ft_outline.tags[i]));
// }
std::vector<TaggedPoint> points = get_contour_points(cont, &ft_outline);
points.push_back(points.front()); // just to simplify, it's removed later.
for( unsigned int i = 0; i < points.size()-1; i++ )
{
TaggedPoint &tp = points[i];
if( tp.tag == FT_Curve_Tag_On )
{
contour.add_line_to(tp.pos);
}
else if( tp.tag == FT_Curve_Tag_Conic )
{
// TODO: i - 1 is safe here because we made sure the contour will start with a Tag_On.
BezierCurve curve;
curve.add_control_point( points[i-1].pos);
curve.add_control_point( tp.pos );
curve.add_control_point( points[i+1].pos );
contour.add_curve(curve);
}
else if( tp.tag == FT_Curve_Tag_Cubic && points[i-1].tag == FT_Curve_Tag_Cubic )
{
BezierCurve curve;
curve.add_control_point( points[i-2].pos);
curve.add_control_point( points[i-1].pos);
curve.add_control_point( tp.pos );
curve.add_control_point( points[i+1].pos );
contour.add_curve(curve);
}
}
outline.add_path(contour);
}
FT_Done_Glyph(glyph);
out_advance_x = get_advance_x( c );
return outline;
}