LinearGradientBrush的使用

来源:互联网 发布:淘宝客的文案 编辑:程序博客网 时间:2024/05/17 08:55

     LinearGradientBrush是倾斜的画笔

     通过GradientStop来设置有几个颜色点,GradientStop有Color  Offset两个属性,color 是设置这个点的颜色的,Offset是设置位移的。这个位移是相对的,通过LinearGradientBrush 的StartPoint, EndPoint来设置总的长度。

例如

<Rectangle Width="200" Height="100">

     <Rectangle.Fill>

         <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">

               <GradientStop Color="Yellow" Offset="0.0" />

               <GradientStop Color="Red" Offset="0.25" />

               <GradientStop Color="Blue" Offset="0.75" />

               <GradientStop Color="LimeGreen" Offset="1.0" />

        </LinearGradientBrush>

     </Rectangle.Fill>

</Rectangle>

2.

   SolidColorBrush是实心的画刷,如

<Rectangle Width="100" Height="100">
        <Rectangle.Fill>
           <SolidColorBrush Color="Red" />
       </Rectangle.Fill>
 </Rectangle>

将以红色填充这个矩形。

原创粉丝点击