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


C++ RenderBatchTriangle::fill_triangle方法代码示例

本文整理汇总了C++中RenderBatchTriangle::fill_triangle方法的典型用法代码示例。如果您正苦于以下问题:C++ RenderBatchTriangle::fill_triangle方法的具体用法?C++ RenderBatchTriangle::fill_triangle怎么用?C++ RenderBatchTriangle::fill_triangle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RenderBatchTriangle的用法示例。


在下文中一共展示了RenderBatchTriangle::fill_triangle方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: fill_rect

void Canvas::fill_rect(float x1, float y1, float x2, float y2, const Gradient &gradient)
{
	Vec2f positions[6] =
	{
		Vec2f(x1, y1),
		Vec2f(x2, y1),
		Vec2f(x1, y2),
		Vec2f(x2, y1),
		Vec2f(x1, y2),
		Vec2f(x2, y2)
	};

	Vec4f colors[6] =
	{
		Vec4f(gradient.top_left),
		Vec4f(gradient.top_right),
		Vec4f(gradient.bottom_left),
		Vec4f(gradient.top_right),
		Vec4f(gradient.bottom_left),
		Vec4f(gradient.bottom_right)
	};

	RenderBatchTriangle *batcher = impl->batcher.get_triangle_batcher();
	batcher->fill_triangle(*this, positions, colors, 6);

}
开发者ID:punkkeks,项目名称:ClanLib,代码行数:26,代码来源:canvas.cpp

示例2: fill_triangles

void Canvas::fill_triangles(const std::vector<Vec2f> &triangles, const Colorf &color)
{
	if (!triangles.empty())
	{
		RenderBatchTriangle *batcher = impl->batcher.get_triangle_batcher();
		batcher->fill_triangle(*this, &triangles[0], color, triangles.size());
	}
}
开发者ID:punkkeks,项目名称:ClanLib,代码行数:8,代码来源:canvas.cpp

示例3: fill_triangle

void Canvas::fill_triangle(const Pointf &a, const Pointf &b, const Pointf &c, const Colorf &color)
{
	Vec2f positions[3] =
	{
		Vec2f(a.x, a.y),
		Vec2f(b.x, b.y),
		Vec2f(c.x, c.y)
	};

	RenderBatchTriangle *batcher = impl->batcher.get_triangle_batcher();
	batcher->fill_triangle(*this, positions, color, 3);
}
开发者ID:punkkeks,项目名称:ClanLib,代码行数:12,代码来源:canvas.cpp

示例4: fill_circle

void Canvas::fill_circle(const Pointf &center, const Pointf &centergradient, float radius, const Gradient &gradient)
{
	float offset_x = 0;
	float offset_y = 0;

	float rotationcount = max(5.0f, (radius - 3.0f));
	float halfpi = 1.5707963267948966192313216916398f;
	float turn = halfpi / rotationcount;

	if(center.distance(center + centergradient) < radius)
	{
		offset_x = centergradient.x;
		offset_y = -centergradient.y;
	}

	Vec4f colors[3] =
	{
		Vec4f(gradient.top_left.get_red(), gradient.top_left.get_green(), gradient.top_left.get_blue(), gradient.top_left.get_alpha()),
		Vec4f(gradient.bottom_right.get_red(), gradient.bottom_right.get_green(), gradient.bottom_right.get_blue(), gradient.bottom_right.get_alpha()),
		Vec4f(gradient.bottom_right.get_red(), gradient.bottom_right.get_green(), gradient.bottom_right.get_blue(), gradient.bottom_right.get_alpha())
	};

	Vec4f triangle_colors[4*3];
	for (int i=0; i<3; i++)
	{
		triangle_colors[0*3+i] = colors[i];
		triangle_colors[1*3+i] = colors[i];
		triangle_colors[2*3+i] = colors[i];
		triangle_colors[3*3+i] = colors[i];
	}

	RenderBatchTriangle *batcher = impl->batcher.get_triangle_batcher();

	for(float i = 0; i < rotationcount ; i++)
	{
		float pos1 = cos(i * turn);
		float pos2 = sin(i * turn);
		float pos3 = cos((i+1) * turn);
		float pos4 = sin((i+1) * turn);

		Vec2f positions[4*3] =
		{
			// 90 triangle:
			Vec2f(center.x + offset_x , center.y + offset_y),
			Vec2f(center.x + ((float)radius * pos1), center.y + ((float)radius * pos2)),
			Vec2f(center.x + ((float)radius * pos3), center.y + ((float)radius * pos4)),

			// 0 triangle:
			Vec2f(center.x + offset_x , center.y + offset_y),
			Vec2f(center.x + ((float)radius * pos2), center.y - ((float)radius * pos1)),
			Vec2f(center.x + ((float)radius * pos4), center.y - ((float)radius * pos3)),

			// 270 triangle:
			Vec2f(center.x + offset_x , center.y + offset_y),
			Vec2f(center.x - ((float)radius * pos1), center.y - ((float)radius * pos2)),
			Vec2f(center.x - ((float)radius * pos3), center.y - ((float)radius * pos4)),

			// 180 triangle:
			Vec2f(center.x + offset_x , center.y + offset_y),
			Vec2f(center.x - ((float)radius * pos2), center.y + ((float)radius * pos1)),
			Vec2f(center.x - ((float)radius * pos4), center.y + ((float)radius * pos3))
		};

		batcher->fill_triangle(*this, positions, triangle_colors, 4*3);

	}
}
开发者ID:punkkeks,项目名称:ClanLib,代码行数:67,代码来源:canvas.cpp


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