php网站后台,电脑淘宝网页版,宿迁装饰网站建设公司排名,今天重大新闻乌克兰在WPF图形体系中#xff0c;Geometry类表示几何图形的基类#xff0c;使用的时候是实例化它的一些子类#xff0c;具体的有#xff1a;
子类介绍#xff1a;
基本几何图形 线段#xff1a;LineGeometry 矩形#xff1a;RectangleGeometry 椭圆#xff1a;EllipseGe…在WPF图形体系中Geometry类表示几何图形的基类使用的时候是实例化它的一些子类具体的有子类介绍基本几何图形线段LineGeometry矩形RectangleGeometry椭圆EllipseGeometry几何图形集合路径集合图形PathGeometry里可以包含一系列几何图形集合常见的有线段 LineSegment弧ArcSegment贝塞尔曲线系列BezierSegment在两个点之间创建一条三次方贝塞尔曲线。PolyBezierSegment创建一系列三次方贝塞尔曲线。PolyQuadraticBezierSegment创建一系列二次贝塞尔曲线。QuadraticBezierSegment创建一条二次贝塞尔曲线。几何图形集合的另一种形式除了这种组合的方式之外系统还提供了一个通过一系列API来绘制的StreamGeometry。它不支持绑定动画相应也更加灵活而高效。复合几何图形使用 GeometryGroup、CombinedGeometry 或者通过调用静态的 Geometry 方法 Combine可以创建复合几何图形对象。它们主要的区别是CombinedGeometry 对子图形进行叠加操作没有面积的子图形将被丢弃。只能组合两个子图形但是这两个子图形也可以是复合几何图形。GeometryGroup 只进行组合而不进行面积叠加。可以添加多个子图形。有关示例请参见如何创建复合形状。CombinedGeometry的叠加方式有四种Union、Intersect、Exclude 和 Xor它们的效果为圈起来的Line Rectangle Ellipse 说的是Shape比较简单可以直接在xaml中显示这里不赘述呈现方式Geometry对象并不能作为图像独立呈现出来它一般有如下几种呈现方式在Path中呈现可以作为GeometryDrawing.Geometry的参数呈现为Path对象以下xaml演示了这一方法基本几何图形Path Grid.Row0 Grid.Column0 StrokeBlue StrokeThickness2 Path.Data LineGeometry StartPoint20,20 EndPoint140,140 / /Path.Data /Path Path Grid.Row0 Grid.Column1 FillYellow StrokeOrange Path.Data RectangleGeometry RadiusX10 RadiusY10 Rect20,20,120,120 / /Path.Data /Path Path Grid.Row1 Grid.Column0 FillLawnGreen StrokeGreen Path.Data EllipseGeometry Center80,80 RadiusX60 RadiusY40 / /Path.Data /Path几何图形集合Path Grid.Row3 Grid.Column1 FillLawnGreen StrokeGreen Path.Data PathGeometry PathGeometry.Figures PathFigure IsClosedTrue StartPoint25,140 !-- 以上一条的终点为起点 -- LineSegment Point20,40 / LineSegment Point40,110 / LineSegment Point50,20 / LineSegment Point80,110 / LineSegment Point110,20 / LineSegment Point120,110 / LineSegment Point140,40 / LineSegment Point135,140 / /PathFigure /PathGeometry.Figures /PathGeometry /Path.Data /Path简写Path Grid.Row3 Grid.Column1 FillLawnGreen StrokeGreen Path.Data PathGeometry FiguresM 25,140 L 20,40 40,110 50,20 80,110 110,20 120,110 140,40 135,140 Z/ /Path.Data /Path继续简写Path Grid.Row3 Grid.Column1 FillLawnGreen StrokeGreen DataM 25,140 L 20,40 40,110 50,20 80,110 110,20 120,110 140,40 135,140 Z/几何图形集合的另一种形式StreamGeometry不支持数据绑定没有什么依赖属性所以在xaml中没什么写的更多是在代码中操作。不过在xaml中可以写成下面的形式Path Grid.Row2 Grid.Column1 StrokeBlack StrokeThickness2 Path.Data StreamGeometryM 10,10 L 100,10 100,100 10,100 Z/StreamGeometry /Path.Data /Path复合几何图形Path Grid.Row3 Grid.Column0 StrokeBlack StrokeThickness2 FillLightBlue Path.Data GeometryGroup !-- 矩形 -- RectangleGeometry Rect10,10,100,50/ !-- 椭圆 -- EllipseGeometry Center60,60 RadiusX40 RadiusY20/ !-- 线条路径 -- PathGeometry PathGeometry.Figures PathFigure StartPoint100,100 LineSegment Point150,50/ LineSegment Point200,100/ /PathFigure /PathGeometry.Figures /PathGeometry !-- 简写线条路径 -- PathGeometry FiguresM 50,120 L 100,80 150,120/ /GeometryGroup /Path.Data /Path在DrawingContext中呈现可以作为DrawingContext. DrawGeometry的参数呈现在GeometryDrawing中呈现可以作为GeometryDrawing.Geometry的参数呈现为Drawing对象图为GeometryDrawing中的属性定义因为继承自Drawing的类不是元素没有继承UIElement类不能将它们放置到用户界面中还需要用于显示图画的类 所以Drawing对象也不能独立呈现一般是作为DrawingBrush或作为DrawingContext.DrawDrawing的参数来使用的直接写在xaml中报错作为DrawingBrushButton Button.Background DrawingBrush StretchFill Viewport0.1 0.1 0.8 0.8 DrawingBrush.Drawing GeometryDrawing BrushRed GeometryDrawing.Pen Pen BrushBlack Thickness0 / /GeometryDrawing.Pen GeometryDrawing.Geometry EllipseGeometry Center50 50 RadiusX10 RadiusY5 / /GeometryDrawing.Geometry /GeometryDrawing /DrawingBrush.Drawing /DrawingBrush /Button.Background /ButtonDrawingContext的DrawDrawing方法接受Drawing对象引用WPF的二维绘图二——几何图形Geometry - MaxBruce - 博客园https://blog.csdn.net/zhudaokuan/article/details/110633190?fromshareblogdetailsharetypeblogdetailsharerId110633190sharereferPCsharesourceqq_59062726sharefromfrom_link