_
This commit is contained in:
parent
1dd2e4de38
commit
7947888be0
@ -15,6 +15,7 @@ class App:
|
|||||||
q = Queue()
|
q = Queue()
|
||||||
|
|
||||||
hands_ai_process = Process(target=self.hands_ai.run, args=(q,))
|
hands_ai_process = Process(target=self.hands_ai.run, args=(q,))
|
||||||
|
hands_ai_process.start()
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
self.scene.redraw()
|
self.scene.redraw()
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import pygame.transform
|
import pygame.transform
|
||||||
from Objects.Screen import Screen
|
from Objects.Screen import Screen
|
||||||
from numpy import array as a
|
from numpy import array as a
|
||||||
import numpy as np
|
|
||||||
|
|
||||||
|
|
||||||
class Scene(Screen):
|
class Scene(Screen):
|
||||||
@ -21,5 +20,8 @@ class Scene(Screen):
|
|||||||
rs = pygame.transform.scale(self.s_, self.screen_size)
|
rs = pygame.transform.scale(self.s_, self.screen_size)
|
||||||
self.s.blit(rs, [0, 0])
|
self.s.blit(rs, [0, 0])
|
||||||
|
|
||||||
|
for object_ in self.nr_objects:
|
||||||
|
object_.blit()
|
||||||
|
|
||||||
pygame.display.update()
|
pygame.display.update()
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
|
import math
|
||||||
from numpy import array as a
|
from numpy import array as a
|
||||||
import numpy as np
|
|
||||||
import pygame
|
import pygame
|
||||||
|
|
||||||
|
|
||||||
@ -15,6 +15,8 @@ class Screen:
|
|||||||
[screen_size[0] / width, 0],
|
[screen_size[0] / width, 0],
|
||||||
[0, screen_size[1] / height]
|
[0, screen_size[1] / height]
|
||||||
])
|
])
|
||||||
|
self.pd = abs(self.matrix[0, 0] * self.matrix[1, 1]) # positive determinant
|
||||||
|
self.pd_ = math.sqrt(self.pd)
|
||||||
|
|
||||||
self.s_ = pygame.Surface([width, height])
|
self.s_ = pygame.Surface([width, height])
|
||||||
self.s = pygame.display.set_mode(screen_size)
|
self.s = pygame.display.set_mode(screen_size)
|
||||||
@ -22,3 +24,6 @@ class Screen:
|
|||||||
self.font_size = font_size
|
self.font_size = font_size
|
||||||
|
|
||||||
self.center = a([width, height]) / 2
|
self.center = a([width, height]) / 2
|
||||||
|
|
||||||
|
def save(self, path):
|
||||||
|
pygame.image.save(self.s, path)
|
||||||
|
14
UI/Objects/nr_objects/Circle.py
Normal file
14
UI/Objects/nr_objects/Circle.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import pygame.draw
|
||||||
|
|
||||||
|
|
||||||
|
class Circle:
|
||||||
|
def __init__(self, center, radius, color, scene):
|
||||||
|
self.center = center
|
||||||
|
self.radius = radius
|
||||||
|
self.color = color
|
||||||
|
self.scene = scene
|
||||||
|
|
||||||
|
def blit(self):
|
||||||
|
pygame.draw.circle(self.scene.s, self.color,
|
||||||
|
self.scene.matrix @ self.center,
|
||||||
|
self.radius * self.scene.pd_)
|
14
UI/Objects/nr_objects/Line.py
Normal file
14
UI/Objects/nr_objects/Line.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import pygame.draw
|
||||||
|
|
||||||
|
|
||||||
|
class Line:
|
||||||
|
def __init__(self, a, b, width, color, scene):
|
||||||
|
self.a = a
|
||||||
|
self.b = b
|
||||||
|
self.width = width
|
||||||
|
self.color = color
|
||||||
|
self.scene = scene
|
||||||
|
|
||||||
|
def blit(self):
|
||||||
|
pygame.draw.line(self.scene.s, self.color, self.scene.matrix @ self.a, self.scene.matrix @ self.b,
|
||||||
|
int(self.width * self.scene.pd))
|
@ -1,6 +1,4 @@
|
|||||||
import pygame.draw
|
import pygame.draw
|
||||||
from numpy import array as a
|
|
||||||
import numpy as np
|
|
||||||
|
|
||||||
|
|
||||||
class Rect:
|
class Rect:
|
||||||
|
@ -3,6 +3,8 @@ from Objects.r_objects import *
|
|||||||
from numpy import array as a
|
from numpy import array as a
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
|
from UI.Objects.nr_objects.Circle import Circle
|
||||||
|
from UI.Objects.nr_objects.Line import Line
|
||||||
from UI.Objects.r_objects.Rect import Rect
|
from UI.Objects.r_objects.Rect import Rect
|
||||||
|
|
||||||
|
|
||||||
@ -15,3 +17,9 @@ class BasicScene(Scene):
|
|||||||
|
|
||||||
r0 = Rect(a([0, 0]), a([200, 200]), (160, 160, 160), self)
|
r0 = Rect(a([0, 0]), a([200, 200]), (160, 160, 160), self)
|
||||||
self.r_objects.append(r0)
|
self.r_objects.append(r0)
|
||||||
|
|
||||||
|
l0 = Line(a([100, 300]), a([500, 100]), 3, (255, 100, 100), self)
|
||||||
|
self.nr_objects.append(l0)
|
||||||
|
|
||||||
|
c0 = Circle(a([400, 200]), 40, (100, 100, 255), self)
|
||||||
|
self.nr_objects.append(c0)
|
||||||
|
@ -3,7 +3,7 @@ from numpy import array as a
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
|
|
||||||
scene = BasicScene(10, [600, 400])
|
scene = BasicScene(10, [600, 500])
|
||||||
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
Loading…
Reference in New Issue
Block a user