mirror of
https://github.com/ocornut/imgui.git
synced 2026-08-21 06:41:09 +00:00
DrawList: added square cap rendering.
- Added square cap rendering to the DrawPolyline, which can be turned on by ImDrawFlags_SquareCap - Added draw flags to AddBezierCubic() and AddBezierQuadratic()
This commit is contained in:
@@ -934,6 +934,8 @@ void ImDrawList::_AddPolylineThin(const ImVec2* points, ImVec2* normals, float*
|
||||
len_sqr1 = sqr_lengths[0];
|
||||
|
||||
const ImVec2 dir(n1.y, -n1.x);
|
||||
if (flags & ImDrawFlags_SquareCap)
|
||||
p1 -= dir * (half_thickness - half_aa); // At this point half_thickness has half fringe width baked in.
|
||||
const ImVec2 pa = p1 - dir * half_aa;
|
||||
const ImVec2 pb = p1 + dir * half_aa;
|
||||
|
||||
@@ -1153,6 +1155,8 @@ void ImDrawList::_AddPolylineThin(const ImVec2* points, ImVec2* normals, float*
|
||||
|
||||
// End cap
|
||||
const ImVec2 dir(n1.y, -n1.x);
|
||||
if (flags & ImDrawFlags_SquareCap)
|
||||
p1 += dir * (half_thickness - half_aa); // At this point half_thickness has half fringe width baked in.
|
||||
const ImVec2 pa = p1 - dir * half_aa;
|
||||
const ImVec2 pb = p1 + dir * half_aa;
|
||||
|
||||
@@ -1247,6 +1251,8 @@ void ImDrawList::_AddPolylineThick(const ImVec2* points, ImVec2* normals, float*
|
||||
|
||||
// Start cap
|
||||
const ImVec2 dir(n1.y, -n1.x);
|
||||
if (flags & ImDrawFlags_SquareCap)
|
||||
p1 -= dir * (half_thickness - half_aa); // At this point half_thickness has half fringe width baked in.
|
||||
const ImVec2 pa = p1 - dir * half_aa;
|
||||
const ImVec2 pb = p1 + dir * half_aa;
|
||||
|
||||
@@ -1464,6 +1470,8 @@ void ImDrawList::_AddPolylineThick(const ImVec2* points, ImVec2* normals, float*
|
||||
|
||||
// End cap
|
||||
const ImVec2 dir(n1.y, -n1.x);
|
||||
if (flags & ImDrawFlags_SquareCap)
|
||||
p1 += dir * (half_thickness - half_aa); // At this point half_thickness has half fringe width baked in.
|
||||
const ImVec2 pa = p1 - dir * half_aa;
|
||||
const ImVec2 pb = p1 + dir * half_aa;
|
||||
|
||||
@@ -1857,7 +1865,7 @@ void ImDrawList::AddConvexPolyFilled(const ImVec2* points, const int points_coun
|
||||
_VtxWritePtr += points_count;
|
||||
_VtxCurrentIdx += points_count;
|
||||
|
||||
unsigned int prev_outer_idx = (unsigned int )-1; // We dont know oueter vert could yet, will need to patch once we're done.
|
||||
unsigned int prev_outer_idx = 0; // We dont know outer vert could yet, will need to patch once we're done.
|
||||
|
||||
const float miter_distance_limit = half_aa * IM_POLYLINE_MITER_LIMIT;
|
||||
const float miter_distance_limit_sqr = miter_distance_limit * miter_distance_limit;
|
||||
@@ -2395,7 +2403,7 @@ void ImDrawList::AddLine(const ImVec2& p1, const ImVec2& p2, ImU32 col, float th
|
||||
if (g_LEGACY_STROKES || stroke_pos == ImDrawFlags_StrokeLegacy)
|
||||
{
|
||||
const ImVec2 points[2] = { ImVec2(p1.x + 0.5f, p1.y + 0.5f), ImVec2(p2.x + 0.5f, p2.y + 0.5f) };
|
||||
AddPolyline(points, 2, col, thickness);
|
||||
AddPolyline(points, 2, col, thickness, ImDrawFlags_StrokeLegacy);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2429,7 +2437,7 @@ void ImDrawList::AddLineH(float min_x, float max_x, float y, ImU32 col, float th
|
||||
if (g_LEGACY_STROKES || stroke_pos == ImDrawFlags_StrokeLegacy)
|
||||
{
|
||||
const ImVec2 points[2] = { ImVec2(min_x + 0.5f, y + 0.5f), ImVec2(max_x + 0.5f, y + 0.5f) }; // Same as AddLine() above.
|
||||
AddPolyline(points, 2, col, thickness);
|
||||
AddPolyline(points, 2, col, thickness, ImDrawFlags_StrokeLegacy);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2460,7 +2468,7 @@ void ImDrawList::AddLineV(float x, float min_y, float max_y, ImU32 col, float th
|
||||
if (g_LEGACY_STROKES || stroke_pos == ImDrawFlags_StrokeLegacy)
|
||||
{
|
||||
const ImVec2 points[2] = { ImVec2(x + 0.5f, max_y + 0.5f), ImVec2(x + 0.5f, min_y + 0.5f) }; // Same as AddLine() above.
|
||||
AddPolyline(points, 2, col, thickness);
|
||||
AddPolyline(points, 2, col, thickness, ImDrawFlags_StrokeLegacy);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -3308,25 +3316,25 @@ void ImDrawList::AddEllipseFilled(const ImVec2& center, const ImVec2& radius, Im
|
||||
}
|
||||
|
||||
// Cubic Bezier takes 4 controls points
|
||||
void ImDrawList::AddBezierCubic(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col, float thickness, int num_segments)
|
||||
void ImDrawList::AddBezierCubic(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col, float thickness, int num_segments, ImDrawFlags flags)
|
||||
{
|
||||
if ((col & IM_COL32_A_MASK) == 0)
|
||||
return;
|
||||
|
||||
PathLineTo(p1);
|
||||
PathBezierCubicCurveTo(p2, p3, p4, num_segments);
|
||||
PathStroke(col, thickness);
|
||||
PathStroke(col, thickness, flags);
|
||||
}
|
||||
|
||||
// Quadratic Bezier takes 3 controls points
|
||||
void ImDrawList::AddBezierQuadratic(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, ImU32 col, float thickness, int num_segments)
|
||||
void ImDrawList::AddBezierQuadratic(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, ImU32 col, float thickness, int num_segments, ImDrawFlags flags)
|
||||
{
|
||||
if ((col & IM_COL32_A_MASK) == 0)
|
||||
return;
|
||||
|
||||
PathLineTo(p1);
|
||||
PathBezierQuadraticCurveTo(p2, p3, num_segments);
|
||||
PathStroke(col, thickness);
|
||||
PathStroke(col, thickness, flags);
|
||||
}
|
||||
|
||||
void ImDrawList::AddText(ImFont* font, float font_size, const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end, float wrap_width, const ImVec4* cpu_fine_clip_rect)
|
||||
|
||||
Reference in New Issue
Block a user