Пользователь
-
Автор темы
- #1
C++:
void CRender::CircleGlow(const Vector& center, Color outerColor, Color innerColor, float radius) {
int num_verts = radius * 6;
float step = 6.283185f / num_verts;
draw_list->PrimReserve(num_verts * 3, num_verts + 2);
auto uv = draw_list->_Data->TexUvWhitePixel;
auto o_c = outerColor.im();
auto i_c = innerColor.im();
unsigned int vtx_base = draw_list->_VtxCurrentIdx;
for (int i = 0; i < num_verts + 1; i++)
draw_list->PrimWriteVtx(ImVec2(std::cos(step * i) * radius + center.x, std::sin(step * i) * radius + center.x), uv, o_c);
draw_list->PrimWriteVtx(center.im(), uv, i_c);
for (int i = 0; i < num_verts; i++) {
draw_list->PrimWriteIdx(vtx_base + i);
draw_list->PrimWriteIdx(vtx_base + i + 1);
draw_list->PrimWriteIdx(vtx_base + num_verts + 1); // center vertex
}
}