Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static Clutter.Timeline? timeline = null;
- public static TestActor[] actors;
- public static void main(string[] args) {
- Clutter.init(ref args);
- Clutter.Stage stage = Clutter.Stage.get_default();
- stage.set_size(512,512);
- actors = new TestActor[26];
- for(int i = 0 ; i < actors.length ; i++) {
- TestActor actor = new TestActor();
- actor.set_size(32,32);
- actor.x = i * 10;
- actor.y = i * 10;
- actor.visible = true;
- stage.add_actor(actor);
- actors[i] = actor;
- }
- timeline = new Clutter.Timeline(1000);
- timeline.loop = true;
- timeline.new_frame.connect( new_frame);
- timeline.start();
- stage.color = {0,0,0,0xff};
- stage.show();
- Clutter.main();
- }
- public static void new_frame() {
- double progress = timeline.get_progress();
- for(int i = 0 ; i < actors.length ; i++) {
- uint opacity = (uint) (255 * progress);
- actors[i].opacity = opacity;
- }
- }
- public class TestActor : Clutter.Actor {
- Cogl.Texture? texture = null;
- Cogl.Offscreen? offscreen = null;
- Cogl.Material? material = null;
- public override void paint() {
- texture = new Cogl.Texture.with_size(32,32,Cogl.TextureFlags.NO_SLICING,Cogl.PixelFormat.RGBA_8888);
- offscreen = new Cogl.Offscreen.to_texture(texture);
- material = new Cogl.Material();
- material.set_layer(0,texture);
- //Without this call we don't leak
- Cogl.set_source(material);
- Cogl.rectangle(0,0,32,32);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement