当前位置:网站首页>Flutter 绘制波浪移动动画效果,曲线和折线图
Flutter 绘制波浪移动动画效果,曲线和折线图
2022-07-05 12:46:00 【岛上码农】
简介
上一篇用 Flutter 的 Canvas 画点有趣的图形我们介绍了使用 CustomPaint 绘制自定义形状,可以看到有了图形的平面绘制数学计算方法,我们可以画出所需的形状。本篇我们来介绍线条类图形的绘制,并且结合 Animation 实现了常见的波浪动效。通过本篇,你可以了解到:
- 正弦曲线的绘制
- 利用两条正弦曲线加上
Animation
实现波浪动效 - 曲线的一般绘制方法
- 折线图绘制
下面是最终实现的效果图,接下来我们一项一项介绍。
正弦曲线绘制
对于正弦曲线,公式定义如下:
对于在屏幕绘制,由于屏幕的点都是离散的,因此实际就是对正弦曲线进行采样,只要采样间隔足够密集,画出来的效果肉眼上很难区分是离散点之间通过连线完成绘制的。因此,绘制正弦曲线其实就是将正弦曲线的点依次连起来就好了。下面是绘制的实现代码,waveHeight
是正弦曲线的振幅,这里我们一个屏幕宽度绘制一个周期,因此使用的是 2 * pi * i / size.width
。
边栏推荐
- Taobao order interface | order flag remarks, may be the most stable and easy-to-use interface
- 奔跑,开路
- Principle and performance analysis of lepton lossless compression
- 我在滴滴做开源
- Simple page request and parsing cases
- Overflow toolbar control in SAP ui5 view
- 2021-12-21 transaction record
- Transactions from January 14 to 19, 2022
- 关于 SAP UI5 getSAPLogonLanguage is not a function 的错误消息以及 API 版本的讨论
- MySQL giant pit: update updates should be judged with caution by affecting the number of rows!!!
猜你喜欢
随机推荐
Setting up sqli lab environment
函数的默认参数&函数参数的多种方法
Kotlin function
Simply take stock reading notes (2/8)
How do e-commerce sellers refund in batches?
Overflow toolbar control in SAP ui5 view
stirring! 2022 open atom global open source summit registration is hot!
Lepton 无损压缩原理及性能分析
关于 SAP UI5 getSAPLogonLanguage is not a function 的错误消息以及 API 版本的讨论
Taobao order interface | order flag remarks, may be the most stable and easy-to-use interface
RHCSA7
A small talk caused by the increase of sweeping
自然语言处理系列(一)入门概述
Laravel文档阅读笔记-mews/captcha的使用(验证码功能)
Natural language processing series (I) introduction overview
【Nacos云原生】阅读源码第一步,本地启动Nacos
阿里云SLB负载均衡产品基本概念与购买流程
将函数放在模块中
HiEngine:可媲美本地的云原生内存数据库引擎
Simply take stock reading notes (4/8)