资讯动态

【WPF动画】实现水波纹动画进度条

发布时间:2026/10/27 1:12:39 来源:尧图企业网站定制
效果图可以自己绘制成圆形等任意形状到Canvas核心代码部分绘制部分//Value当前进度值 _streamGeometryGetSinGeometry(this.Width, -5,1/30.0,-this.Width this.Width * Value /100, this.Height - this.Height * Value /100);GeometryGroup groupnew GeometryGroup();group.Children.Add(_streamGeometry);Path myPathnew Path{FillBrushes.DarkGreen, Datagroup};//绘制 this.Canvas.Children.Add(myPath);正弦曲线计算波纹///summary/// 正弦曲线计算 ////summary///paramnamewaveWidth水纹宽度/param///paramnamewaveA水纹振幅/param///paramnamewaveW水纹周期/param///paramnameoffsetX位移/param///paramnamecurrentK当前波浪高度/param///returns/returnsprivate StreamGeometry GetSinGeometry(double waveWidth, double waveA, double waveW, double offsetX, double currentK){StreamGeometry gnew StreamGeometry();using StreamGeometryContext ctxg.Open();ctx.BeginFigure(new Point(0, waveWidth), true,true);for(int x0;xwaveWidth;x1){double ywaveA * Math.Sin(x * waveW offsetX) currentK;ctx.LineTo(new Point(x, y), true,true);}ctx.LineTo(new Point(waveWidth, waveWidth), true,true);returng;}源码传送门

读完文章,也想定制专属网站?

尧图设计师 24 小时内与您沟通定制方案

免费获取报价 →
↑