_
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import pygame.transform
|
||||
from Objects.Screen import Screen
|
||||
from numpy import array as a
|
||||
import numpy as np
|
||||
|
||||
|
||||
class Scene(Screen):
|
||||
@@ -21,5 +20,8 @@ class Scene(Screen):
|
||||
rs = pygame.transform.scale(self.s_, self.screen_size)
|
||||
self.s.blit(rs, [0, 0])
|
||||
|
||||
for object_ in self.nr_objects:
|
||||
object_.blit()
|
||||
|
||||
pygame.display.update()
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import math
|
||||
from numpy import array as a
|
||||
import numpy as np
|
||||
import pygame
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@ class Screen:
|
||||
[screen_size[0] / width, 0],
|
||||
[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.display.set_mode(screen_size)
|
||||
@@ -22,3 +24,6 @@ class Screen:
|
||||
self.font_size = font_size
|
||||
|
||||
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
|
||||
from numpy import array as a
|
||||
import numpy as np
|
||||
|
||||
|
||||
class Rect:
|
||||
|
Reference in New Issue
Block a user