1 using Tizen.NUI.BaseComponents;
2 using Tizen.NUI.Components;
4 namespace Tizen.NUI.Samples
6 public class RiveAnimationTest : IExample
9 private Layer defaultLayer;
11 RiveAnimationView rav;
12 Button playButton, stopButton;
13 Button bounceButton, brokeButton;
14 Button fillButton, strokeButton, opacityButton;
15 Button scaleButton, rotationButton, positionButton;
16 public void Activate()
18 window = NUIApplication.GetDefaultWindow();
19 defaultLayer = window.GetDefaultLayer();
21 rav = new RiveAnimationView(Tizen.Applications.Application.Current.DirectoryInfo.Resource + "buggy.riv")
23 Size = new Size(500, 500),
24 ParentOrigin = ParentOrigin.Center,
25 PivotPoint = PivotPoint.Center,
26 PositionUsesPivotPoint = true,
29 rav.EnableAnimation("idle", true);
31 playButton = new Button()
33 Size = new Size(200, 100),
34 Position = new Position(0, 0),
37 playButton.Clicked += (object source, ClickedEventArgs args) =>
42 stopButton = new Button()
44 Size = new Size(200, 100),
45 Position = new Position(200, 0),
48 stopButton.Clicked += (object source, ClickedEventArgs args) =>
53 bounceButton = new Button()
55 Size = new Size(200, 100),
56 Position = new Position(0, 100),
59 bounceButton.Clicked += (object source, ClickedEventArgs args) =>
61 rav.EnableAnimation("bouncing", true);
64 brokeButton = new Button()
66 Size = new Size(200, 100),
67 Position = new Position(200, 100),
70 brokeButton.Clicked += (object source, ClickedEventArgs args) =>
72 rav.EnableAnimation("broken", true);
75 fillButton = new Button()
77 Size = new Size(200, 100),
78 Position = new Position(0, 200),
81 fillButton.Clicked += (object source, ClickedEventArgs args) =>
83 rav.SetShapeFillColor("grillFillColor", new Color(1.0f, 0.0f, 0.0f, 1.0f));
86 strokeButton = new Button()
88 Size = new Size(200, 100),
89 Position = new Position(200, 200),
92 strokeButton.Clicked += (object source, ClickedEventArgs args) =>
94 rav.SetShapeStrokeColor("grillStrokeColor", new Color(0.0f, 255.0f, 0.0f, 255.0f));
97 opacityButton = new Button()
99 Size = new Size(200, 100),
100 Position = new Position(400, 200),
103 opacityButton.Clicked += (object source, ClickedEventArgs args) =>
105 rav.SetNodeOpacity("front_light", 0.3f);
108 scaleButton = new Button()
110 Size = new Size(200, 100),
111 Position = new Position(0, 300),
114 scaleButton.Clicked += (object source, ClickedEventArgs args) =>
116 rav.SetNodeScale("front_light", new Vector2(2.0f, 2.0f));
119 rotationButton = new Button()
121 Size = new Size(200, 100),
122 Position = new Position(200, 300),
125 rotationButton.Clicked += (object source, ClickedEventArgs args) =>
127 rav.SetNodeRotation("front_light", new Degree(45.0f));
130 positionButton = new Button()
132 Size = new Size(200, 100),
133 Position = new Position(400, 300),
136 positionButton.Clicked += (object source, ClickedEventArgs args) =>
138 rav.SetNodePosition("front_light", new Position(100.0f, -50.0f));
141 defaultLayer.Add(rav);
142 defaultLayer.Add(playButton);
143 defaultLayer.Add(stopButton);
144 defaultLayer.Add(bounceButton);
145 defaultLayer.Add(brokeButton);
146 defaultLayer.Add(fillButton);
147 defaultLayer.Add(strokeButton);
148 defaultLayer.Add(opacityButton);
149 defaultLayer.Add(scaleButton);
150 defaultLayer.Add(rotationButton);
151 defaultLayer.Add(positionButton);
153 public void Deactivate()
155 defaultLayer.Remove(rav);
156 defaultLayer.Remove(playButton);
157 defaultLayer.Remove(stopButton);
158 defaultLayer.Remove(bounceButton);
159 defaultLayer.Remove(brokeButton);
160 defaultLayer.Remove(fillButton);
161 defaultLayer.Remove(strokeButton);
162 defaultLayer.Remove(opacityButton);
163 defaultLayer.Remove(scaleButton);
164 defaultLayer.Remove(rotationButton);
165 defaultLayer.Remove(positionButton);