mikael last edited by
I had a need for some animations for this thing I was doing (running a kind of a lottery on the big screen before the Star Wars movie tomorrow), and I used scripter again. I was happy how linear and easily readable it makes stuff, without extra animation functions or callbacks.
So, wanted to advertise it (again), in case there are new people, or people with new animation needs.
Part of what I needed to happen was:
- Marker is created, big as the screen
- It zooms to a specific spot and size
- It moves from point to point, stopping for a second at each
- It zooms out again to full screen, and simultaneously its:
- Round corners get squared
- Background darkens to black
- New content is presented
- After user taps it, it fades away
And here is the method, with
yieldmarking the places where we wait for previous actions to complete:
@script def run_lottery(self): spot = self.create_marker(self) self.add_subview(spot) width(spot, 15) height(spot, 20) pos = self.next_position() while pos: center(spot, pos) yield 1.0 pos = self.next_position() frame(spot, self.bounds) corner_radius(spot, 0) background_color(spot, 'black') yield self.present_result(spot) wait_for_tap(spot) yield hide(spot) yield self.remove_subview(spot)
Since last version, I have added the
wait_for_tapfunction, as well as convenience functions like
background_color, corresponding to all animatable properties of the ui module views.