From 50b783c1df722ae86fcda4c4a3e1989b03222499 Mon Sep 17 00:00:00 2001 From: Alexandre RIO Date: Sat, 23 Aug 2025 15:21:06 +0200 Subject: [PATCH] add yellow sphere, fix CI --- grid/ui/items.py | 18 +++++++++++++----- grid/ui/pattern.py | 23 +++++++++++++++++++---- requirements.txt | 1 + 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/grid/ui/items.py b/grid/ui/items.py index b061dff..32063b1 100644 --- a/grid/ui/items.py +++ b/grid/ui/items.py @@ -15,7 +15,9 @@ class SphereGraphicsItem(QGraphicsEllipseItem): SPHERE_WIDTH = 30 - def __init__(self, x_pos: int, y_pos: int, color: Qt.GlobalColor = Qt.GlobalColor.darkBlue) -> None: + def __init__( + self, x_pos: int, y_pos: int, color: Qt.GlobalColor = Qt.GlobalColor.darkBlue + ) -> None: """Create a sphere Args: @@ -34,24 +36,30 @@ class SphereGraphicsItem(QGraphicsEllipseItem): brush = QBrush(color) self.setBrush(brush) - pen = QPen(Qt.GlobalColor.blue) - pen.setWidth(3) + pen = QPen(Qt.GlobalColor.darkBlue) + pen.setWidth(2) self.setPen(pen) self.show() def boundingRect(self) -> QRectF: return QRectF(self.x_pos, self.y_pos, self.SPHERE_WIDTH, self.SPHERE_WIDTH) -class HPSphereGraphicsItem(SphereGraphicsItem): +class HPSphereGraphicsItem(SphereGraphicsItem): def __init__(self, x_pos: int, y_pos: int) -> None: super().__init__(x_pos, y_pos, Qt.GlobalColor.darkGreen) -class StrenghSphereGraphicsItem(SphereGraphicsItem): +class StrenghSphereGraphicsItem(SphereGraphicsItem): def __init__(self, x_pos: int, y_pos: int) -> None: super().__init__(x_pos, y_pos, Qt.GlobalColor.darkRed) + +class AgilitySphereGraphicsItem(SphereGraphicsItem): + def __init__(self, x_pos: int, y_pos: int) -> None: + super().__init__(x_pos, y_pos, Qt.GlobalColor.darkYellow) + + class ArcGraphicsItem(QGraphicsItem): """Circle arc.""" diff --git a/grid/ui/pattern.py b/grid/ui/pattern.py index 71f7242..ad8ef4f 100644 --- a/grid/ui/pattern.py +++ b/grid/ui/pattern.py @@ -13,13 +13,20 @@ from PySide6.QtWidgets import ( QWidget, ) -from grid.ui.items import HPSphereGraphicsItem, SphereGraphicsItem, ArcGraphicsItem, LineGraphicsItem, StrenghSphereGraphicsItem +from grid.ui.items import ( + AgilitySphereGraphicsItem, + HPSphereGraphicsItem, + SphereGraphicsItem, + ArcGraphicsItem, + LineGraphicsItem, + StrenghSphereGraphicsItem, +) class Pattern(QGraphicsItemGroup): """Common pattern on the sphere grid""" - PATTERN_WIDTH = 400 + PATTERN_WIDTH = 350 SPACE_BETWEEN_SPHERE = 60 def __init__(self, top_left_corner_x: int, top_left_corner_y: int) -> None: @@ -67,8 +74,11 @@ class Pattern(QGraphicsItemGroup): center_x, center_y, self.SPACE_BETWEEN_SPHERE, sphere_on_circle ) for x, y in points: - if random.random() > 0.5: + rand = random.random() + if rand > 2 / 3: self.addToGroup(SphereGraphicsItem(x, y)) + elif rand > 1 / 3: + self.addToGroup(AgilitySphereGraphicsItem(x, y)) else: self.addToGroup(StrenghSphereGraphicsItem(x, y)) @@ -105,7 +115,12 @@ class Pattern(QGraphicsItemGroup): super().paint(painter, option, widget) brush = QBrush(Qt.GlobalColor.gray) painter.setBrush(brush) - painter.drawRect(self.top_left_corner_x, self.top_left_corner_y, self.PATTERN_WIDTH, self.PATTERN_WIDTH) + painter.drawRect( + self.top_left_corner_x, + self.top_left_corner_y, + self.PATTERN_WIDTH, + self.PATTERN_WIDTH, + ) @staticmethod def generate_circle_points( diff --git a/requirements.txt b/requirements.txt index 6142e06..a58f242 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ pyside6>=6.6.1 pytest==8.3.3 +ruff==0.12.10