File: test-behave.cs

package info (click to toggle)
clutter-sharp 1.0.0~alpha3~git20090817.r1.349dba6-8
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 4,104 kB
  • ctags: 2,193
  • sloc: xml: 23,456; cs: 9,946; sh: 3,393; perl: 1,213; makefile: 270; awk: 50; sed: 13
file content (69 lines) | stat: -rw-r--r-- 1,603 bytes parent folder | download
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using System;

using Clutter;

namespace ClutterTest
{
	public class Behave
	{
		static Knot[] knots = {new Knot (0, 0), new Knot (0, 300), new Knot (300, 300),
					new Knot (300, 0), new Knot (0, 0) };

		public static void Main(string[] args)
		{
			Application.Init ();

			Stage stage = Stage.Default as Stage;
			(stage as Stage).KeyPressEvent += delegate { 
				Clutter.Main.Quit(); 
			};

			// fixme: add constructor
			Clutter.Color stage_color = new Clutter.Color (0xcc, 0xcc, 0xcc, 0xff);
			stage.SetColor (stage_color);

			Clutter.Group group = new Group();
			stage.Add (group);
			group.Show ();

			// Make a hand
			Clutter.Actor hand = new Texture ("redhand.png");
			hand.SetPosition (0,0);
			hand.Show ();

			// Make a rect
			Clutter.Rectangle rect = new Clutter.Rectangle();
			rect.SetPosition (0,0);
			rect.SetSize ((int)hand.Width, (int)hand.Height);

			Clutter.Color rect_bg_color = new Clutter.Color (0x33, 0x22, 0x22, 0xff);
			rect.SetColor (rect_bg_color);
			rect.BorderWidth = 10;
			rect.Show ();

			group.Add (rect);
			group.Add (hand);

			// Make a timeline
			Timeline timeline = new Timeline (100, 26);
			timeline.Loop = true;

			Alpha alpha = new Alpha (timeline, (a) => a.Value);

			Behaviour o_behave = new BehaviourOpacity (alpha, 0x33, 0xff); 
			o_behave.Apply (group);

			// Make a path behaviour and apply that too
			Behaviour p_behave = new BehaviourPath(alpha, knots); // fixme: add custom constructor?
			p_behave.Apply (group);

			// start timeline
			timeline.Start ();

			stage.ShowAll();

			// launch
			Application.Run ();
		}
	}
}