_
This commit is contained in:
parent
d715ffb7ef
commit
1e3e7939b0
@ -27,9 +27,12 @@ class Multiscene(Scene):
|
||||
self.subscenes_prepared = True
|
||||
|
||||
def light_update(self):
|
||||
for subscene in self.subscenes:
|
||||
subscene.light_update()
|
||||
|
||||
for object_ in self.l_objects:
|
||||
object_.update()
|
||||
object_.blit()
|
||||
object_.blit(True)
|
||||
|
||||
pygame.display.update()
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
import pygame.transform
|
||||
from UI.Objects.Screen import Screen
|
||||
from numpy import array as a
|
||||
import numpy as np
|
||||
|
||||
|
||||
class Scene(Screen):
|
||||
@ -28,7 +29,7 @@ class Scene(Screen):
|
||||
def light_update(self):
|
||||
for object_ in self.l_objects:
|
||||
object_.update()
|
||||
object_.blit()
|
||||
object_.blit(True)
|
||||
|
||||
pygame.display.update()
|
||||
|
||||
@ -69,6 +70,22 @@ class Scene(Screen):
|
||||
def get_i_objects(self):
|
||||
return [[self.i_objects, self.mouse_pos]]
|
||||
|
||||
def get_info_for_light_objects(self, position):
|
||||
s = self
|
||||
positions = [position]
|
||||
matrices = [self.matrix]
|
||||
|
||||
while s.multiscene is not None:
|
||||
positions.append(s.position)
|
||||
s = s.multiscene
|
||||
matrices.append(s.matrix)
|
||||
|
||||
transformed_position = a([0., 0.])
|
||||
for p, m in zip(positions, matrices):
|
||||
transformed_position += a(m @ p)
|
||||
|
||||
return s.s, transformed_position
|
||||
|
||||
def sort_objects(self, *args):
|
||||
for object_ in args:
|
||||
for object_tag in object_.object_type.split("_"):
|
||||
|
@ -52,16 +52,31 @@ class LuminousCircleEffect:
|
||||
self.point_velocity /= math.sqrt(sum(self.point_velocity ** 2))
|
||||
self.point_velocity *= self.point_speed
|
||||
|
||||
def blit(self):
|
||||
rescaled_r = self.r * self.scene.pd_
|
||||
transformed_position = self.scene.matrix @ self.position
|
||||
def blit(self, light_blit=False):
|
||||
if light_blit:
|
||||
s, transformed_position = self.scene.get_info_for_light_objects(self.position)
|
||||
|
||||
x = np.linspace(0, self.point_position[0], self.circles_n) * rescaled_r
|
||||
y = np.linspace(0, self.point_position[1], self.circles_n) * rescaled_r
|
||||
r = np.linspace(rescaled_r, 0, self.circles_n)
|
||||
rescaled_r = self.r * self.scene.pd_
|
||||
|
||||
c = [np.linspace(value, 255, self.circles_n) for value in self.color]
|
||||
x = np.linspace(0, self.point_position[0], self.circles_n) * rescaled_r
|
||||
y = np.linspace(0, self.point_position[1], self.circles_n) * rescaled_r
|
||||
r = np.linspace(rescaled_r, 0, self.circles_n)
|
||||
|
||||
for i in range(self.circles_n - 1):
|
||||
circle(self.scene.s, (c[0][i], c[1][i], c[2][i]),
|
||||
transformed_position + array([x[i], y[i]]), r[i])
|
||||
c = [np.linspace(value, 255, self.circles_n) for value in self.color]
|
||||
|
||||
for i in range(self.circles_n - 1):
|
||||
circle(s, (c[0][i], c[1][i], c[2][i]),
|
||||
transformed_position + array([x[i], y[i]]), r[i])
|
||||
else:
|
||||
rescaled_r = self.r * self.scene.pd_
|
||||
transformed_position = self.scene.matrix @ self.position
|
||||
|
||||
x = np.linspace(0, self.point_position[0], self.circles_n) * rescaled_r
|
||||
y = np.linspace(0, self.point_position[1], self.circles_n) * rescaled_r
|
||||
r = np.linspace(rescaled_r, 0, self.circles_n)
|
||||
|
||||
c = [np.linspace(value, 255, self.circles_n) for value in self.color]
|
||||
|
||||
for i in range(self.circles_n - 1):
|
||||
circle(self.scene.s, (c[0][i], c[1][i], c[2][i]),
|
||||
transformed_position + array([x[i], y[i]]), r[i])
|
||||
|
Loading…
Reference in New Issue
Block a user