WEB开发网
开发学院图形图像Flash Silverlight(9) - 2.0画笔之SolidColorBrush, Ima... 阅读

Silverlight(9) - 2.0画笔之SolidColorBrush, ImageBrush, VideoBrush, LinearGradientBrush, RadialGradientBrush

 2008-11-14 11:50:38 来源:WEB开发网   
核心提示: 4、LinearGradientBrush.xaml<UserControl x:Class="Silverlight20.Brush.LinearGradientBrush"xmlns="http://schemas.microsoft.com/win

4、LinearGradientBrush.xaml

<UserControl x:Class="Silverlight20.Brush.LinearGradientBrush"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <StackPanel HorizontalAlignment="Left">
    <Grid Margin="10">
      <Rectangle Width="200" Height="100" HorizontalAlignment="Left">
        <Rectangle.Fill>
  
          <!--LinearGradientBrush - 线性渐变画笔-->
          <!--
          StartPoint - 线性渐变的起点。默认渐变方向为对角线方向,默认值为左上角0,0
          EndPoint - 线性渐变的终点。默认渐变方向为对角线方向,默认值为右下角1,1
          GradientStop - 渐变中,过渡点的设置
            GradientStop.Color - 过渡点的颜色
            GradientStop.Offset - 过渡点的位置。相对于渐变线的比值。最小值0.0(默认值),最大值1.0
          ColorInterpolationMode - 插入渐变颜色的方式 [System.Windows.Media.ColorInterpolationMode枚举]
            ColorInterpolationMode.ScRgbLinearInterpolation - scRGB
            ColorInterpolationMode.SRgbLinearInterpolation - sRGB。默认值
          -->
          <LinearGradientBrush StartPoint="0,0" EndPoint="1,1" ColorInterpolationMode="SRgbLinearInterpolation">
            <GradientStop Color="Red" Offset="0.0" />
            <GradientStop Color="Green" Offset="0.25" />
            <GradientStop Color="Blue" Offset="0.75" />
            <GradientStop Color="Yellow" Offset="1.0" />
          </LinearGradientBrush>
  
        </Rectangle.Fill>
      </Rectangle>
      <Line X1="0" Y1="0" X2="200" Y2="100" Stroke="Black" HorizontalAlignment="Left" />
    </Grid>
  
    <Grid Margin="10">
      <Rectangle Width="200" Height="100" HorizontalAlignment="Left">
        <Rectangle.Fill>
  
          <!--
          MappingMode - 指定线性渐变的起点(StartPoint)和终点(EndPoint)相对于输出区域是相对的还是绝对的 [System.Windows.Media.BrushMappingMode枚举]
            MappingMode.RelativeToBoundingBox - 相对坐标。默认值
            MappingMode.Absolute - 绝对坐标
          -->
          <LinearGradientBrush StartPoint="0,0" EndPoint="200,100" MappingMode="Absolute">
            <GradientStop Color="Red" Offset="0.0" />
            <GradientStop Color="Green" Offset="0.25" />
            <GradientStop Color="Blue" Offset="0.75" />
            <GradientStop Color="Yellow" Offset="1.0" />
          </LinearGradientBrush>
  
        </Rectangle.Fill>
      </Rectangle>
      <Line X1="0" Y1="0" X2="200" Y2="100" Stroke="Black" HorizontalAlignment="Left" />
    </Grid>
  
    <Grid Margin="10">
      <Rectangle Width="200" Height="100" HorizontalAlignment="Left">
        <Rectangle.Fill>
  
          <!--
          SpreadMethod - 线性渐变线(黑色线)之外, 输出区域之内的渐变方式 [System.Windows.Media.GradientSpreadMethod枚举]
            GradientSpreadMethod.Pad - 用线性渐变线末端的颜色值填充剩余空间。默认值   
          -->
          <LinearGradientBrush StartPoint="0.4,0.5" EndPoint="0.6,0.5" SpreadMethod="Pad">
            <GradientStop Color="Red" Offset="0.0" />
            <GradientStop Color="Green" Offset="1.0" />
          </LinearGradientBrush>
  
        </Rectangle.Fill>
      </Rectangle>
      <Line X1="80" Y1="50" X2="120" Y2="50" Stroke="Black" HorizontalAlignment="Left" />
    </Grid>
  
    <Grid Margin="10">
      <Rectangle Width="200" Height="100" HorizontalAlignment="Left">
        <Rectangle.Fill>
  
          <!--
          SpreadMethod - 线性渐变线(黑色线)之外, 输出区域之内的渐变方式 [System.Windows.Media.GradientSpreadMethod枚举]
            GradientSpreadMethod.Reflect - 相邻填充区域,以 相反方向 重复渐变,直至填充满整个剩余空间
          -->
          <LinearGradientBrush StartPoint="0.4,0.5" EndPoint="0.6,0.5" SpreadMethod="Reflect">
            <GradientStop Color="Red" Offset="0.0" />
            <GradientStop Color="Green" Offset="1.0" />
          </LinearGradientBrush>
  
        </Rectangle.Fill>
      </Rectangle>
      <Line X1="80" Y1="50" X2="120" Y2="50" Stroke="Black" HorizontalAlignment="Left" />
    </Grid>
    
    <Grid Margin="10">
      <Rectangle Width="200" Height="100" HorizontalAlignment="Left">
        <Rectangle.Fill>
  
          <!--
          SpreadMethod - 线性渐变线(黑色线)之外, 输出区域之内的渐变方式 [System.Windows.Media.GradientSpreadMethod枚举]
            GradientSpreadMethod.Repeat - 相邻填充区域,以 相同方向 重复渐变,直至填充满整个剩余空间
          -->
          <LinearGradientBrush StartPoint="0.4,0.5" EndPoint="0.6,0.5" SpreadMethod="Repeat">
            <GradientStop Color="Red" Offset="0.0" />
            <GradientStop Color="Green" Offset="1.0" />
          </LinearGradientBrush>
  
        </Rectangle.Fill>
      </Rectangle>
      <Line X1="80" Y1="50" X2="120" Y2="50" Stroke="Black" HorizontalAlignment="Left" />
    </Grid>
  </StackPanel>
</UserControl>

上一页  1 2 3 4 5  下一页

Tags:Silverlight 画笔 SolidColorBrush

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接