add yellow sphere, fix CI
This commit is contained in:
@@ -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."""
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
pyside6>=6.6.1
|
||||
pytest==8.3.3
|
||||
ruff==0.12.10
|
||||
|
||||
Reference in New Issue
Block a user