Skip to content

Commit

Permalink
Working on glow
Browse files Browse the repository at this point in the history
  • Loading branch information
thoppe committed May 2, 2019
1 parent 26dc8e4 commit 81f1cdf
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 41 deletions.
4 changes: 2 additions & 2 deletions pixelhouse/artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ def __init__(self, *args, **kwargs):
else:
# setattr(self, key, self._constant(val))
setattr(self, key, constant(val))

# Removed __call__ since canvas additions must be done with draw
#def __call__(self, t, *args, **kwargs):
# def __call__(self, t, *args, **kwargs):
# # Convenience method for draw
# self.draw(t, *args, **kwargs)

Expand Down
14 changes: 6 additions & 8 deletions pixelhouse/filters/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ def draw(self, cvs, t=0.0):
bx = cvs.transform_kernel_length(self.blur_x(t))
by = cvs.transform_kernel_length(self.blur_y(t))
kernel = (bx, by)
print("KERNEL!", kernel)

cvs.img = cv2.GaussianBlur(cvs.img, kernel, 0)


Expand All @@ -25,20 +23,20 @@ class glow(Artist):
glow_y = constant(1.0)
n = constant(5)
art = None

args = ("art", "glow_x", "glow_y", "n")

def draw(self, cvs, t=0.0):

gx, gy = self.glow_x(t), self.glow_y(t)
art = self.art(t)

cvs += art

if self.n(t)==0:
if self.n(t) == 0:
return True

with cvs.layer() as C:
with cvs.layer() as cvs2:
for i in range(self.n(t)):
C += gaussian_blur(gx, gy)
C += art
cvs2 += gaussian_blur(gx, gy)
cvs2 += art
2 changes: 1 addition & 1 deletion pixelhouse/primitives.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class line(PrimitiveArtist):
args = ("x", "y", "x1", "y1", "color", "thickness", "lineType")

def draw(self, cvs, t=0.0):

x, y, thickness, color, lineType, mode = self.basic_transforms(cvs, t)
x1 = cvs.transform_x(self.x1(t), use_shift=True)
y1 = cvs.transform_y(self.y1(t), use_shift=True)
Expand Down
21 changes: 21 additions & 0 deletions unincorporated_demos/vapor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import pixelhouse as ph
import numpy as np

pal = ["#FF6AD5", "#C774E8", "#AD8CFF", "#8795E8", "#94D0FF"] * 3
# C = ph.Canvas(512, 512)
C = ph.Animation(512, 512, fps=30, duration=4)

lw = 0.25
Y = np.linspace(-4.0, 4.0, len(pal))
dk = 1.0 / len(pal)
move = ph.motion.easeInOutQuad

for k, y in enumerate(Y):
x = move(3, 0.25, flip=True, phase=k * dk)
gx = move(1, 4, flip=True, phase=k * dk)
line = ph.line(x=-x, x1=x, y=y, y1=y, thickness=lw, color=pal[k])
C += ph.filters.glow(line, glow_x=gx, glow_y=gx, n=5)


ph.canvas2mp4(C, "vwa.mp4")
C.show()
30 changes: 0 additions & 30 deletions vapor.py

This file was deleted.

0 comments on commit 81f1cdf

Please sign in to comment.