我有一些高度相同的矩形。但我填补了他们不同的颜色。我可以结合他们,因为我得到Rectangle
?我可以用RectangleGeometry
做到这一点,但我需要Rectangle
类型有没有机会将矩形合并到一个矩形?
1
A
回答
3
如何组合颜色?
你只是想指定重叠,但使用不同的颜色与透明度级别,这样的颜色混合在一起2个矩形区域?
还是你想的矩形细分,并在不同的区域用不同的颜色?
是否有你需要保持它作为一个矩形的理由?
下面就来保持它作为一个矩形,但指定2种颜色组合/混合作为填充方式:
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
<Rectangle Width="100" Height="100">
<Rectangle.Fill>
<DrawingBrush Viewport="0,0,1,1" TileMode="Tile">
<DrawingBrush.Drawing>
<DrawingGroup>
<GeometryDrawing>
<GeometryDrawing.Geometry>
<RectangleGeometry Rect="0,0,1,1" />
</GeometryDrawing.Geometry>
<GeometryDrawing.Brush>
<SolidColorBrush Color="Red" Opacity="1"/>
</GeometryDrawing.Brush>
</GeometryDrawing>
<GeometryDrawing>
<GeometryDrawing.Geometry>
<RectangleGeometry Rect="0,0,1,1" />
</GeometryDrawing.Geometry>
<GeometryDrawing.Brush>
<SolidColorBrush Color="White" Opacity=".5"/>
</GeometryDrawing.Brush>
</GeometryDrawing>
</DrawingGroup>
</DrawingBrush.Drawing>
</DrawingBrush>
</Rectangle.Fill>
</Rectangle>
</Grid>
</Page>
或者这一个细分矩形:
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
<Rectangle Width="100" Height="100">
<Rectangle.Fill>
<DrawingBrush Viewport="0,0,1,1" TileMode="None">
<DrawingBrush.Drawing>
<DrawingGroup>
<GeometryDrawing>
<GeometryDrawing.Geometry>
<RectangleGeometry Rect="0,0,1,1" />
</GeometryDrawing.Geometry>
<GeometryDrawing.Brush>
<SolidColorBrush Color="Yellow"/>
</GeometryDrawing.Brush>
</GeometryDrawing>
<GeometryDrawing>
<GeometryDrawing.Geometry>
<RectangleGeometry Rect="0,0,0.5,0.5" />
</GeometryDrawing.Geometry>
<GeometryDrawing.Brush>
<SolidColorBrush Color="Red"/>
</GeometryDrawing.Brush>
</GeometryDrawing>
<GeometryDrawing>
<GeometryDrawing.Geometry>
<RectangleGeometry Rect="0.5,0.5,0.5,0.5" />
</GeometryDrawing.Geometry>
<GeometryDrawing.Brush>
<SolidColorBrush Color="Green"/>
</GeometryDrawing.Brush>
</GeometryDrawing>
<GeometryDrawing>
<GeometryDrawing.Geometry>
<RectangleGeometry Rect="0.25,0.25,0.25,0.25" />
</GeometryDrawing.Geometry>
<GeometryDrawing.Brush>
<SolidColorBrush Color="Blue"/>
</GeometryDrawing.Brush>
</GeometryDrawing>
</DrawingGroup>
</DrawingBrush.Drawing>
</DrawingBrush>
</Rectangle.Fill>
</Rectangle>
</Grid>
</Page>
(move the brush descr如果你打算在多个地方使用它,并且/或者为矩形创建一个新的样式,则由DrawingBrush加入到Resources中。
矩形是密封的,因此它可以被覆盖,所以你不能更改模板它不是一个控制。
你可能要考虑做自己的“形状”,这样就可以更好地封装“你的”矩形的增强行为。
下面就来让你开始了一个例子。
+0
让我以另一种方式说。我有'List
相关问题
- 1. 没有矩形形成的矩形
- 2. 矩形有一个斜边
- 3. GetWindowRect()没有返回一个矩形
- 4. CGContextFillRect没有绘制一个矩形?
- 5. java如何将多个矩形合并为一个多边形
- 6. 矩形约束没有内
- 7. 矩形没有出现
- 8. 将矩形位置绑定到另一个矩形
- 9. 另一个矩形内的矩形
- 10. 将矩形添加到列表中并显示矩形
- 11. 没有背景的android圆角矩形直边矩形
- 12. 将矩形UIImageView变成一个圆形
- 13. 得到一个矩形
- 14. 给出一个矩形列表,如何找到完全包含在其他矩形内的所有矩形?
- 15. 将一个矩形映射到另一个矩形,包括旋转
- 16. HTML5画布合并到矩形以形成新形状
- 17. 将一个矩形矩阵绘制成圆形
- 18. kineticjs将矩形卡入另一个矩形
- 19. 将DataContext绑定到一个矩形
- 20. 谷歌地图将矩形合并为一个多边形并搜索它
- 21. drawBitmap有问题 - 有源矩形和目标矩形
- 22. Houghlines没有检测到一个简单的矩形的顶线
- 23. 仅有一个边框的矩形
- 24. 将许多矩形组合成更少的矩形
- 25. 快速矩形到矩形相交
- 26. 有没有办法创建一个非矩形的UIButton?
- 27. 发现,一个矩形触及另一个矩形
- 28. 将n个L&W的矩形拟合成n个可能的大矩形
- 29. 绘制矩形,并看到它批次没有任何纹理
- 30. 在mousemove上绘制一个矩形并使用kineticjs在mouseup上选择该矩形内的所有形状?
你想[Rectangle类](http://msdn.microsoft.com/en-us/library/system.windows.shapes.rectangle)或[矩形结构]( http://msdn.microsoft.com/en-us/library/system.drawing.rectangle.aspx)? – LPL
长方形课程当然 – Rabi