Skip to content

Commit

Permalink
accuracy improvements
Browse files Browse the repository at this point in the history
will tidy up tmrw :)
  • Loading branch information
PycraftDeveloper committed Oct 22, 2024
1 parent 821fe75 commit 8e95ffa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion experiments/drawing test.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
radial_polygon.set_radius(300)
radial_polygon.set_color([255, 0, 0])
radial_polygon.set_point_count(3)
radial_polygon.set_width(5)
radial_polygon.set_width(180)
"""
rectangle = pmma.Rectangle()
rectangle.set_position((100, 100))
Expand Down
5 changes: 3 additions & 2 deletions python_src/draw.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ def __init__(self):
else:
self._surface = None
self._radius = _PointConverter()
self._inner_radius = _PointConverter()
self._center = _CoordinateConverter()
self._width = None
self._vertices_changed = True # Mark vertices as changed initially
Expand Down Expand Up @@ -328,8 +329,8 @@ def _create_shape(self):

# Calculate the inner radius based on the specified width
if self._width is not None:
pixel_width = self._width / _Registry.context.viewport[2] # Convert width from pixels to normalized coordinates
inner_radius = max(outer_radius - pixel_width, 0) # Ensure the inner radius is not negative
self._inner_radius.set_point(max(self._radius.get_point() - self._width, 0))
inner_radius = self._inner_radius.get_point(_Constants.OPENGL_COORDINATES) # Ensure the inner radius is not negative
else:
inner_radius = 0 # Full polygon with no inner cut-out

Expand Down

0 comments on commit 8e95ffa

Please sign in to comment.