除了单色,渐变画刷外,也可以使用图像作为模式(Pattern)画刷来填充图形。
下面的例子使用两个PNG图像来填充图形。
private voID Patterns(){ TextureBrush brush1; TextureBrush brush2; TextureBrush brush3; Affinetransform matrix1 = new Affinetransform(); Affinetransform matrix2 = new Affinetransform(); BitmAPImage img = new BitmAPImage(); img.CreateOptions = BitmapCreateOptions.None; string path = "/SilverlightGraphics2DDemo;component/brick.png"; Stream s = Application.GetResourceStream (new Uri(path,UriKind.relative)).Stream; img.SetSource(s); WriteableBitmap writeableBitmap = new WriteableBitmap(img); brush1 = new TextureBrush(writeableBitmap.Pixels,img.PixelWIDth,img.PixelHeight); path = "/SilverlightGraphics2DDemo;component/bird.png"; s = Application.GetResourceStream(new Uri(path,UriKind.relative)).Stream; img.SetSource(s); writeableBitmap = new WriteableBitmap(img); brush2 = new TextureBrush(writeableBitmap.Pixels,img.PixelHeight); brush3 = new TextureBrush(writeableBitmap.Pixels,img.PixelHeight,127); matrix2.Translate(50,50); graphics2D.Clear(color.White); graphics2D.Affinetransform = (matrix1); graphics2D.FillRectangle(brush1,new Rectangle(20,50,100,100)); graphics2D.Filloval(brush2,10,80,80); graphics2D.Affinetransform = (matrix2); graphics2D.Filloval(brush3,80); }
这个例子所用的brick.png 和bird.png,brush3是半透明画刷。
总结以上是内存溢出为你收集整理的Silverlight 引路蜂二维图形库示例:材质画刷全部内容,希望文章能够帮你解决Silverlight 引路蜂二维图形库示例:材质画刷所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)