路径缩放动画上的低帧速率wpf(巨大的路径数据)

问题描述 投票:1回答:1

谁能告诉我如何用WPF中的大量数据为Path对象设置动画?

这是一个非常简单的代码:

<Window x:Class="WpfApp3.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:WpfApp3"
    mc:Ignorable="d"
    Title="MainWindow" Height="450" Width="800" MouseWheel="MainWindow_OnMouseWheel">
<Grid>
    <Path   StrokeThickness="1" Stroke="#FF000000" StrokeLineJoin="Miter" StrokeStartLineCap="Flat" 
                     StrokeEndLineCap="Flat">
        <Path.RenderTransform>
            <ScaleTransform x:Name="ScaleTransform"></ScaleTransform>
        </Path.RenderTransform>
        <Path.Data>
            <PathGeometry Figures="%%Data%%" FillRule="NonZero"/>
        </Path.Data>
    </Path>
</Grid>

using System;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;

namespace WpfApp3
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window 
    {
    private double _scale = 1;
    public MainWindow()
    {
        InitializeComponent();
    }

    private void MainWindow_OnMouseWheel(object sender, MouseWheelEventArgs e)
    {
        if (e.Delta > 0)
            _scale *= 2;
        else
            _scale /= 2;

        DoubleAnimation a = new DoubleAnimation(_scale, TimeSpan.FromMilliseconds(2000));
        ScaleTransform.BeginAnimation(ScaleTransform.ScaleXProperty, a);
        ScaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, a);
    }

    }
}

注意,当您监视分辨率时,帧速率会降低。

PathData:

M 9.9390855 -9.3573639 H 499.29287 v 6.431173 H 9.3544333 V 7.0128956 H 496.95427 V 17.536631 H 8.1851293 v 9.354434 H 496.36962 v 9.939086 H 8.1851293 L 11.158048 47.925233 H 492.27705 V 63.724147 H 9.3544333 L 13.731642 80.060112693 v 24.79061 H 493.44635 v 18.70887 H 9.3544333 v 13.44699 H 492.8617 v 19.29352 H 10.523738 v 19.87817 H 495.20033 v 22.80143 H 13.446998 v 15.20096 H 489.3538 l 7.64244 28.52201 H 14.03165 v 22.34271 H 491.6924 V -17.542493 H 471.4523 V 471。 402.24064 V 288.81521 h 32.74052 V -14.03458 h -64.31174 v 296.41861 l -27.49889 7.3683 V -15.203885 h -27.4584 V 282.96868 h -29.2326 V -17.542493 H 247.89248 V 281.21473 c 0 0 -24.69105 2.26028 -23.38608 0 -298.172571 H 196.4431 V 284.72263 c 0 0 -34.49447 5.84652 -34.49447 0 0 -5.84652 0 -298.172558 0 -298.172558 H 135.63928 V 278.87611 H 98.806202 V -14.619233 H 67.23499 V 273.61426 H 34。 494472 V -16.373189 H 7.6004771 V 287.06126 H 73.666164 V -17.542493 H 129.20811 V 285.89193 h 91.79038 V -13.449928 l 17.93326 4.8052031 V 287.64591 h 25.91563 V -15.788537 h 32.15587 V 286.47658 c 0 0 23.63175.106.7 -301.095813 0 0 33.32517 -1.169304 33.32517 0 0 1.169305 0 297.003263 0 297.003263 H 330.32842 V -17.542493 h 59.63452 V 276.53751 l 30.22632 8.0991 V -12.865276 H 173.05702 V 278.29146 H 107.57598 V -17.542493 0268.238 6.32698 0 -11.21259 0 -276.05998 0 -276.05998 L 47.847212 39.529523 V 265.42911 H 477.66075 L -2.4598142 -11.768623 V 290.56915 L 477.8195 13.279769 H 150.84024 L 78.982265 137.74143 -279.375375.685.245.7685.824.825.86.854.856.85424.688.85424.688.85424.68824.68524.688.854.86.854.688.450.678.450.678.45024.685.67824.688.265.688.678.450.67824.68524.68524.688.265.86.685.86.854.86.685.86.854.86.856.86.854.86.856.86.608.86.685.286.685.286.685.86.685.86.685.86.685.86.685.86.685.86.685.86.685.86.685.86.685.86.685.86.685.86.685.86.685.86.685.86.685.86.685.685.678。 193.51984 L 96.365667 19.494842 13.741784 162.6036 70.853667 219.71549 279.0081 163.94068 222.61914 66.27214 105.10566 3 4.784496ħ345.52937大号452.84204 6.0301564 V 199.94808大号154.0296 280.01463 83.996002 158.71288 431.78722 65.522512 358.88255 23.43099ħ150.84024大号58.048389 184.15119 462.11722 292.42111 V 129.20518 4.089634ħ311.0349 83.020597大号232.69153 153.76057 401.59207 108.50381 457.63134 52.464523ħ244.96922大号342.31254 221.06811 43.032539 140.87627 247.93747 22.574356 419.91475 194.55165 125.92783 273.3252 191.99353 26.764676 V 265.42911 c 0 0 16.84109 -0.94165 16.84109 -16.84107 0 -15.89944 0 -250.9295788 0 -250.9295788 H 480.584 V 283.55333 l 1.75398 0.58465 -94.71364 1.16931 L 384.11643 22.798501 279.4637 266.77066 679.67966 9.35444 -141.48581 9.35444 -16.954909 -33.90983 84.1899 -166.041198 84.1899 -166.041198 4.67722 -1.753957 150.25559 -4.677217 150.25559 -4.677217 30.98656 12.277694 40.92565 23.970735 40.92565 23.970735 10.52374 25.14004 30.98656 43.84891.46 3.72708 -46.18752 63.72708 -35.07912 -58.46521 2.3386 -7.01583 -58.46521 -7.01583Ç206.96684 171.88479 185.91937 140.31357 185.91937 140.31357 146.16302 115.75818 137.97789 78.925102 137.97789 78.925102 116.34577 70.739973 84.774553 9.3515033 84.774553 9.3515033 121.02298 8.7668512 317.46609 -4.0954948 317.46609 -4.0954948Ç23.97073 0 92.95968 26.3093438 26.3093438 92.95968 15.20095 30.986561 44.43356 116.930421 44.43356 116.930421 19.87817 44.43356 36.83308 80.09733 36.83308 80.09733 -2.33861 23.97074 -21.04748 18.12422 -21.04748 18.12422 -46.18751 -31.57121 -47.35681 -31.57121 -47.35681 -31.57121.1686-1616764 1616-31416-7641616-11816 18.12421 -97.6369 26.30935 -127.454153 32.74052 -127.454153 32.74052 -50.28008 12.86235 -53.20334 -28.0633 -53.20334 -28.0633 C 32.740517 161.36105 35.079126 90.033492 35.079126 90.033492 35.663778 61.970192 57.880557 11.10546 181.826803 9.939085 119.26903 5.261869 188.84262 4.677217 188.84262 4.677217 41.5103 32.740517 45.01822 67.234991 45.01822 67.234991 -1.75396 39.171687 -7.01583 87.113157 -7.01583 87.113157 18.422.57.29591352.9356.29356.1635.69516.5635.695.265.1651 239.5692.165.978.1651 936.79563.1926.56.932.365.916.592.935.265 25.14004 3.50791 32.15587 1.75395 32.15587 1.75395 -172.47237 2.92326 -214.56732 -4.09256 -214.56732 -4.09256 -64.31173 -0.58465 -95.88295 1.1693 -95.88295 1.1693 -11.10839 0 -41.510294 -50.28008 -41.510294 -50.28697654 10.105584 -37.71455 -14.350212 -87.205924 -101.556136 0 14.350211 -14.350211 119.679597 27.472271 167.262967 0 47.58337 -27.472271 137.87135 -76.946396 157.87329 -42.3020193 20.00194 34.6443763 81.5773183 47.09868 60.38059 13.28191 104.5822553 23.00493 12.60158 -5.024275 12.60158 47.02973 0 52.05401 36.25673 49.24539 0 70.17823 -36.25673 20.93283 -13.08656 44.73405 -57 0.06922 32.94893 -43.98267 -11.78512 -13.71718 -3.67551 -86.55171 -23.19146Ç263.4618 210.06778 202.69037 126.37021 180.10782 139.40825 157.52526 152.4463 128.18851 144.7373 101.90511 118.4539 75.621716 92.170504 61.794056 88.122064 48.435394 64.984182 35.076731 41.8463 37.549954 -3.2144908 16.571855 33.120643Ç-20.9780995 36.335134 -5.942827 73.905607 0 96.084537 5.942827 22.17894 21.08962 71.28007 51.185539 ​​88.65596 30.095919 17.37588 27.962231 7.49245 121.835796 32.6458 93.87356 25.15335 70.4376 48.08086 118.51846 0 48.08086 -48.08086 64.06367 -27.06589 77.60579 -77.60579 13.54213 60.03367 -50.5399 33.60899 -31.78779 -58.21247ç392.90175 88.263995 446.09705 89.463785 375.06986 70.432107 304.04267 51.400428 355.90942 19.101598 269.70561 42.19984 183.50179 65.298082 170.5094 68.779383 118.03276 82.840457 65.556116 96.901531 15.084417 121.14966 75.7073 156.1503 c 60.62288 35.00064 -2.946233 49.53018 85.78878 49.53018 88.73502 0 89.48031 -11.7355 129.04282 -34.57692 39.5625 -22.84142 72.95695 -5.9875 48.44443 -48.44443Ç314.47081 80.202196 342.81589 65.909136 299.52096 54.308294 256.22603 42.707452 315.14921 58.49587 230.49928 35.81399 145.84935 13.132109 174.03821 8.8045591 129.69871 8.8045591Ç-44.339504 0 -21.79089 -65.3841661 -59.540459 0℃32.408686 74.188725 29.051489 77.030339 40.464349 119.62371Ç11.41286 42.59337 30.325961 75.88639 25.329829 94.53221 -4.996132 18.64582 -14.518831 1.73318 5.948649 22.20066 20.46748 20.46748 -0.02999 57.09475 45.022873 45.02287 45.05285 -12.07188 -37.501136 10.0484 69.86346 -18.71986 107.3646 -28.76826 128.21788 -59.14237 174.4701 12.46.19242.9244.9242.94251.97%249.724-192.9 942.95479.2942.97-1925 1492-1694-925942-425-1792-1694-269-1429.92-4925-499-499-284-342-342-342-925-124-342-697-342-419-342-419-342-394-124-124-124 -39.63475 -68.6494 -43.7245 -75.73306 -4.08975 -7.08365 1.37549 5.1334 -2.88423 -10.76407 -4.25971 -15.89748 -9.83489 -19.11876 -9.83489 -36.70435 0 -17.585586 1.55223 -27.301202 12.30633 -45.92785 10.7541 -12.24-218.2827 7.42 9823 3.92191 -3.921911 16.78425 -16.784257 12.86235 -12.8623458 15.78561 -15.7856063 15.78561 -15.7856063 0 0 0 --9.6206695 0 33.6435853 0 43.264255 -12.40115 19.199304 0 65.48103 12.40115 46.28173 30.9696 70.08695 24.87467 22.38.27.281.582.1821.853.872.1852-1825 -43.29261 11.60022 -20.07605 5.37936 -36.51643 23.96586 -89.44183 23.96586 -52.92539 0 -30.12396 0 -84.4966 0 -54.37265 0 -38.00239 0 -65.48103 0 -27.47865 0 -27.62124 7.48133 -55.54195 0 -27.92071 -7.48133 -27.547 ç87.83909 216.30299 88.238415 216.99464 68.439326 182.70161 48.640237 148.40858 28.172949 81.17404 37.09456 65.721355 46.016172 50.268671 26.814074 25.974127 76.841789 25.974127 50.027711ç0 103.103691 11.626748 146.495311 0 43.39161 -11.626749 -6.70527 -20.9553236 -20.9553236 78.20633 84.9116 0 100.8597 -9.0200128 116.48282 0 15.62312 9.0200126 26.39195 -9.3966421 18.82893 18.8289346 -7.56302 28.225577 1.45495 19.115508 -28.0 9977 48.670224 -29.55471 29.554718 -18.21013 20.385838 -50.11762 28.935428 -31.90749 8.54958 -38.38517 -16.255704 -99.05226 0 -60.6671 16.25569 -17.06748 17.56067 -65.53732 17.56067 -48.46984 0 -76.19493 -16.36816521 521.168.5618.521.521.160.868.521521 21.6657 33.86317 58.65274 33.86317 36.98704 0 4.3563 46.51839 84.92851 0 80.57221 -46.51839 103.10463 -58.37041 105.8423 -61.10808 2.73767 -2.73767 7.63331 9.54532 0 -18.9426 -7.63332 -28.48793 -9.35861 -32.32599 -93.58642 -9.354433 0 -60.2191654 0 -60.2191654 l -213.98267 0 L 126.14562 141.28891 240.90403 256.04732 317.99906 122.51481 153.36913 78.402353 57.421997 174.34949 v 75.87868 L 445.12315 146.34395 387.63386 20.209.72946.8246.8246.9866.8866.82946.8246.2866.8294 2.7603.6426.86926.8246.8246.8436.8246.8246.8244.2436.8294 107.795407 0 191.183117 H 320.974 L 220.07693 294.21837 113.76901 265.73325 -0 56346214 151.40077 24.8056 56.722143 277.58826 -11.010767 417.50185 69.768377 H 316.29678 c 0 0 -77.44671 -32.177162 -83.1594 -22.282494 -5.71269 9.894669 -98.61277 26.423213 -98.61277 26.423213 L 67.07551 1168.8184 16.7987.624 16.798.167.69816147 98279 16.798.67821.972.186.789716.978.6786.817。 h 98.496216 c 0 0 56.92242 14.8299816 58.28743 15.6180695 1.36501 0.7880879 -42.18954 116.2964253 -32.63901 121.8104353 9.55053 5.514 112.30718 112.30718 112.30718 112.30718 0 0 109.48988 -3.81219 111.69084 0 2.20097 3.81218 -49.657.8741789 55.276532 0 0 -176.594294 -0.947088 -177.141096 0 -0.546802 0.947088 0 172.812952 0 172.812952 0 0 5.903862 80.58267 0 77.17408 -5.903861 -3.4086 3.351256 -0.89797 59.878486 -16.0444 56.52723 -15.14642 281.7518 -162.66947 01.7 -69.147.247 1.37334 5.125359 -40.62396 151.61071 -40.62396 151.61071 0 0 -28.28437 44。 89857 -27.5356 47.69304 0.74878 2.79448 -46.90116 0 -52.16303 0 -5.26187 0 -107.82333 -186.755491 -107.82333 -186.755491 L 151.69416 6.1589742 319.48415 51.118165 V 156.68383 l -24.17938 90.23867 c 0 0 22.31126.251 43671 -251.677412 l 54.14483 31.260533 c 0 0 26.52255 123.850339 32.29292 120.518819 5.77037 -3.33153 -236.79697 -55.75703 -242.05107 -64.85739 C 122.8247 116.40571 42.210544 39.637819 42.210544 39.637819 L 20.368151 1.8056849 10.6.85.78.76.87.64.78.746.7 06.83.76.86.78.76.876.76.84.76.84.78.746.7 06.83742.7374.374.678.374.678 0.74631 291.836069 0 291.836069 0 0 0 113.09383 -78.6833 105.82203 -105.82202 -7.2718 -27.13873 0 -101.144816 0 -101.144816 l 61.8367 -35.7014353 c 0 0 3.4397 163.2238013 0 166.6635013 -3.43971 3.4397 3.43797 92.71158 0 -09.79038 111.62221 -29.90908 -1.663 -1.663 48.4343 -62.26457 62.26458 -62.26457 13.83027 0 64.102 -25.23927 39.46401 -39.46402 -24.63799 -14.2247 5 -10.13639 -52.857128 -91.55123 -52.857128 -81.41484 0 -83.94149 14.675378 -138.71074 0 C 184.9381 60.997074 170.39578 44.147238 155.07194 52.99446 139.7481 61.841683 255.49296 180.06991 255.49296 180.06991

c# wpf animation frame-rate
1个回答
0
投票

StreamGeometry对象是PathGeometry的轻型替代方案,用于创建几何形状。需要描述复杂的几何图形时,请使用StreamGeometry。 StreamGeometry经过优化,可处理许多PathGeometry对象,与使用许多单个PathGeometry对象相比,性能更好。

© www.soinside.com 2019 - 2024. All rights reserved.