深入浅出WPF-12.绘图与动画

绘图

1)Brush(画刷)

  • SolidColorBrush实心画刷,直接使用颜色赋值

  • LinearGradientBrush线性渐变画刷,色彩沿设定的直线方向、按设定的变化点进行渐变

  • RadialGradientBrush径向渐变画刷,色彩沿半径的方向,按设定的变化点进行渐变,形成圆形填充

  • ImageBrush使用图片Image作为填充内容

  • DrawingBrush使用矢量图Vector和位图Bitmap作为填充内容

  • VisualBrush:WPF中每个控件都是由FrameworkElement类派生来的,而FrameworkElement是由Visual类派生来的。每个控件的可视化形象就可以通过Visual类的方法来获得。获得这个可视化的形象之后,我们可以使用这个形象进行填充,这就是VisualBrush。比如我们想把窗体上的某个控件拖拽到另一个位置,当鼠标松开之前需要再鼠标指针下显示一个控件的幻影,这个幻影就用VisualBrush填充出来的一个矩形,并让矩形捕获鼠标的位置、随鼠标移动。

    <DrawingBrush
            x:Key="CloudDrawingBrush"
            o:Freeze="True"
            Opacity=".1"
            RenderOptions.CacheInvalidationThresholdMaximum="2.0"
            RenderOptions.CacheInvalidationThresholdMinimum="0.5"
            RenderOptions.CachingHint="Cache"
            Stretch="Uniform"
            TileMode="Tile"
            Viewport="0,0,314,157"
            ViewportUnits="Absolute">
            <DrawingBrush.Drawing>
                <DrawingGroup o:Freeze="True">
                    <ImageDrawing ImageSource="/LpbPrj.Client.UI.Demo;component/Resources/Img/cloud.png" Rect="0,0,314,157" />
                </DrawingGroup>
            </DrawingBrush.Drawing>
        </DrawingBrush>
    

2)Path(路径)

路径是WPF回途中最强大的工作,完全可以替代其他图形,也可以将简单的基本元素结合起来形成复杂的图像。路径的最重要属性就是Data,Data的数据类型是Geometry(几何图形)。这里我建议使用PS和Blend相结合的方法实现Path。可以参考:http://www.mikeswanson.com/XAMLExport/

<Geometry x:Key="NewGeometry" o:Freeze="True">M512 0h1216a512 512 0 1 1 0 1024H512A512 512 0 1 1 512 0zM420.16 311.04V768h74.88V433.92h2.56l228.48 334.08h72.96V311.04h-75.52v329.6h-2.56l-225.92-329.6h-74.88z m468.48 0V768h340.48v-64h-265.6V565.76h239.36v-64h-239.36V375.04h254.72v-64h-329.6z m369.28 0l131.2 456.96h80l89.6-343.68h2.56l88.96 343.68h79.36l131.84-456.96h-84.48l-85.76 347.52h-2.56l-90.24-347.52h-77.44l-90.24 347.52h-2.56l-85.76-347.52h-84.48z</Geometry>
    <Geometry x:Key="LogoGeometry" o:Freeze="True">M40.493382,19.001303 C36.637875,19.06448 33.938568,21.421986 33.948524,25.271919 L34.068279,71.56765 34.066906,71.598007 34.068745,71.747833 34.18895,118.21758 C34.202225,123.35083 39.026951,129.19344 44.965271,131.2674 50.903587,133.34137 55.706783,130.86133 55.693504,125.72808 L55.589508,85.524513 93.866371,85.524513 93.950943,118.21758 C93.964218,123.35083 98.788948,129.19344 104.72726,131.2674 110.66558,133.34137 115.46878,130.86133 115.4555,125.72808 L115.33575,79.432381 115.33712,79.401993 115.33528,79.252007 115.21507,32.782413 C115.2018,27.64917 110.37708,21.806566 104.43876,19.732603 98.500435,17.658638 93.697243,20.138674 93.710518,25.271919 L93.814514,65.475487 55.537647,65.475487 55.453079,32.782413 C55.439804,27.64917 50.615082,21.806566 44.676762,19.732603 43.192181,19.214111 41.778549,18.980244 40.493382,19.001303 z M9.999999,0 L140,0 C145.52284,0 150,4.4771523 150,9.999999 L150,140 C150,145.52284 145.52284,150 140,150 L9.999999,150 C4.4771523,150 0,145.52284 0,140 L0,9.999999 C0,4.4771523 4.4771523,0 9.999999,0 z</Geometry>
    <Geometry x:Key="CirclePanelDemoGeometry" o:Freeze="True">M28.677037,-2.2499313E-22 C38.75065,24.740243 38.50705,52.437974 27.999852,77.000001 L-1.7053028E-13,65.206651 C7.3550318,48.013234 7.5255431,28.624822 0.4740567,11.306663 z</Geometry>
    <Geometry x:Key="CirclePanelRightGeometry" o:Freeze="True">M267.287478 892.162257c0 45.149912 59.597884 71.336861 93.008818 37.925926L740.458554 549.925926c21.671958-21.671958 21.671958-54.179894 0-75.851852L360.296296 93.911817c-33.410935-33.410935-93.008818-5.417989-93.008818 38.828924v759.421516z m0 0</Geometry>
    <Geometry x:Key="GithubGeometry" o:Freeze="True">M512 0C229.12 0 0 229.12 0 512c0 226.56 146.56 417.92 350.08 485.76 25.6 4.48 35.2-10.88 35.2-24.32 0-12.16-0.64-52.48-0.64-95.36-128.64 23.68-161.92-31.36-172.16-60.16-5.76-14.72-30.72-60.16-52.48-72.32-17.92-9.6-43.52-33.28-0.64-33.92 40.32-0.64 69.12 37.12 78.72 52.48 46.08 77.44 119.68 55.68 149.12 42.24 4.48-33.28 17.92-55.68 32.64-68.48-113.92-12.8-232.96-56.96-232.96-252.8 0-55.68 19.84-101.76 52.48-137.6-5.12-12.8-23.04-65.28 5.12-135.68 0 0 42.88-13.44 140.8 52.48 40.96-11.52 84.48-17.28 128-17.28 43.52 0 87.04 5.76 128 17.28 97.92-66.56 140.8-52.48 140.8-52.48 28.16 70.4 10.24 122.88 5.12 135.68 32.64 35.84 52.48 81.28 52.48 137.6 0 196.48-119.68 240-233.6 252.8 18.56 16 34.56 46.72 34.56 94.72 0 68.48-0.64 123.52-0.64 140.8 0 13.44 9.6 29.44 35.2 24.32A512.832 512.832 0 0 0 1024 512c0-282.88-229.12-512-512-512z</Geometry>
    <Geometry x:Key="NugetGeometry" o:Freeze="True">M449.722947 199.412211H706.021053c130.967579 0 237.136842 106.169263 237.136842 237.136842v256.298105c0 130.967579-106.169263 237.136842-237.136842 237.136842H449.722947c-130.965895 0-237.136842-106.169263-237.136842-237.136842V436.549053c0-130.967579 106.170947-237.136842 237.136842-237.136842z m-201.205894-21.557895c0-64.299789-70.085053-104.704-125.850948-72.55579s-55.764211 112.96 0 145.111579 125.850947-8.257684 125.850948-72.555789z m239.528421 234.74021c0-68.003368-74.088421-110.736842-133.037474-76.734315s-58.950737 119.467789 0 153.470315 133.039158-8.730947 133.039158-76.736zM835.368421 692.847158c0-117.596632-128.154947-191.494737-230.123789-132.695579s-101.970526 206.593684 0 265.391158S835.368421 810.443789 835.368421 692.847158z</Geometry>
    <Geometry x:Key="EmailGeometry" o:Freeze="True">M430.079734 481.464543c45.196365 45.596478 118.486578 45.596478 163.68499 0l360.684736-324.939627c0.547469 3.751441 1.13894 7.490601 1.13894 11.401678l0 404.753417 0 116.754121c0 42.995233-34.547841 77.838809-77.145008 77.838809L145.397996 767.272941c-42.597167 0-77.145008-34.844599-77.145008-77.838809L68.252988 494.839155 68.252988 167.926594c0-3.911076 0.593518-7.65126 1.139963-11.401678L430.079734 481.464543zM910.960992 74.226538 562.044278 387.28558c-38.470173 38.811957-62.276369 38.811957-100.770078 0L112.538611 74.408687c10.011005-4.789073 21.069875-7.673773 32.859385-7.673773l733.044372 0C890.095779 66.735937 901.065622 69.539796 910.960992 74.226538z</Geometry>
    <Geometry x:Key="GitterGeometry" o:Freeze="True">M260.8 645H160V0h100.8v645zM461.8 152.2h-100.8V1024h100.8V152.2z m201.2 0h-100.8V1024h100.8V152.2zM864 152h-100.8v494H864V152z</Geometry>
    <Geometry x:Key="WebsiteGeometry" o:Freeze="True">M698.026667 597.333333C701.44 569.173333 704 541.013333 704 512 704 482.986667 701.44 454.826667 698.026667 426.666667L842.24 426.666667C849.066667 453.973333 853.333333 482.56 853.333333 512 853.333333 541.44 849.066667 570.026667 842.24 597.333333M622.506667 834.56C648.106667 787.2 667.733333 736 681.386667 682.666667L807.253333 682.666667C766.293333 753.066667 701.013333 807.68 622.506667 834.56M611.84 597.333333 412.16 597.333333C407.893333 569.173333 405.333333 541.013333 405.333333 512 405.333333 482.986667 407.893333 454.4 412.16 426.666667L611.84 426.666667C615.68 454.4 618.666667 482.986667 618.666667 512 618.666667 541.013333 615.68 569.173333 611.84 597.333333M512 851.626667C476.586667 800.426667 448 743.68 430.506667 682.666667L593.493333 682.666667C576 743.68 547.413333 800.426667 512 851.626667M341.333333 341.333333 216.746667 341.333333C257.28 270.506667 322.986667 215.893333 401.066667 189.44 375.466667 236.8 356.266667 288 341.333333 341.333333M216.746667 682.666667 341.333333 682.666667C356.266667 736 375.466667 787.2 401.066667 834.56 322.986667 807.68 257.28 753.066667 216.746667 682.666667M181.76 597.333333C174.933333 570.026667 170.666667 541.44 170.666667 512 170.666667 482.56 174.933333 453.973333 181.76 426.666667L325.973333 426.666667C322.56 454.826667 320 482.986667 320 512 320 541.013333 322.56 569.173333 325.973333 597.333333M512 171.946667C547.413333 223.146667 576 280.32 593.493333 341.333333L430.506667 341.333333C448 280.32 476.586667 223.146667 512 171.946667M807.253333 341.333333 681.386667 341.333333C667.733333 288 648.106667 236.8 622.506667 189.44 701.013333 216.32 766.293333 270.506667 807.253333 341.333333M512 85.333333C276.053333 85.333333 85.333333 277.333333 85.333333 512 85.333333 747.52 276.48 938.666667 512 938.666667 747.52 938.666667 938.666667 747.52 938.666667 512 938.666667 276.48 747.52 85.333333 512 85.333333Z</Geometry>
    <Geometry x:Key="FaceBookGeometry" o:Freeze="True">m 41.416254,90 c -0.327378,-7.4702 0.20833,-32.7284 0,-39.901 -5.386902,-0.2083 -4.521603,0.3274 -9.848987,0 0.20833,-5.50595 0.36436,-7.66666 0.126269,-13.32142 4.646472,0.0181 3.439989,-0.009 9.848987,-0.1894 0.09586,-3.7736 0.133082,-3.0791 0.126269,-7.38674 0.18259,-3.73943 -0.486609,-10.54308 4.293149,-14.96288 4.779758,-4.4198 13.606811,-3.64808 22.223356,-3.53554 -0.04417,5.73754 -0.03936,9.37986 0,12.87945 -5.049924,0.46388 -7.309188,-0.33689 -10.85914,1.26269 -1.403378,3.17794 -1.569601,4.80531 -1.262691,11.93242 3.147964,-0.13336 8.201788,-0.1378 12.626907,0 -0.995158,6.00899 -0.948285,7.62376 -1.767767,13.06882 -3.676625,0.088 -5.605721,-0.1488 -11.111678,0 -0.148814,6.756 0.357147,33.0107 0,40.1536 -6.428576,0.1786 -8.174438,-0.03 -14.394674,0 z</Geometry>
    <Geometry x:Key="TwitterGeometry" o:Freeze="True">m 10.44335,90 c 11.073313,0.3952 19.483106,-1.8358 23.901837,-7.1603 -7.9736,-1.4292 -11.832311,-4.1933 -15.078321,-11.0837 3.459698,0.8219 5.795894,0.6358 7.606781,-0.607 -7.19593,-1.719 -12.734543,-6.7971 -13.741664,-15.836 2.766355,1.55307 5.466848,2.66623 7.828682,2.0203 -4.336544,-2.92911 -9.838998,-10.47636 -5.555839,-22.47589 8.400675,11.87052 23.824269,17.67568 33.840111,17.67767 -0.936406,-9.74688 5.88057,-19.46521 15.302849,-19.97853 8.13118,-0.50719 10.57457,4.01944 12.476346,4.82624 3.644547,0.13419 7.393301,-1.74401 10.354063,-3.53553 -1.380842,4.47157 -5.06769,5.62903 -6.313453,8.58629 5.42317,0.41513 5.891376,-1.53111 8.333758,-2.0203 -2.071414,3.75017 -5.393863,5.00034 -7.323606,8.08122 -1.633654,16.12573 -5.16049,27.57123 -14.647212,36.36553 -13.825764,11.3764 -34.755458,17.369 -56.984332,5.14 z</Geometry>
    <Geometry x:Key="ThumbsUpGeometry" o:Freeze="True">M68.191078 915.462005l161.384597 0L229.575676 431.30719 68.191078 431.30719 68.191078 915.462005zM955.808922 471.653083c0-44.582381-36.109406-80.69281-80.69281-80.69281L620.329241 390.960273 658.859789 206.578915c0.807389-4.034896 1.412163-8.271384 1.412163-12.709463 0-16.743336-6.859221-31.873941-17.752316-42.767036l-42.968627-42.565445L333.871043 374.216937c-14.524808 14.7264-23.602557 34.899858-23.602557 57.090253l0 403.462005c0 44.582381 36.109406 80.69281 80.69281 80.69281l363.116111 0c33.487695 0 62.133106-20.37505 74.236771-49.222051l121.643478-284.441261c3.63069-9.279341 5.850242-19.164478 5.850242-29.452799L955.807898 475.083206l-0.403183-0.403183L955.808922 471.653083z</Geometry>
    <Geometry x:Key="ImageGeometry" o:Freeze="True">M736 224H288a64 64 0 0 0-64 64v448a64 64 0 0 0 64 64h448a64 64 0 0 0 64-64V288a64 64 0 0 0-64-64z m-416 160a64 64 0 1 1 128.032 0.032A64 64 0 0 1 320 384z m416 320a32 32 0 0 1-32 32H384a32 32 0 0 1-32-32l96-160c26.432-2.048 68.128 6.016 128 64l128-224a32 32 0 0 1 32 32v288z</Geometry>
    <Geometry x:Key="KeyboardGeometry" o:Freeze="True">M19.692308 512A25 25 0 1 1 19.692308 531.692308ZM512 303.027832C512 286.548884 524.86564 273.174666 540.717948 273.174666L598.153846 273.174666C614.006154 273.174666 626.871794 286.548884 626.871794 303.027832L626.871794 362.734167C626.871794 379.213115 614.006154 392.587333 598.153846 392.587333L540.717948 392.587333C524.86564 392.587333 512 379.213115 512 362.734167L512 303.027832 512 303.027832ZM512 482.146834 512 541.853166C512 558.332115 499.13436 571.706335 483.282052 571.706335L425.846154 571.706335C409.993846 571.706335 397.128206 558.332115 397.128206 541.853166L397.128206 482.146834C397.128206 465.667885 409.993846 452.293665 425.846154 452.293665L483.282052 452.293665C499.13436 452.293665 512 465.667885 512 482.146834L512 482.146834ZM339.692308 303.027832C339.692308 286.548884 352.557948 273.174666 368.410256 273.174666L425.846154 273.174666C441.698462 273.174666 454.564102 286.548884 454.564102 303.027832L454.564102 362.734167C454.564102 379.213115 441.698462 392.587333 425.846154 392.587333L368.410256 392.587333C352.557948 392.587333 339.692308 379.213115 339.692308 362.734167L339.692308 303.027832 339.692308 303.027832ZM167.384615 303.027832C167.384615 286.548884 180.250256 273.174666 196.102564 273.174666L253.538462 273.174666C269.390769 273.174666 282.25641 286.548884 282.25641 303.027832L282.25641 362.734167C282.25641 379.213115 269.390769 392.587333 253.538462 392.587333L196.102564 392.587333C180.250256 392.587333 167.384615 379.213115 167.384615 362.734167L167.384615 303.027832 167.384615 303.027832ZM282.25641 720.972168C282.25641 737.451116 269.390769 750.825334 253.538462 750.825334L196.102564 750.825334C180.250256 750.825334 167.384615 737.451116 167.384615 720.972168L167.384615 661.265833C167.384615 644.786885 180.250256 631.412667 196.102564 631.412667L253.538462 631.412667C269.390769 631.412667 282.25641 644.786885 282.25641 661.265833L282.25641 720.972168 282.25641 720.972168ZM310.97436 571.706335 253.538462 571.706335C237.686154 571.706335 224.820513 558.332115 224.820513 541.853166L224.820513 482.146834C224.820513 465.667885 237.686154 452.293665 253.538462 452.293665L310.97436 452.293665C326.826667 452.293665 339.692308 465.667885 339.692308 482.146834L339.692308 541.853166C339.692308 558.332115 326.826667 571.706335 310.97436 571.706335L310.97436 571.706335ZM569.435898 720.972168C569.435898 737.451116 556.570256 750.825334 540.717948 750.825334L368.410256 750.825334C352.557948 750.825334 339.692308 737.451116 339.692308 720.972168L339.692308 661.265833C339.692308 644.786885 352.557948 631.412667 368.410256 631.412667L540.717948 631.412667C556.570256 631.412667 569.435898 644.786885 569.435898 661.265833L569.435898 720.972168 569.435898 720.972168ZM569.435898 541.853166 569.435898 482.146834C569.435898 465.667885 582.301538 452.293665 598.153846 452.293665L655.589744 452.293665C671.442052 452.293665 684.307692 465.667885 684.307692 482.146834L684.307692 541.853166C684.307692 558.332115 671.442052 571.706335 655.589744 571.706335L598.153846 571.706335C582.301538 571.706335 569.435898 558.332115 569.435898 541.853166L569.435898 541.853166ZM856.615385 720.972168C856.615385 737.451116 843.749744 750.825334 827.897437 750.825334L655.589744 750.825334C639.737437 750.825334 626.871794 737.451116 626.871794 720.972168L626.871794 661.265833C626.871794 644.786885 639.737437 631.412667 655.589744 631.412667L713.02564 631.412667C728.877948 631.412667 741.74359 618.038449 741.74359 601.559501L741.74359 482.146834C741.74359 465.667885 754.609231 452.293665 770.461538 452.293665L827.897437 452.293665C843.749744 452.293665 856.615385 465.667885 856.615385 482.146834L856.615385 720.972168 856.615385 720.972168ZM856.615385 362.734167C856.615385 379.213115 843.749744 392.587333 827.897437 392.587333L713.02564 392.587333C697.173333 392.587333 684.307692 379.213115 684.307692 362.734167L684.307692 303.027832C684.307692 286.548884 697.173333 273.174666 713.02564 273.174666L827.897437 273.174666C843.749744 273.174666 856.615385 286.548884 856.615385 303.027832L856.615385 362.734167 856.615385 362.734167Z</Geometry>
    <Geometry x:Key="LoveGeometry" o:Freeze="True">M890.2 208.2c-91.8-91.9-242.1-91.9-334 0L544.4 220c-18.2 18.2-47.6 18.2-65.8 0l-11.8-11.8c-91.9-91.9-242.1-91.9-334 0C41 300 24.7 533.9 203.6 722.1 304 827.8 412.4 882.3 470 905.9c26.6 10.9 56.5 10.9 83 0 57.6-23.6 166-78.1 266.4-183.8 178.9-188.2 162.6-422 70.8-513.9z</Geometry>
    <Geometry x:Key="CnblogsGeometry" o:Freeze="True">M512 0C229.234472 0 0 229.226146 0 512 0 794.765528 229.234472 1024 512 1024S1024 794.765528 1024 512C1024 229.226146 794.765528 0 512 0zM228.776585 836.066862c-63.163317 0-114.371642-51.208325-114.371642-114.371642S165.613268 607.323577 228.776585 607.323577s114.371642 51.208325 114.371643 114.371643c0 63.171642-51.208325 114.371642-114.371643 114.371642z m420.555968-89.612488a391.867317 391.867317 0 0 1-1.989724 16.975089c-7.259577 30.203837-33.950179 52.898341-66.376845 52.898342-38.104455 0-68.990959-34.158309-68.99096-72.204488 0-5.877593 0.81587-11.463805 2.206179-16.775284-1.756618-131.096976-103.981789-237.867707-233.205593-246.883903l-6.343805-0.740943-1.015675-0.041626c-5.453008-0.216455-10.930992-0.732618-16.142569-2.331057a67.958634 67.958634 0 0 1-47.91987-65.078114c0-37.604943 30.245463-68.091837 67.550699-68.091837 0.299707 0 0.591089 0.041626 0.890797 0.049951l0.124878-0.049951c205.707447 2.139577 371.836878 169.484488 371.836878 375.699772 0 7.717463-0.341333 15.34335-0.824195 22.94426 0.066602 1.207154 0.19148 2.397659 0.199805 3.629789z m254.085203-63.329821c-10.856065 45.172553-25.80813 104.114992-74.310764 104.114992-56.994341 0-48.236228-66.085463-48.236228-122.996553 0-8.791415 1.223805-17.149919 3.296781-25.100488-2.639089-196.108488-169.834146-387.812943-363.137041-401.291447l-35.806699-5.827642c-42.117203-7.492683-111.715902-3.255154-111.715903-49.193626 0-56.253398 50.234276-81.861724 106.038114-81.861724 0.449561 0 0.882472 0.058276 1.332033 0.066602l0.183154-0.066602c307.724488 3.180228 526.252748 208.546341 526.252748 517.028423a538.474146 538.474146 0 0 1-1.23213 34.316488c0.108228 1.806569 0.291382 3.596488 0.308033 5.428032a542.72 542.72 0 0 1-2.972098 25.383545z</Geometry>
    <Geometry x:Key="ConfigGeometry" o:Freeze="True">M827.904 541.184a278.592 278.592 0 0 0 0-58.368l73.728-58.368c15.872-13.056 20.224-35.584 9.728-53.504l-78.592-137.728c-9.984-17.408-31.232-25.856-51.712-18.176l-86.528 35.072c-15.872-11.52-32.512-21.248-49.664-29.184l-12.8-92.928c-3.072-20.224-20.736-35.584-41.216-35.584h-157.44c-20.736 0-38.144 14.848-41.216 35.84L378.88 221.44c-17.152 7.936-33.792 17.92-49.664 29.184L242.688 215.296c-18.688-7.168-41.216 0.768-51.2 18.176L112.64 371.2c-10.24 17.92-6.144 40.448 10.24 53.76l73.472 58.112c-1.024 9.472-1.536 19.2-1.536 29.184 0 9.728 0.512 19.456 1.536 29.184l-73.984 58.368c-15.872 13.056-19.968 35.584-9.728 53.248l78.848 137.728c9.984 17.408 32 25.856 51.456 17.92l86.528-35.072c15.872 11.52 32.512 21.248 49.664 29.184l13.056 93.696c3.328 20.48 20.48 35.328 41.216 35.328h157.44c20.48 0 38.144-15.36 41.216-35.84l13.056-93.184c17.152-7.936 33.792-17.664 49.664-29.184l86.784 35.328c4.864 1.792 9.984 2.816 15.104 2.816 14.848 0 28.672-7.936 36.096-20.992l78.592-137.728c10.24-17.664 6.4-40.192-9.984-53.76l-73.472-58.112z m-25.344 231.168l-99.584-40.448c-7.424-3.072-15.872-1.792-22.272 3.072-19.712 15.36-40.704 27.648-62.464 36.608-7.424 3.072-12.544 9.728-13.568 17.664l-14.592 104.96-155.392 2.304-15.104-107.264c-1.024-7.936-6.4-14.592-13.568-17.664-21.76-8.96-42.752-21.504-62.464-36.608-4.096-3.072-8.96-4.608-13.824-4.608-2.816 0-5.888 0.512-8.448 1.536l-96.256 41.472-80.896-137.216 84.48-66.816c6.144-4.864 9.472-12.8 8.448-20.48-1.536-12.032-2.56-24.32-2.56-36.608 0-12.288 1.024-24.576 2.56-36.608 1.024-7.936-2.048-15.616-8.448-20.48l-83.712-64 76.544-139.264 99.584 40.448c7.424 3.072 15.872 1.792 22.272-3.072 19.712-15.36 40.96-27.648 62.72-36.864 7.424-3.072 12.544-9.728 13.568-17.664l12.544-104.704 157.696-2.304 15.104 107.264c1.024 7.936 6.4 14.592 13.568 17.664 21.76 8.96 42.752 21.504 62.464 36.864 6.4 4.864 14.848 6.144 22.272 3.072l96.256-41.472 80.896 137.216-84.48 66.816c-6.144 4.864-9.472 12.544-8.448 20.48 1.536 12.032 2.56 24.32 2.56 36.608 0 12.288-1.024 24.576-2.56 36.608-1.024 7.936 2.304 15.616 8.448 20.48l83.712 63.744-77.056 139.264zM512 345.6c-91.136 0-165.12 74.752-165.12 166.4s73.984 166.4 165.12 166.4 165.12-74.752 165.12-166.4-73.984-166.4-165.12-166.4z m0 297.216c-71.168 0-129.28-58.624-129.28-130.816 0-72.192 58.112-130.816 129.28-130.816s129.28 58.624 129.28 130.816c0 72.192-57.856 130.816-129.28 130.816z</Geometry>
    <Geometry x:Key="ContributorsGeometry" o:Freeze="True">M657.486769 287.744c5.671385 0 11.264-5.671385 16.935385-5.671385l186.289231-124.140307c5.592615-5.592615 16.935385-16.935385 16.935384-28.199385V73.334154A74.673231 74.673231 0 0 0 804.233846 0H606.680615v220.002462c0 22.606769-16.935385 33.870769-39.463384 33.870769H454.262154c-22.528 0-39.463385-16.935385-39.463385-33.870769V5.671385H222.838154c-45.134769 0-79.005538 33.870769-79.005539 73.255384v56.477539c0 11.264 5.671385 22.528 16.935385 28.199384l186.289231 124.140308h16.935384C200.310154 349.735385 98.697846 507.746462 121.304615 693.878154c22.528 169.275077 169.353846 310.350769 344.221539 327.207384 237.095385 28.199385 440.32-152.339692 440.32-377.934769 0-158.011077-101.612308-299.008-248.359385-355.406769z m-146.747077 671.271385C335.793231 959.015385 189.046154 818.018462 189.046154 643.150769c0-174.867692 146.747077-310.350769 321.693538-310.350769 174.946462 0 321.693538 141.075692 321.693539 315.943385s-146.747077 310.350769-321.693539 310.350769zM670.798769 572.967385l-68.371692-11.185231a31.507692 31.507692 0 0 1-28.514462-16.777846l-28.514461-55.926154c-17.092923-27.963077-51.278769-27.963077-68.371692 0l-28.514462 55.926154a31.507692 31.507692 0 0 1-28.514462 16.777846l-68.371692 11.185231c-28.514462 5.592615-39.936 39.148308-17.092923 61.44l45.528615 39.227077c5.750154 11.185231 17.171692 22.370462 11.421539 33.555692l-11.421539 67.111384c-5.671385 27.963077 28.514462 50.333538 51.357539 33.555693l62.700308-27.963077a37.021538 37.021538 0 0 1 34.185846 0l62.700307 33.555692c28.514462 16.777846 57.028923-5.592615 51.27877-33.555692l-11.421539-67.111385c0-16.777846 5.750154-27.963077 11.421539-33.555692l51.278769-44.740923a38.596923 38.596923 0 0 0-22.843077-61.518769z</Geometry>
    <Geometry x:Key="GitHubStrGeometry" o:Freeze="True">M1185.92 769.92h-1.28c0.576 0 0.96 0.64 1.536 0.704h0.384l-0.64-0.64z m0.256 0.704c-5.952 0.064-20.928 3.2-36.736 3.2-49.92 0-67.2-23.04-67.2-53.12V520.32h101.76c5.76 0 10.24-5.12 10.24-12.16v-108.8c0-5.76-5.12-10.88-10.24-10.88h-101.76V253.44c0-5.12-3.2-8.32-8.96-8.32h-138.24c-5.76 0-8.96 3.2-8.96 8.32v138.88s-69.76 17.28-74.24 17.92c-5.12 1.28-8.32 5.76-8.32 10.88v87.04c0 7.04 5.12 12.16 10.88 12.16h71.04v209.92c0 156.16 108.8 172.16 183.04 172.16 33.92 0 74.88-10.88 81.28-14.08 3.84-1.28 5.76-5.76 5.76-10.24v-96a11.328 11.328 0 0 0-9.344-11.52z m1516.544-140.8c0-115.84-46.72-131.2-96-126.08-38.4 2.56-69.12 21.76-69.12 21.76v225.28s31.36 21.76 78.08 23.04c65.92 1.92 87.04-21.76 87.04-144z m155.52-10.24c0 219.52-71.04 282.24-195.2 282.24-104.96 0-161.28-53.12-161.28-53.12s-2.56 29.44-5.76 33.28c-1.92 3.84-5.12 5.12-8.96 5.12h-94.72c-6.4 0-12.16-5.12-12.16-10.88l1.28-711.04c0-5.76 5.12-10.88 10.88-10.88h136.32c5.76 0 10.88 5.12 10.88 10.88v241.28s52.48-33.92 129.28-33.92l-0.64-1.28c76.8 0 190.08 28.8 190.08 248.32z m-558.08-231.04H2165.76c-7.04 0-10.88 5.12-10.88 12.16v348.16s-35.2 24.96-83.2 24.96-62.08-21.76-62.08-69.76V400c0-5.76-5.12-10.88-10.88-10.88h-136.96c-5.76 0-10.88 5.12-10.88 10.88v327.04c0 140.8 78.72 176 186.88 176 88.96 0 161.28-49.28 161.28-49.28s3.2 24.96 5.12 28.8c1.28 3.2 5.76 5.76 10.24 5.76h85.76c7.04 0 10.88-5.12 10.88-10.88l1.28-478.08c0-5.76-5.12-10.88-12.16-10.88z m-1516.8-0.64h-136.32c-5.76 0-10.88 5.76-10.88 12.8v469.76c0 12.8 8.32 17.28 19.2 17.28h122.88c12.8 0 16-5.76 16-17.28V398.72c0-5.76-5.12-10.88-10.88-10.88z m-67.2-216.32c-49.28 0-88.32 39.04-88.32 88.32 0 49.28 39.04 88.32 88.32 88.32 48 0 87.04-39.04 87.04-88.32 0-49.28-39.04-88.32-87.04-88.32z m1055.36-16h-135.04c-5.76 0-10.88 5.12-10.88 10.88v261.76h-211.84V166.4c0-5.76-5.12-10.88-10.88-10.88h-136.32c-5.76 0-10.88 5.12-10.88 10.88v711.04c0 5.76 5.76 10.88 10.88 10.88h136.32c5.76 0 10.88-5.12 10.88-10.88V573.44h211.84l-1.28 304c0 5.76 5.12 10.88 10.88 10.88h136.32c5.76 0 10.88-5.12 10.88-10.88V166.4c0-5.76-5.12-10.88-10.88-10.88zM563.84 470.4v367.36c0 2.56-0.64 7.04-3.84 8.32 0 0-80 56.96-211.84 56.96-159.36 0-348.16-49.92-348.16-378.88S165.12 127.36 326.4 128c139.52 0 195.84 31.36 204.8 37.12 2.56 3.2 3.84 5.76 3.84 8.96L508.16 288c0 5.76-5.76 12.8-12.8 10.88-23.04-7.04-57.6-21.12-138.88-21.12-94.08 0-195.2 26.88-195.2 238.72s96 236.8 165.12 236.8c58.88 0 80-7.04 80-7.04v-147.2H312.32c-7.04 0-12.16-5.12-12.16-10.88V470.4c0-5.76 5.12-10.88 12.16-10.88h239.36c7.04 0 12.16 5.12 12.16 10.88z</Geometry>
    <Geometry x:Key="QqGeometry" o:Freeze="True">M936.194300839506 691.6934192494618c-5.891587367822223-94.26540047423211-70.69904970840491-170.8560375504593-106.04857520987652-212.09715041975304 5.891587367822223-11.783174735644446 17.674762103466666-79.53643140740742-29.457938133649378-126.66913164452346V349.981342854005c0-182.63921228610366-129.61492468116543-315.1999312984493-294.57937486380246-315.1999312984493s-294.57937615834066 132.5607190123457-294.57937615834066 315.1999312984493v2.9457943311802466c-47.132700237116055 47.132700237116055-35.349525501471604 114.885956908879-29.45793683911111 126.66913164452346-35.349525501471604 41.24111286929382-100.15698784205432 117.83174994552098-106.04857520987652 212.09715041975304 0 23.56634947128889 2.9457943311802466 58.91587497276049 14.728969066824689 76.59063707622718 14.728969066824689 20.62055643464691 55.97008193611851-2.9457943311802466 82.48222444404936-64.80746234058272 8.837381699002469 29.457938133649378 26.51214380246913 73.64484403958517 67.75325667176295 126.66913164452346-70.69904970840491 14.728969066824689-88.37381310640988 85.42801877522965-64.80746234058272 123.72333731334321 17.674762103466666 26.51214380246913 53.02428760493826 47.132700237116055 120.77754298216297 47.132700237116055 114.885956908879 0 167.9102445138173-32.40373117029136 191.4765952796444-53.02428760493826 5.891587367822223-5.891587367822223 11.783174735644446-5.891587367822223 20.620555140108642-5.891587367822223 8.837381699002469 0 14.728969066824689 2.9457943311802466 20.62055643464691 5.891587367822223 23.56634947128889 20.62055643464691 73.64484403958517 53.02428760493826 191.4765939851062 53.02428760493826 64.80746234058272 0 103.10278087869627-20.62055643464691 120.77754427670124-47.132700237116055 23.56634947128889-38.29531853811359 2.9457943311802466-106.04857520987652-64.80746234058272-123.72333731334321 41.24111286929382-55.97008193611851 58.91587497276049-100.15698784205432 67.75325667176295-126.66913164452346 29.457938133649378 61.86166930394074 67.75325667176295 85.42801877522965 82.48222444404936 64.80746234058272 5.891587367822223-17.674762103466666 11.783174735644446-53.02428760493826 8.837381699002469-76.59063707622718z m0 0</Geometry>
    <Geometry x:Key="ProjectGeometry" o:Freeze="True">M838.4 325.12 554.24 479.36C528 493.44 512 521.6 512 552.96l0 298.24c0 32 31.36 53.12 57.6 38.4l284.16-154.24c25.6-14.08 42.24-42.24 42.24-73.6L896 364.16C896 331.52 864.64 311.04 838.4 325.12zM405.76 478.72 121.6 325.12C95.36 311.04 64 331.52 64 363.52l0 299.52c0 31.36 16 59.52 42.24 73.6l284.16 153.6C416.64 904.32 448 883.2 448 851.2L448 552.32C448 520.96 432 492.8 405.76 478.72zM812.16 255.36c13.44-7.04 19.84-19.2 18.56-30.72 1.28-12.16-5.12-23.68-18.56-30.72L522.88 42.88c-12.8-7.04-28.16-10.24-43.52-10.24-15.36 0-30.72 3.2-43.52 10.24L146.56 193.28C133.12 200.32 127.36 212.48 128 224 127.36 236.16 133.12 248.32 146.56 255.36l289.28 150.4c12.8 7.04 28.16 10.24 43.52 10.24 15.36 0 30.72-3.2 43.52-10.24L812.16 255.36z</Geometry>
    <Geometry x:Key="BlogGeometry" o:Freeze="True">M1137.575865 0l0 795.939663-267.130435 228.060337-870.44543 0 0-1024 1137.575865 0zM795.939663 682.363798l-626.030169 0 0 113.575865 626.030169 0 0-113.575865zM966.757764 455.212067l-796.84827 0 0 113.575865 796.84827 0 0-113.575865zM966.757764 227.15173l-796.84827 0 0 114.484472 796.84827 0 0-114.484472z</Geometry>
    <Geometry x:Key="VisualStudioGeometry" o:Freeze="True">M23.063,0L11,12L3,6L0,7v15l3,2l8-6l11.875,12L30,27V2.938L23.063,0z M3,19v-8l5,4L3,19z M23,21l-8-6l8-6V21z</Geometry>
    <Geometry x:Key="CodeGeometry" o:Freeze="True">M288.752 319.495c-12.497-12.497-32.758-12.497-45.255 0L73.619 489.372a32 32 0 0 0 0 45.254l169.878 169.879c6.249 6.248 14.438 9.372 22.627 9.372s16.379-3.124 22.627-9.372c12.497-12.497 12.497-32.759 0-45.255L141.502 512l147.25-147.25c12.497-12.497 12.497-32.758 0-45.255zM950.38 489.372L780.504 319.495c-12.498-12.497-32.759-12.497-45.255 0-12.497 12.497-12.497 32.758 0 45.255L882.499 512l-147.25 147.251c-12.496 12.496-12.496 32.758 0.001 45.255 6.248 6.248 14.438 9.372 22.627 9.372s16.379-3.124 22.628-9.373l169.877-169.878c12.496-12.497 12.496-32.758-0.002-45.255zM600.417 312.63c-16.289-6.858-35.052 0.785-41.91 17.074L415.451 669.46c-6.858 16.288 0.786 35.052 17.074 41.91a31.892 31.892 0 0 0 12.404 2.517c12.488 0 24.355-7.359 29.506-19.591L617.491 354.54c6.858-16.288-0.786-35.052-17.074-41.91z</Geometry>
    <Geometry x:Key="WikiGeometry" o:Freeze="True">M638.72 808.533333 529.493333 551.253333C485.973333 636.16 438.186667 725.333333 397.226667 808.533333 396.8 808.96 377.173333 808.533333 377.173333 808.533333 314.453333 661.333333 249.6 516.266667 186.453333 370.346667 171.946667 334.506667 120.746667 277.333333 85.333333 277.333333 85.333333 273.066667 85.333333 263.68 85.333333 258.133333L301.226667 258.133333 301.226667 277.333333C275.626667 277.333333 232.106667 294.4 243.2 322.133333 273.92 387.84 381.44 642.56 410.88 707.413333 430.933333 667.306667 487.68 561.493333 512 516.693333 492.8 479.146667 432.213333 338.346667 414.293333 303.36 400.64 280.32 366.08 277.333333 339.626667 277.333333 339.626667 270.933333 340.053333 266.666667 339.626667 258.56L529.92 258.986667 529.92 276.053333C503.893333 277.333333 479.573333 286.293333 490.666667 311.04 516.266667 363.946667 531.2 401.92 554.666667 450.986667 561.92 436.48 600.32 357.546667 618.666667 316.16 629.76 288.426667 613.12 277.333333 567.04 277.333333 567.466667 272.213333 567.466667 263.253333 567.466667 258.986667 626.773333 258.56 715.946667 258.56 731.733333 258.133333L731.733333 276.053333C701.44 277.333333 670.293333 293.546667 654.08 318.293333L576 482.133333C583.68 503.893333 659.626667 672.426667 667.733333 691.2L832 314.453333C819.2 283.733333 782.506667 277.333333 768 277.333333 768 271.786667 768 264.533333 768 258.133333L938.666667 259.413333 938.666667 260.266667 938.666667 277.333333C901.12 277.333333 877.653333 298.666667 864 330.666667 829.866667 407.04 725.333333 650.24 657.066667 808.533333 657.066667 808.533333 638.72 808.533333 638.72 808.533333Z</Geometry>
    <Geometry x:Key="DocGeometry" o:Freeze="True">M173.826977 510.432295c0-122.019031-0.050142-244.038062 0.022513-366.057093 0.032746-54.232159 27.618011-81.962733 81.740676-82.012875 117.26475-0.10847 234.532571-0.400113 351.790158 0.567935 10.968819 0.090051 24.65554 5.861498 32.362059 13.658068 66.276473 67.050092 131.747603 134.908596 196.58633 203.352431 7.161097 7.559163 12.495592 20.287045 12.535501 30.641881 0.738827 189.363835 0.623193 378.731764 0.480954 568.098669-0.036839 49.259914-28.894074 77.959559-78.538751 78.007655-172.727946 0.166799-345.455893 0.165776-518.183839 0.002047-50.561559-0.048095-78.714759-28.893051-78.760808-80.201623C173.752276 754.470357 173.826977 632.451326 173.826977 510.432295zM425.726078 715.13242c-0.409322 52.42193 32.43983 88.344071 81.254605 88.856747 48.829102 0.512676 83.016739-35.294854 83.205027-87.148849 0.190335-52.300156-32.965809-88.35942-81.524758-88.665389C459.317127 627.863844 426.136424 662.654208 425.726078 715.13242zM265.914302 633.581056c0 56.69935 0 110.830201 0 166.16446 23.783683 0 45.88505 0.218988 67.980277-0.049119 36.362162-0.441045 61.114916-17.009396 71.76958-47.599088 13.557784-38.924521 4.252861-85.525885-22.836101-104.649432-9.880021-6.974855-22.768563-12.386098-34.668591-13.255908C321.448106 632.240525 294.495244 633.581056 265.914302 633.581056zM758.306732 689.51088c-9.967002-45.812395-41.170678-66.920132-86.082564-60.683081-42.587957 5.913687-71.66418 46.171576-67.992557 94.137007 3.773953 49.296753 35.82902 80.999802 81.923848 81.025385 42.137703 0.023536 68.915579-25.63382 71.465658-69.621661-10.092869 0-20.128433 0-30.109762 0-16.044418 36.365232-36.768415 47.330982-62.482053 33.178657-19.942191-10.975982-28.691459-39.623439-21.979594-69.791529 4.77884-21.481244 16.022928-36.523845 39.027875-38.340213 21.590737-1.704828 35.721573 9.087982 40.968064 30.095435C735.017306 689.51088 745.964636 689.51088 758.306732 689.51088zM635.406634 159.644977c0 32.664957-0.671289 69.714781 0.62524 106.695021 0.230244 6.566556 8.422833 18.209734 13.30912 18.408255 37.929868 1.542122 75.950809 0.851391 113.944122 0.851391 1.113357-2.461051 2.226714-4.92108 3.340071-7.382131C722.585159 238.422158 678.54513 198.626803 635.406634 159.644977zM553.603537 717.1381c-0.353041 34.149774-17.751293 55.144948-45.725414 55.175647-29.049616 0.031722-45.502333-21.023826-44.98454-57.571207 0.49528-34.968419 17.328667-55.873542 44.977377-55.858192C535.765263 658.899698 553.965787 682.0827 553.603537 717.1381zM298.449299 770.413468c0-37.08564 0-71.501474 0-107.650789 25.056676-1.242294 50.77236-6.163373 66.627467 18.401092 13.642718 21.135366 14.034645 45.815465 2.095731 67.677379C352.412328 775.868713 325.439 771.676228 298.449299 770.413468z</Geometry>

3)图形效果(Effect)

BlurEffect:模糊效果

DropShadowEffect:投影效果

ShaderEffect:着色器效果

<Color x:Key="EffectShadowColor">#AA000000</Color>
    <DropShadowEffect x:Key="EffectShadow1" PresentationOptions:Freeze="True" BlurRadius="5" ShadowDepth="1" Direction="270" Color="{StaticResource EffectShadowColor}" Opacity=".2" RenderingBias="Performance" />
    <DropShadowEffect x:Key="EffectShadow2" PresentationOptions:Freeze="True" BlurRadius="8" ShadowDepth="1.5" Direction="270" Color="{StaticResource EffectShadowColor}" Opacity=".2" RenderingBias="Performance" />
    <DropShadowEffect x:Key="EffectShadow3" PresentationOptions:Freeze="True" BlurRadius="14" ShadowDepth="4.5" Direction="270" Color="{StaticResource EffectShadowColor}" Opacity=".2" RenderingBias="Performance" />
    <DropShadowEffect x:Key="EffectShadow4" PresentationOptions:Freeze="True" BlurRadius="25" ShadowDepth="8" Direction="270" Color="{StaticResource EffectShadowColor}" Opacity=".2" RenderingBias="Performance" />
    <DropShadowEffect x:Key="EffectShadow5" PresentationOptions:Freeze="True" BlurRadius="35" ShadowDepth="13" Direction="270" Color="{StaticResource EffectShadowColor}" Opacity=".2" RenderingBias="Performance" />

4)图形的变形(Transform)

控件变形的属性有两个:

  • RenderTransform:呈现变形,定义在UIElement类中
  • LayoutTransform:布局变形,定义在FrameworkElement类中

这两个属性都是依赖属性,数据类型都是Transform抽象类,也就是说Transform的派生类都可以赋值这两个属性。常用的派生类如下:

矩阵变形MatrixTransform,把容纳被变形的UI元素的矩形顶点看做一个矩形进行变形

旋转变形RotateTransform,以给定的点为旋转中心,以角度为单位进行旋转变形

坐标系变形ScaleTransform,坐标系变形,调整被变形元素的坐标系,可产生缩放效果

拉伸变形SkewTransform,可在横向或者纵向上对被变形元素进行拉伸

偏移变形TranslateTransform,使被变形元素在横向或纵向上偏移一个给定的值

变形组TransformGroup,可以把多个独立变形合成一个变形组,产生复合变性的效果

动画

1)动画

就是会动的画,会动指的是能够让UI元素或者元素变形的某个属性值产生连续的变化,针对每个可能的数据类型,WPF提供对应的动画类,这些动画类都派生自AnimationTimeline。

2)场景(Storyboard),就是并行执行一组动画

<Storyboard x:Key="Storyboard1">
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="PART_VerticalScrollBar" Storyboard.TargetProperty="Opacity">
                                <EasingDoubleKeyFrame KeyTime="0:0:.2" Value=".8" />
                            </DoubleAnimationUsingKeyFrames>
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="PART_HorizontalScrollBar" Storyboard.TargetProperty="Opacity">
                                <EasingDoubleKeyFrame KeyTime="0:0:.2" Value=".8" />
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                        <Storyboard x:Key="Storyboard2">
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="PART_VerticalScrollBar" Storyboard.TargetProperty="Opacity">
                                <EasingDoubleKeyFrame KeyTime="0:0:.2" Value="0" />
                            </DoubleAnimationUsingKeyFrames>
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="PART_HorizontalScrollBar" Storyboard.TargetProperty="Opacity">
                                <EasingDoubleKeyFrame KeyTime="0:0:.2" Value="0" />
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
<ControlTemplate.Triggers>
                                        <EventTrigger RoutedEvent="MouseEnter">
                                            <BeginStoryboard Storyboard="{StaticResource Storyboard1}"/>
                                        </EventTrigger>
                                        <EventTrigger RoutedEvent="MouseLeave">
                                            <BeginStoryboard Storyboard="{StaticResource Storyboard2}"/>
                                        </EventTrigger>
                                    </ControlTemplate.Triggers>
posted @ 2020-07-31 15:12  蜗牛的希望  阅读(1105)  评论(0编辑  收藏  举报