2 * Copyright(c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 using Tizen.NUI.BaseComponents;
18 using Tizen.NUI.Components;
21 namespace NUITizenGallery
23 public partial class BrushBackgroundTestPage : ContentPage
25 public BrushBackgroundTestPage()
27 InitializeComponent();
29 ButtonSolid.Clicked += OnClickedSolid;
30 ButtonGradientLinear.Clicked += OnClickedLinear;
31 ButtonGradientRadial.Clicked += OnClickedRadial;
34 public void OnClickedSolid(object sender, ClickedEventArgs args)
36 ContentView.BackgroundColor = Color.Red;
39 public void OnClickedLinear(object sender, ClickedEventArgs args)
41 PropertyArray stopColor = new PropertyArray();
42 stopColor.Add(new PropertyValue(new Vector4(255.0f, 0.0f, 0.0f, 255.0f) / 255.0f));
43 stopColor.Add(new PropertyValue(new Vector4(0.0f, 255.0f, 0.0f, 255.0f) / 255.0f));
45 GradientVisual linearGradient = new GradientVisual();
46 linearGradient.StopColor = stopColor;
47 linearGradient.StartPosition = new Vector2(0.0f, 0.0f);
48 linearGradient.EndPosition = new Vector2(0.3f, 0.3f);
49 linearGradient.Origin = Visual.AlignType.TopBegin;
51 ContentView.Background = linearGradient.OutputVisualMap;
54 public void OnClickedRadial(object sender, ClickedEventArgs args)
56 PropertyArray stopColor = new PropertyArray();
57 stopColor.Add(new PropertyValue(new Vector4(255.0f, 0.0f, 0.0f, 255.0f) / 255.0f));
58 stopColor.Add(new PropertyValue(new Vector4(0.0f, 255.0f, 0.0f, 255.0f) / 255.0f));
60 GradientVisual radialGradient = new GradientVisual();
61 radialGradient.Center = new Vector2(0.0f, 0.0f);
62 radialGradient.Radius = 0.5f;
63 radialGradient.StopColor = stopColor;
64 radialGradient.Origin = Visual.AlignType.TopBegin;
66 ContentView.Background = radialGradient.OutputVisualMap;