first circle
This commit is contained in:
44
grid/ui/pattern.py
Normal file
44
grid/ui/pattern.py
Normal file
@@ -0,0 +1,44 @@
|
||||
from PySide6.QtWidgets import QGraphicsItemGroup
|
||||
from random import randint
|
||||
|
||||
from grid.ui.sphere_widget import SphereGraphicsItem, ArcGraphicsItem, LineGraphicsItem
|
||||
|
||||
class Pattern(QGraphicsItemGroup):
|
||||
"""Common pattern on the sphere grid
|
||||
"""
|
||||
|
||||
PATTERN_WIDTH = 250
|
||||
SPACE_BETWEEN_SPHERE = 60
|
||||
|
||||
def __init__(self, top_left_corner_x: int, top_left_corner_y: int) -> None:
|
||||
super().__init__()
|
||||
# center coordinates of the pattern
|
||||
center_x = int((top_left_corner_x + self.PATTERN_WIDTH) / 2)
|
||||
center_y = int((top_left_corner_y + self.PATTERN_WIDTH) / 2)
|
||||
|
||||
# center
|
||||
self.addToGroup(SphereGraphicsItem(center_x, center_y))
|
||||
|
||||
# first cercle
|
||||
self.addToGroup(SphereGraphicsItem(center_x, center_y - self.SPACE_BETWEEN_SPHERE))
|
||||
self.addToGroup(SphereGraphicsItem(center_x, center_y + self.SPACE_BETWEEN_SPHERE))
|
||||
self.addToGroup(SphereGraphicsItem(center_x - self.SPACE_BETWEEN_SPHERE, center_y))
|
||||
self.addToGroup(SphereGraphicsItem(center_x + self.SPACE_BETWEEN_SPHERE, center_y))
|
||||
|
||||
sphere_on_circle = 4
|
||||
for i in range(sphere_on_circle):
|
||||
self.addToGroup(ArcGraphicsItem(center_x, center_y, self.SPACE_BETWEEN_SPHERE, (i*360/sphere_on_circle)%360, ((i+1)*360/sphere_on_circle)%360, self))
|
||||
print(center_x-self.SPACE_BETWEEN_SPHERE+i*self.SPACE_BETWEEN_SPHERE)
|
||||
self.addToGroup(SphereGraphicsItem(center_x, center_y - self.SPACE_BETWEEN_SPHERE))
|
||||
|
||||
|
||||
line_start_x = int(center_x + self.SPACE_BETWEEN_SPHERE/2)
|
||||
line_start_y = int(center_y + self.SPACE_BETWEEN_SPHERE/2)
|
||||
line_end_x = int(center_x + self.SPACE_BETWEEN_SPHERE/2)
|
||||
line_end_y = int(center_y + self.SPACE_BETWEEN_SPHERE*1.5)
|
||||
self.addToGroup(LineGraphicsItem(line_start_x, line_start_y, line_end_x, line_end_y, self))
|
||||
|
||||
# second cercle
|
||||
sphere_on_circle = 8
|
||||
#for i in range(sphere_on_circle):
|
||||
# self.addToGroup(ArcGraphicsItem(center_x, center_y, self.SPACE_BETWEEN_SPHERE*2, int(i*360/sphere_on_circle/4)%360, int((i+1)*360/sphere_on_circle)%360, self))
|
||||
Reference in New Issue
Block a user