add yellow sphere, fix CI
This commit is contained in:
@@ -15,7 +15,9 @@ class SphereGraphicsItem(QGraphicsEllipseItem):
|
|||||||
|
|
||||||
SPHERE_WIDTH = 30
|
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
|
"""Create a sphere
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -34,24 +36,30 @@ class SphereGraphicsItem(QGraphicsEllipseItem):
|
|||||||
|
|
||||||
brush = QBrush(color)
|
brush = QBrush(color)
|
||||||
self.setBrush(brush)
|
self.setBrush(brush)
|
||||||
pen = QPen(Qt.GlobalColor.blue)
|
pen = QPen(Qt.GlobalColor.darkBlue)
|
||||||
pen.setWidth(3)
|
pen.setWidth(2)
|
||||||
self.setPen(pen)
|
self.setPen(pen)
|
||||||
self.show()
|
self.show()
|
||||||
|
|
||||||
def boundingRect(self) -> QRectF:
|
def boundingRect(self) -> QRectF:
|
||||||
return QRectF(self.x_pos, self.y_pos, self.SPHERE_WIDTH, self.SPHERE_WIDTH)
|
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:
|
def __init__(self, x_pos: int, y_pos: int) -> None:
|
||||||
super().__init__(x_pos, y_pos, Qt.GlobalColor.darkGreen)
|
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:
|
def __init__(self, x_pos: int, y_pos: int) -> None:
|
||||||
super().__init__(x_pos, y_pos, Qt.GlobalColor.darkRed)
|
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):
|
class ArcGraphicsItem(QGraphicsItem):
|
||||||
"""Circle arc."""
|
"""Circle arc."""
|
||||||
|
|
||||||
|
|||||||
@@ -13,13 +13,20 @@ from PySide6.QtWidgets import (
|
|||||||
QWidget,
|
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):
|
class Pattern(QGraphicsItemGroup):
|
||||||
"""Common pattern on the sphere grid"""
|
"""Common pattern on the sphere grid"""
|
||||||
|
|
||||||
PATTERN_WIDTH = 400
|
PATTERN_WIDTH = 350
|
||||||
SPACE_BETWEEN_SPHERE = 60
|
SPACE_BETWEEN_SPHERE = 60
|
||||||
|
|
||||||
def __init__(self, top_left_corner_x: int, top_left_corner_y: int) -> None:
|
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
|
center_x, center_y, self.SPACE_BETWEEN_SPHERE, sphere_on_circle
|
||||||
)
|
)
|
||||||
for x, y in points:
|
for x, y in points:
|
||||||
if random.random() > 0.5:
|
rand = random.random()
|
||||||
|
if rand > 2 / 3:
|
||||||
self.addToGroup(SphereGraphicsItem(x, y))
|
self.addToGroup(SphereGraphicsItem(x, y))
|
||||||
|
elif rand > 1 / 3:
|
||||||
|
self.addToGroup(AgilitySphereGraphicsItem(x, y))
|
||||||
else:
|
else:
|
||||||
self.addToGroup(StrenghSphereGraphicsItem(x, y))
|
self.addToGroup(StrenghSphereGraphicsItem(x, y))
|
||||||
|
|
||||||
@@ -105,7 +115,12 @@ class Pattern(QGraphicsItemGroup):
|
|||||||
super().paint(painter, option, widget)
|
super().paint(painter, option, widget)
|
||||||
brush = QBrush(Qt.GlobalColor.gray)
|
brush = QBrush(Qt.GlobalColor.gray)
|
||||||
painter.setBrush(brush)
|
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
|
@staticmethod
|
||||||
def generate_circle_points(
|
def generate_circle_points(
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
pyside6>=6.6.1
|
pyside6>=6.6.1
|
||||||
pytest==8.3.3
|
pytest==8.3.3
|
||||||
|
ruff==0.12.10
|
||||||
|
|||||||
Reference in New Issue
Block a user