Skip to content

Commit

Permalink
Merge pull request #312 from Godzil/Add_DrawList_Functions
Browse files Browse the repository at this point in the history
Adding path related functions
  • Loading branch information
KinoxKlark committed Nov 29, 2022
2 parents 139b5eb + 28889c5 commit 9a8e53f
Show file tree
Hide file tree
Showing 18 changed files with 714 additions and 19 deletions.
68 changes: 68 additions & 0 deletions doc/source/guide/draw-flags.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
.. _guide-draw-flags:

Using draw flags
================


Certains commands link with the DrawList do accept a flag parameter to customise
how lines and shapes are drawn. This argument is an integer bitfield
so many different flags can be joined together with ``|`` operator.

It has to be noted that not all flag apply to all functions using them. For
example :func:`_DrawList.path_stroke()` do not use the rounded corner flags.

.. visual-example::
:auto_layout:
:width: 320
:title: Draw flags


imgui.set_next_window_size(300, 300)
imgui.set_next_window_position(10, 0)
imgui.begin("Draw flags examples")

draw_list = imgui.get_window_draw_list()
draw_list.path_clear()
draw_list.path_line_to(80, 80)
draw_list.path_arc_to(80, 80, 30, 0.5, 5.5)
draw_list.path_stroke(imgui.get_color_u32_rgba(1,1,0,1),
flags=imgui.DRAW_CLOSED, thickness=10)

draw_list.path_clear()
draw_list.path_line_to(240, 80)
draw_list.path_arc_to(240, 80, 30, 0.5, 5.5)
draw_list.path_stroke(imgui.get_color_u32_rgba(1,1,0,1),
flags=imgui.DRAW_NONE, thickness=10)

draw_list.add_rect(20, 135, 60, 190,
imgui.get_color_u32_rgba(1,1,0,1), rounding=5,
flags=imgui.DRAW_ROUND_CORNERS_ALL, thickness=10)
draw_list.add_rect(100, 135, 140, 190,
imgui.get_color_u32_rgba(1,1,0,1), rounding=5,
flags=imgui.DRAW_ROUND_CORNERS_NONE, thickness=10)
draw_list.add_rect(180, 135, 220, 190,
imgui.get_color_u32_rgba(1,1,0,1), rounding=5,
flags=imgui.DRAW_ROUND_CORNERS_LEFT, thickness=10)
draw_list.add_rect(260, 135, 300, 190,
imgui.get_color_u32_rgba(1,1,0,1), rounding=5,
flags=imgui.DRAW_ROUND_CORNERS_BOTTOM_RIGHT, thickness=10)

imgui.end()


List of all available draw flags (click to see documentation):

.. _draw-flag-options:

* :py:data:`imgui.DRAW_NONE`
* :py:data:`imgui.DRAW_CLOSED`
* :py:data:`imgui.DRAW_ROUND_CORNERS_TOP_LEFT`
* :py:data:`imgui.DRAW_ROUND_CORNERS_TOP_RIGHT`
* :py:data:`imgui.DRAW_ROUND_CORNERS_BOTTOM_LEFT`
* :py:data:`imgui.DRAW_ROUND_CORNERS_BOTTOM_RIGHT`
* :py:data:`imgui.DRAW_ROUND_CORNERS_NONE`
* :py:data:`imgui.DRAW_ROUND_CORNERS_TOP`
* :py:data:`imgui.DRAW_ROUND_CORNERS_BOTTOM`
* :py:data:`imgui.DRAW_ROUND_CORNERS_LEFT`
* :py:data:`imgui.DRAW_ROUND_CORNERS_RIGHT`
* :py:data:`imgui.DRAW_ROUND_CORNERS_ALL`
1 change: 1 addition & 0 deletions doc/source/guide/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ Usage guide
inputtext-flags
slider-flags
tabbar-flags
draw-flags

Binary file added doc/source/visual_examples/guidedrawflags_0.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 14 additions & 14 deletions imgui/cimgui.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ cdef extern from "imgui.h":
ImDrawFlags flags # = 0
) except +

void AddRectFilledMultiColor( #
void AddRectFilledMultiColor( #
const ImVec2& p_min,
const ImVec2& p_max,
ImU32 col_upr_left,
Expand All @@ -384,7 +384,7 @@ cdef extern from "imgui.h":
ImU32 col_bot_left
) except +

void AddQuad( #
void AddQuad( #
const ImVec2& p1,
const ImVec2& p2,
const ImVec2& p3,
Expand All @@ -394,15 +394,15 @@ cdef extern from "imgui.h":
float thickness # = 1.0f
) except +

void AddQuadFilled( #
void AddQuadFilled( #
const ImVec2& p1,
const ImVec2& p2,
const ImVec2& p3,
const ImVec2& p4,
ImU32 col
) except +

void AddTriangle( #
void AddTriangle( #
const ImVec2& p1,
const ImVec2& p2,
const ImVec2& p3,
Expand All @@ -411,7 +411,7 @@ cdef extern from "imgui.h":
float thickness # = 1.0f
) except +

void AddTriangleFilled( #
void AddTriangleFilled( #
const ImVec2& p1,
const ImVec2& p2,
const ImVec2& p3,
Expand Down Expand Up @@ -486,7 +486,7 @@ cdef extern from "imgui.h":
ImU32 col
) except +

void AddBezierCubic( #
void AddBezierCubic( #
const ImVec2& p1,
const ImVec2& p2,
const ImVec2& p3,
Expand All @@ -497,7 +497,7 @@ cdef extern from "imgui.h":
int num_segments # = 0
) except +

void AddBezierQuadratic( #
void AddBezierQuadratic( #
const ImVec2& p1,
const ImVec2& p2,
const ImVec2& p3,
Expand Down Expand Up @@ -545,25 +545,25 @@ cdef extern from "imgui.h":
) except +

# Stateful path API, add points then finish with PathFillConvex() or PathStroke()
void PathClear() except + #
void PathLineTo(const ImVec2& pos) except + #
void PathClear() except + #
void PathLineTo(const ImVec2& pos) except + #
void PathLineToMergeDuplicate(const ImVec2& pos) except + #
void PathFillConvex(ImU32 col) except + #
void PathStroke( #
void PathFillConvex(ImU32 col) except + #
void PathStroke( #
ImU32 col,
# note: optional
ImDrawFlags flags, # = 0
float thickness # = 1.0f
) except +
void PathArcTo( #
void PathArcTo( #
const ImVec2& center,
float radius,
float a_min,
float a_max,
# note: optional
int num_segments # = 0
) except +
void PathArcToFast( #
void PathArcToFast( #
const ImVec2& center,
float radius,
int a_min_of_12,
Expand All @@ -582,7 +582,7 @@ cdef extern from "imgui.h":
# note: optional
int num_segments # = 0
) except +
void PathRect( #
void PathRect( #
const ImVec2& rect_min,
const ImVec2& rect_max,
# note: optional
Expand Down

0 comments on commit 9a8e53f

Please sign in to comment.