稳扎稳打Silverlight(9) - 2.0画笔之SolidColorBrush, ImageBrush, VideoBrush, LinearGradientBrush

稳扎稳打Silverlight(9) - 2.0画笔之SolidColorBrush, ImageBrush, VideoBrush, LinearGradientBrush,第1张

概述[索引页] [源码下载] 稳扎稳打Silverlight(9) - 2.0画笔之SolidColorBrush, ImageBrush, VideoBrush, LinearGradientBrush, RadialGradientBrush 作者: webabcd 介绍 Silverlight 2.0 画笔:     SolidColorBrush - 单色画笔     ImageBrush - [索引页]
[源码下载]


稳扎稳打Silverlight(9) - 2.0画笔之SolIDcolorBrush,ImageBrush,VIDeoBrush,linearGradIEntBrush,RadialGradIEntBrush

作者: webabcd


介绍
Silverlight 2.0 画笔:
    SolIDcolorBrush - 单色画笔
    ImageBrush - 图像画笔
    VIDeoBrush - 视频画笔
    linearGradIEntBrush - 线性渐变画笔
    RadialGradIEntBrush - 放射性渐变画笔


在线DEMO
http://www.voidcn.com/article/p-ounmxjds-tq.html

示例
1、SolIDcolorBrush.xaml <UserControl x:Class="Silverlight20.Brush.solIDcolorBrush"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"    
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
        <StackPanel HorizontalAlignment="left">
                <Ellipse margin="10" WIDth="200" Height="100" stroke="Yellow" strokeThickness="3">
                        <Ellipse.Fill>

                                <!--SolIDcolorBrush - 单色画笔-->
                                <!--
                                color - 颜色
                                        格式如下:
                                                预定义的color的名称。如:Red,Green,Blue
                                                #RGB。如:#F00
                                                #ARGB(A为Alpha值)。如:#FF00,#F0F0,#F00F
                                                #RGB。如:#FF0000,#00FF00,#0000FF
                                                #ARGB(A为Alpha值)。如:#FFFF0000,#FF00FF00,#FF0000FF
                                Opacity - 不透明度。0 - 1之间
                                -->
                                <SolIDcolorBrush color="#FF0000" Opacity="0.5"    />

                        </Ellipse.Fill>
                </Ellipse>
                
                <Ellipse margin="10" WIDth="200" Height="100" stroke="Yellow" strokeThickness="3">
                        <Ellipse.Fill>

                                <SolIDcolorBrush color="#88FF0000" />

                        </Ellipse.Fill>
                </Ellipse>
        </StackPanel>
</UserControl>     2、ImageBrush.xaml
<UserControl x:Class="Silverlight20.Brush.ImageBrush"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"    
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
        <StackPanel HorizontalAlignment="left">
                <Rectangle WIDth="100" Height="100" stroke="Red" strokeThickness="1">
                        <Rectangle.Fill>
                        
                                <!--ImageBrush - 图像画笔-->
                                <!--
                                ImageSource - 图片地址
                                Stretch属性 - 拉伸值 [System.windows.Media.Stretch 枚举]。参见:本Demo的Shape/Shape.xaml
                                AlignmentX - 水平方向的对齐方式。Center(默认值),left,Right
                                AlignmentY - 垂直方向的对齐方式。Center(默认值),top,Bottom
                                -->
                                <ImageBrush ImageSource="/Silverlight20;component/Images/logo.jpg" AlignmentX="Right" AlignmentY="Bottom" Stretch="None" />
                                
                        </Rectangle.Fill>
                </Rectangle>
        </StackPanel>
</UserControl>     3、VIDeoBrush.xaml
<UserControl x:Class="Silverlight20.Brush.VIDeoBrush"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"    
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
        <StackPanel HorizontalAlignment="left">
        
                <MediaElement x:name="mediaElement" Source="/Silverlight20;component/VIDeo/Demo.wmv" WIDth="0" Height="0" />

                <Rectangle WIDth="300" Height="100">
                        <Rectangle.Fill>

                                <!--VIDeoBrush - 视频画笔-->
                                <!--
                                Sourcename - 相关的 MediaElement 的名称
                                Stretch属性 - 拉伸值 [System.windows.Media.Stretch 枚举]。参见:本Demo的Shape/Shape.xaml
                                AlignmentX - 水平方向的对齐方式。Center(默认值),Right
                                AlignmentY - 垂直方向的对齐方式。Center(默认值),Bottom
                                -->
                                <VIDeoBrush Sourcename="mediaElement" />

                        </Rectangle.Fill>
                </Rectangle>
                
        </StackPanel>
</UserControl>     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" 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" 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>     5、RadialGradIEntBrush.xaml
<UserControl x:Class="Silverlight20.Brush.RadialGradIEntBrush"
        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" VerticalAlignment="top">
                                <Rectangle.Fill>

                                        <!--linearGradIEntBrush - 放射性渐变画笔-->
                                        <!--
                                        GradIEntOrigin - 放射性渐变的 放射源的 原点坐标。默认值0.5,0.5
                                        Center - 放射性渐变的 填充范围(红色圆圈部分)的 原点坐标。默认值0.5,0.5
                                        GradIEntStop - 渐变中,过渡点的设置。参见:Brush/linearGradIEntBrush.xaml
                                        colorInterpolationMode - 插入渐变颜色的方式 [System.windows.Media.colorInterpolationMode枚举]。参见:Brush/linearGradIEntBrush.xaml
                                        SpreadMethod - 线性渐变线之外, 输出区域之内的渐变方式 [System.windows.Media.GradIEntSpreadMethod枚举]。。参见:Brush/linearGradIEntBrush.xaml
                                        -->
                                        <RadialGradIEntBrush GradIEntOrigin="0.5,0.5" Center="0.5,0.5">
                                                <GradIEntStop color="Red" Offset="0.0" />
                                                <GradIEntStop color="Green" Offset="0.25" />
                                                <GradIEntStop color="Blue" Offset="0.75" />
                                                <GradIEntStop color="Yellow" Offset="1.0" />
                                        </RadialGradIEntBrush>

                                </Rectangle.Fill>
                        </Rectangle>
                        <Path stroke="Red" strokeThickness="1" HorizontalAlignment="left" VerticalAlignment="top">
                                <Path.Data>
                                        <EllipseGeometry Center="100,50" RadiusX="100" RadiusY="50" />
                                </Path.Data>
                        </Path>
                </GrID>

                <GrID margin="10">
                        <Rectangle WIDth="200" Height="100" HorizontalAlignment="left" VerticalAlignment="top">
                                <Rectangle.Fill>

                                        <!--
                                        RadiusX - 填充范围的 X 轴半径。默认值0.5
                                        RadiusY - 填充范围的 Y 轴半径。默认值0.5
                                        -->
                                        <RadialGradIEntBrush GradIEntOrigin="0.3,0.3" Center="0.7,0.7" RadiusX="0.6" RadiusY="0.6">
                                                <GradIEntStop color="Red" Offset="0.0" />
                                                <GradIEntStop color="Green" Offset="0.25" />
                                                <GradIEntStop color="Blue" Offset="0.75" />
                                                <GradIEntStop color="Yellow" Offset="1.0" />
                                        </RadialGradIEntBrush>

                                </Rectangle.Fill>
                        </Rectangle>
                        <Path stroke="Red" strokeThickness="1" HorizontalAlignment="left" VerticalAlignment="top">
                                <Path.Data>
                                        <EllipseGeometry Center="140,70" RadiusX="120" RadiusY="60" />
                                </Path.Data>
                        </Path>
                </GrID>

                <GrID margin="10">
                        <Rectangle WIDth="200" Height="100" HorizontalAlignment="left" VerticalAlignment="top">
                                <Rectangle.Fill>
                                
                                        <!--
                                        MapPingMode - 指定线性渐变的起点(StartPoint)、终点(EndPoint)填充范围的 X 轴半径(RadiusX)和填充范围的 Y 轴半径(RadiusY)相对于输出区域是相对的还是绝对的 [System.windows.Media.BrushMapPingMode枚举]
                                                MapPingMode.relativeToBoundingBox - 相对坐标。默认值
                                                MapPingMode.absolute - 绝对坐标
                                        -->
                                        <RadialGradIEntBrush MapPingMode="absolute" GradIEntOrigin="60,30" Center="140,70" RadiusX="120" RadiusY="60">
                                                <GradIEntStop color="Red" Offset="0.0" />
                                                <GradIEntStop color="Green" Offset="0.25" />
                                                <GradIEntStop color="Blue" Offset="0.75" />
                                                <GradIEntStop color="Yellow" Offset="1.0" />
                                        </RadialGradIEntBrush>

                                </Rectangle.Fill>
                        </Rectangle>
                        <Path stroke="Red" strokeThickness="1" HorizontalAlignment="left" VerticalAlignment="top">
                                <Path.Data>
                                        <EllipseGeometry Center="140,70" RadiusX="120" RadiusY="60" />
                                </Path.Data>
                        </Path>
                </GrID>
        </StackPanel>
</UserControl>     OK
[源码下载]
总结

以上是内存溢出为你收集整理的稳扎稳打Silverlight(9) - 2.0画笔之SolidColorBrush, ImageBrush, VideoBrush, LinearGradientBrush全部内容,希望文章能够帮你解决稳扎稳打Silverlight(9) - 2.0画笔之SolidColorBrush, ImageBrush, VideoBrush, LinearGradientBrush所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1053104.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存