feat: 12-形状画刷和变换-9LinearGradientBrush

This commit is contained in:
Bunny 2025-01-15 23:36:29 +08:00
parent 4cf80ab768
commit dc96e2a248
8 changed files with 167 additions and 0 deletions

View File

@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<RootNamespace>_12_形状画刷和变换_9LinearGradientBrush</RootNamespace>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<Resource Include="public\003540AH4M72.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
</ItemGroup>
</Project>

View File

@ -0,0 +1,9 @@
<Application x:Class="_12_形状画刷和变换_9LinearGradientBrush.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:_12_形状画刷和变换_9LinearGradientBrush"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>

View File

@ -0,0 +1,12 @@
using System.Configuration;
using System.Data;
using System.Windows;
namespace _12_形状画刷和变换_9LinearGradientBrush;
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}

View File

@ -0,0 +1,10 @@
using System.Windows;
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]

View File

@ -0,0 +1,89 @@
<Window x:Class="_12_形状画刷和变换_9LinearGradientBrush.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Icon="public/003540AH4M72.jpg" Title="12-形状画刷和变换-9LinearGradientBrush" Height="800" Width="800">
<StackPanel>
<StackPanel Margin="30 10" Orientation="Horizontal">
<Rectangle Width="150" Height="100">
<Rectangle.Fill>
<LinearGradientBrush>
<GradientStop Color="Blue" Offset="0" />
<GradientStop Color="White" Offset="1" />
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Label VerticalAlignment="Center"> GradientStop Color="Blue" Offset="0" GradientStop Color="White" Offset="1"</Label>
</StackPanel>
<StackPanel Margin="30 10" Orientation="Horizontal">
<Rectangle Width="150" Height="100">
<Rectangle.Fill>
<LinearGradientBrush>
<GradientStop Color="Red" Offset="0" />
<GradientStop Color="White" Offset="0.5" />
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Label VerticalAlignment="Center"> GradientStop Color="Blue" Offset="0" GradientStop Color="White" Offset="0.5"</Label>
</StackPanel>
<StackPanel Margin="30 10" Orientation="Horizontal">
<Rectangle Width="150" Height="100">
<Rectangle.Fill>
<LinearGradientBrush StartPoint="1,1" EndPoint="0,0">
<GradientStop Color="Gold" Offset="0" />
<GradientStop Color="White" Offset="1" />
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Label VerticalAlignment="Center">StartPoint="1,1" EndPoint="0,0"</Label>
</StackPanel>
<StackPanel Margin="30 10" Orientation="Horizontal">
<Rectangle Width="150" Height="100">
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="Blue" Offset="0" />
<GradientStop Color="White" Offset="1" />
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Label VerticalAlignment="Center">StartPoint="0,0" EndPoint="0,1"</Label>
</StackPanel>
<StackPanel Margin="30 10" Orientation="Horizontal">
<Rectangle Width="150" Height="100">
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,0.5" SpreadMethod="Reflect">
<GradientStop Color="Green" Offset="0" />
<GradientStop Color="White" Offset="1" />
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Label VerticalAlignment="Center"> GradientStop Color="Blue" Offset="0" GradientStop Color="White" Offset="0.5"</Label>
</StackPanel>
<StackPanel Margin="30 10" Orientation="Horizontal">
<Rectangle Width="150" Height="100">
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
<GradientStop Color="Yellow" Offset="0" />
<GradientStop Color="Red" Offset="0.25" />
<GradientStop Color="Blue" Offset="0.75" />
<GradientStop Color="LimeGreen" Offset="1" />
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Label VerticalAlignment="Center">彩虹效果</Label>
</StackPanel>
</StackPanel>
</Window>

View File

@ -0,0 +1,23 @@
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace _12_形状画刷和变换_9LinearGradientBrush;
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

View File

@ -22,6 +22,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "12-形状画刷和变换-7
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "12-形状画刷和变换-8SolidColorBrush", "12-形状画刷和变换-8SolidColorBrush\12-形状画刷和变换-8SolidColorBrush.csproj", "{5982C17D-2565-406E-A989-BA3C74E76B5E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "12-形状画刷和变换-9LinearGradientBrush", "12-形状画刷和变换-9LinearGradientBrush\12-形状画刷和变换-9LinearGradientBrush.csproj", "{1E49BA0D-B480-45DB-A5A0-CBEA0F419222}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -72,5 +74,9 @@ Global
{5982C17D-2565-406E-A989-BA3C74E76B5E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5982C17D-2565-406E-A989-BA3C74E76B5E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5982C17D-2565-406E-A989-BA3C74E76B5E}.Release|Any CPU.Build.0 = Release|Any CPU
{1E49BA0D-B480-45DB-A5A0-CBEA0F419222}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1E49BA0D-B480-45DB-A5A0-CBEA0F419222}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1E49BA0D-B480-45DB-A5A0-CBEA0F419222}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1E49BA0D-B480-45DB-A5A0-CBEA0F419222}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal