本文整理汇总了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);
}
示例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());
}
}
示例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);
}
示例4: fill_circle
void Canvas::fill_circle(const Pointf ¢er, const Pointf ¢ergradient, 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);
}
}