public
Last active

  • Download Gist
animate.py
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
import sys
import pygtk
pygtk.require('2.0')
 
from gi.repository import Clutter
 
Clutter.init(sys.argv)
 
stage = Clutter.Stage()
 
stage_color = Clutter.Color(0, 0, 0, 255)
actor_color = Clutter.Color(255, 255, 255, 99)
 
stage.set_size(200, 200)
stage.set_color(stage_color)
 
rect = Clutter.Rectangle.new_with_color(actor_color)
rect.set_size(40, 40)
rect.set_position(10, 10)
stage.add_actor(rect)
rect.show()
 
stage.show()
 
def on_alpha(alpha, data):
timeline = alpha.get_timeline()
return timeline.get_progress()
 
timeline = Clutter.Timeline.new(5000)
timeline.set_loop(True)
timeline.start()
 
#import pdb; pdb.set_trace()
alpha = Clutter.Alpha()
alpha.set_timeline(timeline)
alpha.set_func(on_alpha, None, None)
animation = rect.animate_with_alphav(alpha, 3,
["x", 150, "y", 150, "opacity", 0])
 
Clutter.main()
rect_and_text.py
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
# adaptation of http://www.openismus.com/documents/clutter_tutorial/0.9/docs/tutorial/html/sec-actors-transformations.html
import sys
import pygtk
pygtk.require('2.0')
 
from gi.repository import Clutter
 
Clutter.init(sys.argv)
 
stage = Clutter.Stage()
 
 
stage_color = Clutter.Color(0, 0, 0, 255)
actor_color = Clutter.Color(255, 255, 255, 99)
 
stage.set_size(200, 200)
stage.set_color(stage_color)
 
rect = Clutter.Rectangle.new_with_color(actor_color)
rect.set_size(100, 100)
rect.set_position(20, 20)
stage.add_actor(rect)
rect.show()
 
rect.set_rotation(Clutter.RotateAxis.X_AXIS, -20, 0, 0, 0)
 
label = Clutter.Text.new_full("Sans 12", "Some Text", actor_color)
label.set_size(500, 500)
label.set_position(20, 150)
stage.add_actor(label)
label.show()
 
label.set_scale(3., 1.)
 
label.move_by(10, -10)
label.set_depth(-20)
 
stage.show()
 
Clutter.main()

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.