From 8e95ffa8b394f04989a7cba6db67f44d7d5a4cac Mon Sep 17 00:00:00 2001 From: Thomas Jebson Date: Tue, 22 Oct 2024 22:45:17 +0100 Subject: [PATCH] accuracy improvements will tidy up tmrw :) --- experiments/drawing test.py | 2 +- python_src/draw.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/experiments/drawing test.py b/experiments/drawing test.py index f1ae5c9..741442e 100644 --- a/experiments/drawing test.py +++ b/experiments/drawing test.py @@ -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)) diff --git a/python_src/draw.py b/python_src/draw.py index ec18e05..59c7e9a 100644 --- a/python_src/draw.py +++ b/python_src/draw.py @@ -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 @@ -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