Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. public static Clutter.Timeline? timeline = null;
  2. public static TestActor[] actors;
  3.  
  4. public static void main(string[] args) {
  5. Clutter.init(ref args);
  6. Clutter.Stage stage = Clutter.Stage.get_default();
  7. stage.set_size(512,512);
  8. actors = new TestActor[26];
  9. for(int i = 0 ; i < actors.length ; i++) {
  10. TestActor actor = new TestActor();
  11. actor.set_size(32,32);
  12. actor.x = i * 10;
  13. actor.y = i * 10;
  14. actor.visible = true;
  15. stage.add_actor(actor);
  16. actors[i] = actor;
  17. }
  18.  
  19. timeline = new Clutter.Timeline(1000);
  20. timeline.loop = true;
  21. timeline.new_frame.connect( new_frame);
  22. timeline.start();
  23. stage.color = {0,0,0,0xff};
  24. stage.show();
  25. Clutter.main();
  26. }
  27.  
  28. public static void new_frame() {
  29. double progress = timeline.get_progress();
  30. for(int i = 0 ; i < actors.length ; i++) {
  31. uint opacity = (uint) (255 * progress);
  32. actors[i].opacity = opacity;
  33. }
  34. }
  35.  
  36. public class TestActor : Clutter.Actor {
  37.  
  38. Cogl.Texture? texture = null;
  39. Cogl.Offscreen? offscreen = null;
  40. Cogl.Material? material = null;
  41.  
  42. public override void paint() {
  43. texture = new Cogl.Texture.with_size(32,32,Cogl.TextureFlags.NO_SLICING,Cogl.PixelFormat.RGBA_8888);
  44. offscreen = new Cogl.Offscreen.to_texture(texture);
  45. material = new Cogl.Material();
  46. material.set_layer(0,texture);
  47.  
  48. //Without this call we don't leak
  49. Cogl.set_source(material);
  50.  
  51. Cogl.rectangle(0,0,32,32);
  52.  
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement