zoukankan      html  css  js  c++  java
  • WPF 2D绘图(2)Geometry

    Shape是对Geometry的一种封装,Shape本质上还是通过绘制Geometry的形状,然后以填充笔刷来呈现效果

    image

    如Rectangle

              <Path Stroke="Black" StrokeThickness="1" Fill="#CCCCFF">
                <Path.Data>
                  <RectangleGeometry Rect="30,55 100 30" />
                </Path.Data>
              </Path>
    
    <Rectangle Stroke="Black" StrokeThickness="1" Fill="#CCCCFF" Width="100" Height="30"></Rectangle>
    

    这两者是等价的

    Rectangle 是对RectangleGeometry 的封装实现,Rectangle 布局内部将会重写,所以封装了起始点

    Geometry(没有笔刷的透明形状)本身无法呈现,必须放在Path容器中才可以

    同样的其他的shape也对应Geometry,如果没有的话则以PathGeometry表示.

    GeometryGroup

    可以同时将多个Geometry放在一起成为一个新的图形

              <Path Stroke="Black" StrokeThickness="1" Fill="#CCCCFF">
                <Path.Data>
                  <GeometryGroup FillRule="Nonzero">
                    <LineGeometry StartPoint="10,10" EndPoint="50,30" />
                    <EllipseGeometry Center="40,70" RadiusX="30" RadiusY="30" />              
                    <RectangleGeometry Rect="30,55 100 30" />
                  </GeometryGroup>
                </Path.Data>
              </Path>
    

    好比Path是一张画布,代表着一个FrameworkElement。如果使用Shape的话,则需要三个FrameworkElement,这是对性能的挑战.FrameworkElement多的话将会大大降低程序的性能,这时还得采用传统的绘图方法.

    即Shape依赖于Geometry

    1000个Shape会产生1000个Geometry,但1000个Geometry可以放在1个Shape中,性能不言而喻了

  • 相关阅读:
    jumpserver的安装
    安装iostat 命令
    zabbix配置server,proxy,agent架构
    RGB颜色对照表
    【ZYNQ-7000开发之九】使用VDMA在PL和PS之间传输视频流数据
    基于AXI VDMA的图像采集系统
    图像采集调试总结
    DDR3调试总结
    内存系列二:深入理解硬件原理
    在嵌入式设计中使用MicroBlaze(Vivado版本)
  • 原文地址:https://www.cnblogs.com/Clingingboy/p/1885124.html
Copyright © 2011-2022 走看看