728x90
반응형
728x170
▶ MainWindow.xaml
<Window x:Class="TestProject.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:o="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"
Width="800"
Height="600"
Title="Brush 클래스 : RelativeTransform/Transform 속성 사용하기"
FontFamily="나눔고딕코딩"
FontSize="16">
<Window.Resources>
<Style TargetType="{x:Type Rectangle}">
<Setter Property="HorizontalAlignment" Value="Left" />
</Style>
<GradientStopCollection x:Key="GradientStopCollectionKey"
o:Freeze="True">
<GradientStop Offset="0.0" Color="Blue" />
<GradientStop Offset="0.4" Color="Black" />
<GradientStop Offset="0.5" Color="White" />
<GradientStop Offset="0.6" Color="Black" />
<GradientStop Offset="0.7" Color="Blue" />
</GradientStopCollection>
<DrawingGroup x:Key="DrawingGroupKey"
o:Freeze="True">
<GeometryDrawing>
<GeometryDrawing.Geometry>
<GeometryGroup>
<LineGeometry StartPoint="0 0" EndPoint="1 1" />
<LineGeometry StartPoint="0 1" EndPoint="1 0" />
</GeometryGroup>
</GeometryDrawing.Geometry>
<GeometryDrawing.Pen>
<Pen
Thickness="0.2"
Brush="#3366ff" />
</GeometryDrawing.Pen>
</GeometryDrawing>
<GeometryDrawing
Brush="Red"
Geometry="M 0.4 0.4 L 0.5 0.2 0.6 0.4 0.5 0.5" />
<GeometryDrawing
Brush="Blue"
Geometry="M 0.4 0.6 L 0.5 0.8 0.6 0.6 0.5 0.5" />
<GeometryDrawing
Brush="Black"
Geometry="M 0.4 0.4 L 0.2 0.5 0.4 0.6 0.5 0.5" />
<GeometryDrawing
Brush="Green"
Geometry="M 0.6 0.4 L 0.8 0.5 0.6 0.6 0.5 0.5" />
</DrawingGroup>
</Window.Resources>
<ScrollViewer>
<Grid Margin="10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="10" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="10" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="10" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="10" />
<RowDefinition Height="Auto" />
<RowDefinition Height="10" />
<RowDefinition Height="Auto" />
<RowDefinition Height="10" />
<RowDefinition Height="Auto" />
<RowDefinition Height="10" />
<RowDefinition Height="Auto" />
<RowDefinition Height="10" />
<RowDefinition Height="Auto" />
<RowDefinition Height="10" />
<RowDefinition Height="Auto" />
<RowDefinition Height="10" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Grid.Column="2">
변환없음
</TextBlock>
<TextBlock Grid.Row="0" Grid.Column="4">
Brush.RelativeTransform<LineBreak />
Center : 0.5, 0.5<LineBreak />
Angle : 45<LineBreak />
</TextBlock>
<TextBlock Grid.Row="0" Grid.Column="6">
Brush.Transform<LineBreak />
Center : 50, 50<LineBreak />
Angle : 45<LineBreak />
</TextBlock>
<TextBlock Grid.Row="2" Grid.Column="0">
<Bold>LinearGradientBrush</Bold>
</TextBlock>
<Rectangle Grid.Row="2" Grid.Column="2"
Width="100"
Height="100"
Stroke="Black">
<Rectangle.Fill>
<LinearGradientBrush GradientStops="{StaticResource GradientStopCollectionKey}" />
</Rectangle.Fill>
</Rectangle>
<Rectangle Grid.Row="2" Grid.Column="4"
Width="100"
Height="100"
Stroke="Black">
<Rectangle.Fill>
<LinearGradientBrush GradientStops="{StaticResource GradientStopCollectionKey}">
<LinearGradientBrush.RelativeTransform>
<RotateTransform
CenterX="0.5"
CenterY="0.5"
Angle="45" />
</LinearGradientBrush.RelativeTransform>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Rectangle Grid.Row="2" Grid.Column="6"
Width="100"
Height="100"
Stroke="Black">
<Rectangle.Fill>
<LinearGradientBrush GradientStops="{StaticResource GradientStopCollectionKey}">
<LinearGradientBrush.Transform>
<RotateTransform
CenterX="50"
CenterY="50"
Angle="45" />
</LinearGradientBrush.Transform>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<TextBlock Grid.Row="4" Grid.Column="0">
<Bold>RadialGradientBrush</Bold>
</TextBlock>
<Rectangle Grid.Row="4" Grid.Column="2"
Width="100"
Height="100"
Stroke="Black">
<Rectangle.Fill>
<RadialGradientBrush GradientStops="{StaticResource GradientStopCollectionKey}" />
</Rectangle.Fill>
</Rectangle>
<Rectangle Grid.Row="4" Grid.Column="4"
Width="100"
Height="100"
Stroke="Black">
<Rectangle.Fill>
<RadialGradientBrush GradientStops="{StaticResource GradientStopCollectionKey}">
<RadialGradientBrush.RelativeTransform>
<RotateTransform
CenterX="0.5"
CenterY="0.5"
Angle="45" />
</RadialGradientBrush.RelativeTransform>
</RadialGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Rectangle Grid.Row="4" Grid.Column="6"
Width="100"
Height="100"
Stroke="Black">
<Rectangle.Fill>
<RadialGradientBrush GradientStops="{StaticResource GradientStopCollectionKey}">
<RadialGradientBrush.Transform>
<RotateTransform
CenterX="50"
CenterY="50"
Angle="45" />
</RadialGradientBrush.Transform>
</RadialGradientBrush>
</Rectangle.Fill>
</Rectangle>
<TextBlock Grid.Row="6" Grid.Column="0">
<Bold>ImageBrush</Bold><LineBreak />
(Not tiled)
</TextBlock>
<Rectangle Grid.Row="6" Grid.Column="2"
Width="100"
Height="100"
Stroke="Black">
<Rectangle.Fill>
<ImageBrush ImageSource="IMAGE\cherry.jpg" />
</Rectangle.Fill>
</Rectangle>
<Rectangle Grid.Row="6" Grid.Column="4"
Width="100"
Height="100"
Stroke="Black">
<Rectangle.Fill>
<ImageBrush ImageSource="IMAGE\cherry.jpg">
<ImageBrush.RelativeTransform>
<RotateTransform
CenterX="0.5"
CenterY="0.5"
Angle="45" />
</ImageBrush.RelativeTransform>
</ImageBrush>
</Rectangle.Fill>
</Rectangle>
<Rectangle Grid.Row="6" Grid.Column="6"
Width="100"
Height="100"
Stroke="Black">
<Rectangle.Fill>
<ImageBrush ImageSource="IMAGE\cherry.jpg">
<ImageBrush.Transform>
<RotateTransform
CenterX="50"
CenterY="50"
Angle="45" />
</ImageBrush.Transform>
</ImageBrush>
</Rectangle.Fill>
</Rectangle>
<TextBlock Grid.Row="8" Grid.Column="0">
<Bold>ImageBrush</Bold><LineBreak />
(Tiled)
</TextBlock>
<Rectangle Grid.Row="8" Grid.Column="2"
Width="100"
Height="100"
Stroke="Black">
<Rectangle.Fill>
<ImageBrush
Viewport="0 0 0.5 0.5"
TileMode="Tile"
ImageSource="IMAGE\cherry.jpg" />
</Rectangle.Fill>
</Rectangle>
<Rectangle Grid.Row="8" Grid.Column="4"
Width="100"
Height="100"
Stroke="Black">
<Rectangle.Fill>
<ImageBrush
Viewport="0 0 0.5 0.5"
TileMode="Tile"
ImageSource="IMAGE\cherry.jpg">
<ImageBrush.RelativeTransform>
<RotateTransform
CenterX="0.5"
CenterY="0.5"
Angle="45" />
</ImageBrush.RelativeTransform>
</ImageBrush>
</Rectangle.Fill>
</Rectangle>
<Rectangle Grid.Row="8" Grid.Column="6"
Width="100"
Height="100"
Stroke="Black">
<Rectangle.Fill>
<ImageBrush
Viewport="0 0 0.5 0.5"
TileMode="Tile"
ImageSource="IMAGE\cherry.jpg">
<ImageBrush.Transform>
<RotateTransform
CenterX="50"
CenterY="50"
Angle="45" />
</ImageBrush.Transform>
</ImageBrush>
</Rectangle.Fill>
</Rectangle>
<TextBlock Grid.Row="10" Grid.Column="0">
<Bold>DrawingBrush</Bold><LineBreak />
(Not tiled)
</TextBlock>
<Rectangle Grid.Row="10" Grid.Column="2"
Width="100"
Height="100"
Stroke="Black">
<Rectangle.Fill>
<DrawingBrush Drawing="{StaticResource DrawingGroupKey}" />
</Rectangle.Fill>
</Rectangle>
<Rectangle Grid.Row="10" Grid.Column="4"
Width="100"
Height="100"
Stroke="Black">
<Rectangle.Fill>
<DrawingBrush Drawing="{StaticResource DrawingGroupKey}">
<DrawingBrush.RelativeTransform>
<RotateTransform
CenterX="0.5"
CenterY="0.5"
Angle="45" />
</DrawingBrush.RelativeTransform>
</DrawingBrush>
</Rectangle.Fill>
</Rectangle>
<Rectangle Grid.Row="10" Grid.Column="6"
Width="100"
Height="100"
Stroke="Black">
<Rectangle.Fill>
<DrawingBrush Drawing="{StaticResource DrawingGroupKey}">
<DrawingBrush.Transform>
<RotateTransform
CenterX="50"
CenterY="50"
Angle="45" />
</DrawingBrush.Transform>
</DrawingBrush>
</Rectangle.Fill>
</Rectangle>
<TextBlock Grid.Row="12" Grid.Column="0">
<Bold>DrawingBrush</Bold><LineBreak />
(Tiled)
</TextBlock>
<Rectangle Grid.Row="12" Grid.Column="2"
Width="100"
Height="100"
Stroke="Black">
<Rectangle.Fill>
<DrawingBrush
Viewport="0 0 0.5 0.5"
TileMode="Tile"
Drawing="{StaticResource DrawingGroupKey}" />
</Rectangle.Fill>
</Rectangle>
<Rectangle Grid.Row="12" Grid.Column="4"
Width="100"
Height="100"
Stroke="Black">
<Rectangle.Fill>
<DrawingBrush
Viewport="0 0 0.5 0.5"
TileMode="Tile"
Drawing="{StaticResource DrawingGroupKey}">
<DrawingBrush.RelativeTransform>
<RotateTransform
CenterX="0.5"
CenterY="0.5"
Angle="45" />
</DrawingBrush.RelativeTransform>
</DrawingBrush>
</Rectangle.Fill>
</Rectangle>
<Rectangle Grid.Row="12" Grid.Column="6"
Width="100"
Height="100"
Stroke="Black">
<Rectangle.Fill>
<DrawingBrush
Viewport="0 0 0.5 0.5"
TileMode="Tile"
Drawing="{StaticResource DrawingGroupKey}">
<DrawingBrush.Transform>
<RotateTransform
CenterX="50"
CenterY="50"
Angle="45" />
</DrawingBrush.Transform>
</DrawingBrush>
</Rectangle.Fill>
</Rectangle>
</Grid>
</ScrollViewer>
</Window>
728x90
반응형
그리드형(광고전용)
'C# > WPF' 카테고리의 다른 글
[C#/WPF] DrawingBrush 엘리먼트 : GeometryDrawing 객체를 사용해 체크 배경 브러시 만들기 (0) | 2020.08.02 |
---|---|
[C#/WPF] HSV 색상에서 RGB 색상 구하기 (0) | 2020.08.02 |
[C#/WPF] 색상 선택기 사용하기 (0) | 2020.08.02 |
[C#/WPF] LinearGradientBrush 클래스 : 속성 값 변경하기 (0) | 2020.08.01 |
[C#/WPF] LinearGradientBrush 클래스 : 애니메이션 사용하기 (0) | 2020.07.31 |
[C#/WPF] Brush 클래스 : RelativeTransform/Transform 속성 사용하기 (0) | 2020.07.31 |
[C#/WPF] Brushes 클래스 : 미리 정의된 브러시 사용하기 (0) | 2020.07.31 |
[C#/WPF] SolidColorBrush 클래스 : Color/Opacity 속성 애니메이션 설정하기 (0) | 2020.07.31 |
[C#/WPF] SolidColorBrush 클래스 : 서로 다른 표기 방법을 사용해 브러시 색상 표시하기 (0) | 2020.07.31 |
[C#/WPF] SolidColorBrush 엘리먼트 : Opacity 속성을 사용해 투명도 설정하기 (0) | 2020.07.31 |
[C#/WPF] DrawingBrush 엘리먼트 : GeometryDrawing 객체를 사용해 체크 배경 브러시 만들기 (0) | 2020.07.31 |
댓글을 달아 주세요