How to get ui.Path to fill arbitrary polygons? #104
Answered
by
cvpe
CatsAndChaos
asked this question in
Q&A
-
|
I cannot get a Path to fill in a shape drawn using lines. Am I doing something wrong, is this a bug, or is this simply not supported? If it is one of the latter two, are there any alternatives? This clearly creates a perfect triangle with no gaps, but all that results is the outline. |
Beta Was this translation helpful? Give feedback.
Answered by
cvpe
Nov 19, 2025
Replies: 1 comment 1 reply
-
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
CatsAndChaos
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

When you do intermediate moves, you break the polygon, try without them
import scene
import ui
with ui.ImageContext(100, 100) as ctx:
ui.set_color('red')
p = ui.Path()
p.move_to(10, 10)
p.line_to(30, 30)
#p.move_to(30, 30)
p.line_to(10, 30)
#p.move_to(10, 30)
p.line_to(10, 10)
#p.move_to(10, 10)
p.stroke()
p.fill()
ctx.get_image().show()