File: test-cogl-primitives.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 (71 lines) | stat: -rw-r--r-- 2,027 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
70
71
using System;
using Clutter;

public static class TestCoglPrimitives
{
    public static void Main ()
    {
        var painters = new Action [] {
            () => Cogl.Path.Line (-50, -25, 50, 25),
            () => Cogl.Path.Rectangle (-50, -25, 50, 25),
            () => Cogl.Path.RoundRectangle (-50, -25, 50, 25, 10, 5),
            () => Cogl.Path.Ellipse (0, 0, 60, 40),
            () => Cogl.Path.Polygon (new float [] {
                    -50, -50,
                    +50, -30,
                    +30, +30,
                    -30, +40}),
            () => Cogl.Path.Polyline (new float [] {
                    -50, -50,
                    +50, -30,
                    +30, +30,
                    -30, +40}),
            () => {
                Cogl.Path.MoveTo (-50, +50);
                Cogl.Path.CurveTo (
                    +100, -50,
                    -100, -50,
                    +50,  +50);
            }
        };

        Application.Init ();

        var timeline = new Timeline () {
            FrameCount = (uint)painters.Length, 
            Speed = 1,
            Loop = true
        };

        var box = new Group ();
        box.Painted += (o, e) => {
            Cogl.General.PushMatrix ();

            painters[timeline.CurrentFrame % painters.Length] ();

            Cogl.General.Translate (100, 100, 0);
            Cogl.General.SetSourceColor4ub (0, 160, 0, 255);
            Cogl.Path.StrokePreserve ();

            Cogl.General.Translate (150, 0, 0);
            Cogl.General.SetSourceColor4ub (200, 0, 0, 255);
            Cogl.Path.Fill ();

            Cogl.General.PopMatrix ();
        };

        box.SetRotation (RotateAxis.X, -30, 200, 0, 0);
        box.SetPosition (0, 100);

        var stage = Stage.Default;
        stage.SetSize (400, 400);
        stage.Title = "Cogl Primitives Test";
        stage.Add (box);
        stage.Show ();

        timeline.NewFrame += (o, e) => box.QueueRedraw ();
        timeline.Start ();

        Application.Run ();
    }
}