This commit is contained in:
Benjamín 2021-09-01 18:23:35 +02:00
parent 7947888be0
commit b3c93e804a
4 changed files with 36 additions and 3 deletions

@ -0,0 +1,19 @@
import pygame
class Ellipse:
def __init__(self, center, a, b, color, scene):
self.center = center
self.a = a
self.b = b
self.color = color
self.scene = scene
def blit(self):
a_ = self.a * self.scene.pd_
b_ = self.b * self.scene.pd_
center_ = self.scene.matrix @ self.center
center_ = [center_[0] - a_, center_[1] - b_]
pygame.draw.ellipse(self.scene.s, self.color,
pygame.Rect(center_, [a_ * 2, b_ * 2]))

@ -11,4 +11,4 @@ class Line:
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))
max(1, int(self.width * self.scene.pd)))

@ -3,6 +3,7 @@ from Objects.r_objects import *
from numpy import array as a
import numpy as np
from UI.Objects.nr_objects.Ellipse import Ellipse
from UI.Objects.nr_objects.Circle import Circle
from UI.Objects.nr_objects.Line import Line
from UI.Objects.r_objects.Rect import Rect
@ -23,3 +24,6 @@ class BasicScene(Scene):
c0 = Circle(a([400, 200]), 40, (100, 100, 255), self)
self.nr_objects.append(c0)
e0 = Ellipse(a([150, 360]), 60, 20, (100, 255, 100), self)
self.nr_objects.append(e0)

@ -3,9 +3,19 @@ from numpy import array as a
import time
scene = BasicScene(10, [600, 500])
screen_size = a([200, 500])
while True:
for i in range(400):
scene = BasicScene(10, screen_size)
scene.redraw()
#scene.save(f"Render/{i}.png")
if i < 150:
screen_size[0] += 3
elif i < 250:
screen_size[1] += 2
else:
screen_size -= 4
time.sleep(0.01)