Created
June 21, 2012 23:16
-
-
Save SuborbitalPigeon/2969195 to your computer and use it in GitHub Desktop.
Clutter example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"id" : "stage", | |
"type" : "ClutterStage", | |
"width" : 800, | |
"height" : 600, | |
"color" : "black", | |
"children" : [ "rectangle" ], | |
"signals" : | |
[ | |
{ | |
"name" : "destroy", | |
"handler" : "clutter_main_quit" | |
} | |
] | |
}, | |
{ | |
"id" : "rectangle", | |
"type" : "ClutterRectangle", | |
"width" : 600, | |
"height" : 450, | |
"x" : 100, | |
"y" : 75, | |
"color" : "blue", | |
"rotation-center-z-gravity" : "center", | |
"reactive" : true, | |
"signals" : | |
[ | |
{ | |
"name" : "enter-event", | |
"states" : "rectangle-states", | |
"target-state" : "hover" | |
}, | |
{ | |
"name" : "leave-event", | |
"states" : "rectangle-states", | |
"target-state" : "base" | |
} | |
], | |
"actions" : | |
[ | |
{ | |
"type" : "ClutterClickAction", | |
"signals" : | |
[ | |
{ | |
"name" : "clicked", | |
"states" : "rectangle-states", | |
"target-state" : "clicked" | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"id" : "rectangle-states", | |
"type" : "ClutterState", | |
"duration" : 1000, | |
"transitions" : | |
[ | |
{ | |
"source" : null, | |
"target" : "hover", | |
"keys" : | |
[ | |
[ "rectangle", "color", "linear", "red" ] | |
] | |
}, | |
{ | |
"source" : null, | |
"target" : "base", | |
"keys" : | |
[ | |
[ "rectangle", "color", "linear", "blue" ] | |
] | |
}, | |
{ | |
"source" : null, | |
"target" : "clicked", | |
"keys" : | |
[ | |
[ "rectangle", "rotation-angle-z" "ease-in-out-quad", 360.0 ] | |
] | |
} | |
] | |
} | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from gi.repository import Clutter | |
class Rectangle(Clutter.Script): | |
def __init__(self): | |
Clutter.Script.__init__(self) | |
self.load_from_file("rectangle.json") | |
self.connect_signals(self) | |
stage = self.get_object("stage") | |
stage.show() | |
if __name__ == "__main__": | |
Clutter.init(None) | |
view = Rectangle() | |
Clutter.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment