当前位置: 首页>>代码示例>>C++>>正文


C++ Path2D::add_curve方法代码示例

本文整理汇总了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 &center, 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);

}
开发者ID:Cassie90,项目名称:ClanLib,代码行数:15,代码来源:shape2d_impl.cpp

示例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;
}
开发者ID:wbyang1985,项目名称:ClanLib,代码行数:83,代码来源:font_engine_freetype.cpp


注:本文中的Path2D::add_curve方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。