from pres.combined.diagrams import * from pres.combined.animations import * from pres.combined.interactions import * from pres.combined.presentations import *becomes:
from slithy.library import * from slithy.presentations import *
test_objects
function.
from slithy.library import * . . . # define stuff test_objects( some_diagram, some_animation, some_interaction )In the tester window, the Object menu lets you select which object to display.
Note that you can no longer pass in an animation script function, you have to call the script yourself and pass the resulting animation object. Here's the recommended style:
from slithy.library import *
def my_anim():
. . .
start_animation( ... )
. . .
return end_animation()
my_anim = my_anim() # execute the script and then discard it,
# keeping only the animation object it returns
test_objects( my_anim )
rotate( 45, (4, 5) ) line( (0,0), (1,0), (1,1) ) rectangle( (10,10), (20,20) ) text( (5,5), 'hello!', font = fonts['bold'] )becomes:
rotate( 45, 4, 5 ) line( 0, 0, 1, 0, 1, 1 ) rectangle( 10, 10, 20, 20 ) text( 5, 5, 'hello!', font = fonts['bold'] )Similarly,
start_animation
now takes elements as its
arguments, rather than a list of elements. Replace code like this:
start_animation( [bg, dr, tx] )with this:
start_animation( bg, dr, tx )
set_camera
. If
you want to base the camera on a parameter, you can.
def diagram( ... ): . . . diagram.cameras = { 'start' : (0, 0, 2, 0, 1), 'end' : (0, 0, 20, 0, 1) }becomes:
def diagram( cam=(SCALAR, 0, 1), ... ): set_camera( Rect( 0, 0, 2, 2 ).interp( Rect( 0, 0, 20, 20 ), cam ) ) . . .Now you move the camera by twiddling the cam parameter, just like any other parameter. The
interp_cameralist
function
in slithy.utils
might come in handy for handling more
than two camera positions.
set_background_layout
function, etc. They
didn't work that well, and they didn't seem that useful anyway.
Hopefully positioning elements by hand will be much easier due to the
next item.
translate
and rotate
methods that worked in strange, unintuitive ways:
def my_animation(): dr = Diagram( x1 = 200, y1 = 00, x2 = 400, y2 = 280, ... ) tx = Text( x = 200, y = 280, ... ) start_animation( [dr, tx] ) . . . tx.translate( 200, 0 ) . . .Now, all elements are positioned on the animation canvas by a rectangle object. Rather than constructing a Rect object by hand, the recommended method is to call
get_camera
, which returns a
rectangle representing the whole screen, and use the Rect methods to
subdivide it.Animating element positions is done by creating a viewport pseudoelement which interpolates between the rectangles you want:
def my_animation(): dr = Drawable( get_camera().left(0.5).inset(0.05), ... ) txv = viewport.interp( get_camera().right(0.5).inset(0.5), get_camera().right(0.5).inset(0.5).move_right(2.0) ) tx = Text( txv, ... ) start_animation( dr, tx ) . . . smooth( 2.0, txv.x, 1.0 ) # manipulating txv's x parameter moves tx . . .
a = bullet_a.diagram_interaction() play( a[:-1] ) t = add_interactive_diagram( piechart_d.pc, (20,10), (380,190) ) pause() delete_interactive_diagram( t ) play( a[-1] ) a = bullet_a.playing_video() play( a[0] ) t = add_video( 'running.avi', (20,20), (380,200) ) pause() delete_video( t ) play( a[1] )Instead, these things are integrated into your animation scripts, just like diagrams and whatnot:
def my_anim(): bg = Fill( ... ) tx = Text( ... ) it = Interactive( ... ) vd = Video( ... ) start_animation( bg, tx ) . . . enter( it ) pause() . . . exit( it ) enter( vd ) . . . exit( vd ) . . . return end_animation()Video windows still can't be moved around — they are fixed in their initial position on the screen. Interactions behave just like other elements, though — they can animatedly move around, and they remain interactive as you spacebar through the rest of the animation. The Bézier demo in the techfest sample is an example of this.