/
TransformPlaygroundGallery.xaml
172 lines (166 loc) · 8.17 KB
/
TransformPlaygroundGallery.xaml
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Maui.Controls.Sample.Pages.ShapesGalleries.TransformPlaygroundGallery"
Title="Transform Playground">
<ContentPage.Resources>
<ResourceDictionary>
<Style x:Key="PathContainerStyle" TargetType="Grid">
<Setter Property="HeightRequest" Value="200" />
<Setter Property="WidthRequest" Value="200" />
<Setter Property="BackgroundColor" Value="#e5e5e5" />
<Setter Property="HorizontalOptions" Value="Start" />
<Setter Property="VerticalOptions" Value="Start" />
</Style>
<Style x:Key="PathStyle" TargetType="Path">
<Setter Property="HeightRequest" Value="200" />
<Setter Property="WidthRequest" Value="200" />
<Setter Property="Fill" Value="Red" />
<Setter Property="Stroke" Value="Blue" />
<Setter Property="StrokeThickness" Value="4" />
</Style>
<Style x:Key="HeaderStyle" TargetType="Label">
<Setter Property="FontSize" Value="14" />
<Setter Property="Margin" Value="6, 12, 0, 0" />
</Style>
<Style x:Key="ValueStyle" TargetType="Label">
<Setter Property="FontSize" Value="10" />
<Setter Property="Margin" Value="12, 0" />
</Style>
<Style TargetType="Slider">
<Setter Property="ThumbColor" Value="Black" />
<Setter Property="MinimumTrackColor" Value="LightGray" />
<Setter Property="MaximumTrackColor" Value="Gray" />
</Style>
</ResourceDictionary>
</ContentPage.Resources>
<ContentPage.Content>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<!-- PATH -->
<Grid
Style="{StaticResource PathContainerStyle}">
<Path
Style="{StaticResource PathStyle}">
<Path.Data>
<RectangleGeometry
Rect="0, 0, 50, 50" />
</Path.Data>
<Path.RenderTransform>
<TransformGroup>
<RotateTransform
Angle="{Binding Source={x:Reference SliderRotation}, Path=Value}"
CenterX="{Binding Source={x:Reference SliderCenterX}, Path=Value}"
CenterY="{Binding Source={x:Reference SliderCenterY}, Path=Value}" />
<ScaleTransform
ScaleX="{Binding Source={x:Reference SliderScaleX}, Path=Value}"
ScaleY="{Binding Source={x:Reference SliderScaleY}, Path=Value}"
CenterX="{Binding Source={x:Reference SliderCenterX}, Path=Value}"
CenterY="{Binding Source={x:Reference SliderCenterY}, Path=Value}" />
<SkewTransform
AngleX="{Binding Source={x:Reference SliderSkewX}, Path=Value}"
AngleY="{Binding Source={x:Reference SliderSkewY}, Path=Value}"
CenterX="{Binding Source={x:Reference SliderCenterX}, Path=Value}"
CenterY="{Binding Source={x:Reference SliderCenterY}, Path=Value}" />
<TranslateTransform
X="{Binding Source={x:Reference SliderTranslateX}, Path=Value}"
Y="{Binding Source={x:Reference SliderTranslateY}, Path=Value}"/>
</TransformGroup>
</Path.RenderTransform>
</Path>
</Grid>
<!-- TRANSFORMS -->
<ScrollView
Grid.Row="1"
Padding="12">
<StackLayout>
<!-- ROTATE -->
<Label
Text="RotateTransform"
Style="{StaticResource HeaderStyle}"/>
<Label
Text="{Binding Source={x:Reference SliderRotation}, Path=Value, StringFormat='Rotation: {0:F0}'}"
Style="{StaticResource ValueStyle}"/>
<Slider
x:Name="SliderRotation"
Minimum="0"
Maximum="200" />
<Label
Text="{Binding Source={x:Reference SliderCenterX}, Path=Value, StringFormat='CenterX: {0:F0}'}"
Style="{StaticResource ValueStyle}"/>
<Slider
x:Name="SliderCenterX"
Minimum="0"
Maximum="100" />
<Label
Text="{Binding Source={x:Reference SliderCenterY}, Path=Value, StringFormat='CenterY: {0:F0}'}"
Style="{StaticResource ValueStyle}"/>
<Slider
x:Name="SliderCenterY"
Minimum="0"
Maximum="100" />
<!-- SCALE -->
<Label
Text="ScaleTransform"
Style="{StaticResource HeaderStyle}"/>
<Label
Text="{Binding Source={x:Reference SliderScaleX}, Path=Value, StringFormat='ScaleX: {0:F2}'}"
Style="{StaticResource ValueStyle}" />
<Slider
x:Name="SliderScaleX"
Minimum="0.5"
Maximum="2"
Value="1" />
<Label
Text="{Binding Source={x:Reference SliderScaleY}, Path=Value, StringFormat='ScaleY: {0:F2}'}"
Style="{StaticResource ValueStyle}" />
<Slider
x:Name="SliderScaleY"
Minimum="0.5"
Maximum="2"
Value="1" />
<!-- SKEW -->
<Label
Text="SkewTransform"
Style="{StaticResource HeaderStyle}"/>
<Label
Text="{Binding Source={x:Reference SliderSkewX}, Path=Value, StringFormat='SkewX: {0:F0}'}"
Style="{StaticResource ValueStyle}" />
<Slider
x:Name="SliderSkewX"
Minimum="0"
Maximum="100" />
<Label
Text="{Binding Source={x:Reference SliderSkewY}, Path=Value, StringFormat='SkewY: = {0:F0}'}"
Style="{StaticResource ValueStyle}"/>
<Slider
x:Name="SliderSkewY"
Minimum="0"
Maximum="100" />
<!-- TRANSLATE -->
<Label
Text="TranslateTransform"
Style="{StaticResource HeaderStyle}"/>
<Label
Text="{Binding Source={x:Reference SliderTranslateX}, Path=Value, StringFormat='X: {0:F0}'}"
Style="{StaticResource ValueStyle}"/>
<Slider
x:Name="SliderTranslateX"
Minimum="0"
Maximum="200" />
<Label
Text="{Binding Source={x:Reference SliderTranslateY}, Path=Value, StringFormat='Y: {0:F0}'}"
Style="{StaticResource ValueStyle}"/>
<Slider
x:Name="SliderTranslateY"
Minimum="0"
Maximum="200" />
</StackLayout>
</ScrollView>
</Grid>
</ContentPage.Content>
</ContentPage>