Reorg
This commit is contained in:
138
cues.py
Normal file
138
cues.py
Normal file
@ -0,0 +1,138 @@
|
||||
#%%
|
||||
|
||||
import math
|
||||
import random
|
||||
|
||||
from flight.case import *
|
||||
from flight.color import Color
|
||||
from flight.client import *
|
||||
from flight.expressions import *
|
||||
from flight.expressions import Expression
|
||||
from flight.server import FlightServer
|
||||
|
||||
from constants import *
|
||||
|
||||
|
||||
#%%
|
||||
|
||||
client.activate()
|
||||
|
||||
with Cue('Q01', name='Mask', fadeIn=5, fadeOut=5):
|
||||
Match('#mask').fader = 1
|
||||
|
||||
with Cue('Q02', name='Rotating mask', fadeIn=1, fadeOut=2):
|
||||
period = 11
|
||||
count = t / period
|
||||
Match('#master_mask').rotate = count % 1 * f
|
||||
|
||||
with Cue('Q03', name='Multiple masks'):
|
||||
period = 3
|
||||
scale = 1 / (1 + (t / period) // 1)
|
||||
Match('#mask').scale = scale
|
||||
Match('#mask Rect').width = container.width / scale
|
||||
Match('#mask Rect').height = container.height / scale
|
||||
|
||||
with Cue('Q04', name='Blinking eyes') as Q2:
|
||||
period = 3
|
||||
duration = 0.2
|
||||
count = t / period
|
||||
cycle = t % period
|
||||
offset = beta('Q04.offset')[count] * (period - duration)
|
||||
blink = 1 - when((cycle > offset) & (cycle < offset + duration), impulse((cycle - offset) / duration), 0)
|
||||
Match('.pupil > Rect').y = -PupilHeight / 2 * blink
|
||||
Match('.pupil > Rect').height = PupilHeight * blink
|
||||
|
||||
with Cue('Q05', name='Talking'):
|
||||
period = 0.5
|
||||
duration = 0.1 + 0.2 * beta('Q04.duration')[count]
|
||||
count = t / period
|
||||
cycle = t % period
|
||||
offset = beta('Q05.offset')[count] * (period - duration)
|
||||
wag = when((cycle > offset) & (cycle < offset + duration), impulse((cycle - offset) / duration), 0)
|
||||
height = uniform('Q05.height')[count] * (TongueHeight - MouthCornerRadius * 2)
|
||||
Match('.tongue > RoundedRect').height = TongueHeight - height * wag
|
||||
|
||||
with Cue('Q06', name='Emoji'):
|
||||
emoji = ['😳', '🎁', '🎉', '🤗', '💃', '🍰', '😉', '😸', '🐄', '🍆', '❤️', '⭐️', '😎',
|
||||
'🛑', '✋', '🏃♀️', '✈️', '☹️', '🤕', '😢', '👺', '💵', '💰', '🤑']
|
||||
period = 0.5
|
||||
count = t / period
|
||||
character = choose(uniform('Q06')[count], emoji)
|
||||
Match('#symbol Text').text = character
|
||||
|
||||
with Cue('Q07', name='Helmet', fadeIn=1, fadeOut=1):
|
||||
Match('#helmet').fader = 1
|
||||
|
||||
with Cue('Q11', name='Rainbow triangles', fadeIn=1, fadeOut=1):
|
||||
period = 5
|
||||
count = t / period
|
||||
color = hsv(count + i / n, 1, 1)
|
||||
Match('.triangle .left').color = color
|
||||
Match('.triangle .right').color = color * 0.9
|
||||
|
||||
with Cue('Q12', name='Rotating triangles') as Q1:
|
||||
period = 9 / maximum(f, 1e-6)
|
||||
count = t / period
|
||||
Match('#triangles').rotate = count
|
||||
|
||||
with Cue('Q13', name='Spinning triangles', fadeIn=1, fadeOut=1):
|
||||
period = 5
|
||||
count = t / period
|
||||
scale = 2*sine((count + i / n) * 5)
|
||||
Match('.triangle').rotate = count
|
||||
Match('.triangle').scale = 1 + scale
|
||||
Match('.triangle').y = -TriangleRadius - TriangleHeight * scale
|
||||
|
||||
with Cue('Q14', name='Nightmare spots') as Q3:
|
||||
period = 1
|
||||
count = t / period
|
||||
Match('.bead.odd').scale = 2 * sine(count)
|
||||
Match('.bead.even').scale = 2 * (1 - sine(count))
|
||||
|
||||
with Cue('Q21', name='Twinkling stars', fadeIn=1, fadeOut=1):
|
||||
period = 1
|
||||
phase = uniform('Q21.phase')[i]
|
||||
count = gt / period + phase
|
||||
Match('#stars').fader = 1
|
||||
with Match('.star') as m:
|
||||
m.x = (uniform('Q21.x', i)[count] - 0.5) * screen.width
|
||||
m.y = (uniform('Q21.y', i)[count] - 0.5) * screen.height
|
||||
Match('.star').scale = uniform('Q21.scale', i)[count]
|
||||
Match('.star .fill').color = white(sine(count))
|
||||
|
||||
with Cue('Q22', name='Bouncing stars', fadeIn=1, fadeOut=1):
|
||||
period = 1
|
||||
phase = uniform('Q21.phase')[i]
|
||||
count = gt / period + phase
|
||||
Match('#stars').fader = 1
|
||||
with Match('.star') as m:
|
||||
m.x = (uniform('Q21.x', i)[count] - 0.5) * screen.width
|
||||
m.y = (uniform('Q21.y', i)[count] - 0.5) * screen.height
|
||||
m.rotate = count / 5
|
||||
m.scale = bounce(count) * 25
|
||||
Match('.star .outline').color = hsv(uniform('Q22.hue', i)[count], 1, bounce(count))
|
||||
|
||||
with Cue('Q23', name='Thin stars', fadeIn=1, fadeOut=1):
|
||||
period = 9 + beta('Q23.period')[i] * 2
|
||||
phase = uniform('Q23.phase')[i]
|
||||
count = t / period + phase
|
||||
hue = quad(count, uniform('Q23.hue', i)[count], uniform('Q23.hue', i)[count + 1])
|
||||
Match('#stars').fader = 1
|
||||
with Match('.star') as m:
|
||||
m.lineWidth = sine(count) / 10
|
||||
m.scale = 50
|
||||
m.x = (uniform('Q23.x')[i] - 0.5) * screen.width
|
||||
m.y = (uniform('Q23.y')[i] - 0.5) * screen.height
|
||||
m.rotate = count / 10
|
||||
Match('.star .outline').color = hsv(hue, 0.8, 1)
|
||||
|
||||
with Cue('Q24', name='Rushing stars', fadeIn=1, fadeOut=1):
|
||||
period = 3
|
||||
phase = uniform('Q21.phase')[i]
|
||||
count = gt / period + phase
|
||||
Match('#stars').fader = 1
|
||||
with Match('.star') as m:
|
||||
m.x = (uniform('Q24.x', i)[count] - 0.5) * screen.width * 2 * (count % 1)
|
||||
m.y = (uniform('Q24.y', i)[count] - 0.5) * screen.height * 2 * (count % 1)
|
||||
m.color = white(sine(count))
|
||||
m.scale = count % 1
|
Reference in New Issue
Block a user