当前位置:网站首页>Flutter 绘制波浪移动动画效果,曲线和折线图
Flutter 绘制波浪移动动画效果,曲线和折线图
2022-07-05 12:46:00 【岛上码农】
简介
上一篇用 Flutter 的 Canvas 画点有趣的图形我们介绍了使用 CustomPaint 绘制自定义形状,可以看到有了图形的平面绘制数学计算方法,我们可以画出所需的形状。本篇我们来介绍线条类图形的绘制,并且结合 Animation 实现了常见的波浪动效。通过本篇,你可以了解到:
- 正弦曲线的绘制
- 利用两条正弦曲线加上
Animation
实现波浪动效 - 曲线的一般绘制方法
- 折线图绘制
下面是最终实现的效果图,接下来我们一项一项介绍。
正弦曲线绘制
对于正弦曲线,公式定义如下:
对于在屏幕绘制,由于屏幕的点都是离散的,因此实际就是对正弦曲线进行采样,只要采样间隔足够密集,画出来的效果肉眼上很难区分是离散点之间通过连线完成绘制的。因此,绘制正弦曲线其实就是将正弦曲线的点依次连起来就好了。下面是绘制的实现代码,waveHeight
是正弦曲线的振幅,这里我们一个屏幕宽度绘制一个周期,因此使用的是 2 * pi * i / size.width
。
边栏推荐
- About the single step debugging of whether SAP ui5 floating footer is displayed or not and the benefits of using SAP ui5
- MySQL giant pit: update updates should be judged with caution by affecting the number of rows!!!
- 深度长文探讨Join运算的简化和提速
- Vonedao solves the problem of organizational development effectiveness
- 使用 jMeter 对 SAP Spartacus 进行并发性能测试
- 非技术部门,如何参与 DevOps?
- OpenHarmony应用开发之Navigation组件详解
- 研究:数据安全工具在 60% 的情况下无法抵御勒索软件
- I'm doing open source in Didi
- SAP self-development records user login logs and other information
猜你喜欢
2021-12-21 transaction record
10 minute fitness method reading notes (5/5)
Four common problems of e-commerce sellers' refund and cash return, with solutions
Taobao product details API | get baby SKU, main map, evaluation and other API interfaces
Detailed explanation of navigation component of openharmony application development
Simple page request and parsing cases
Research: data security tools cannot resist blackmail software in 60% of cases
Pycharm installation third party library diagram
MySQL giant pit: update updates should be judged with caution by affecting the number of rows!!!
Get to know linkerd project for the first time
随机推荐
ABAP editor in SAP segw transaction code
155. Minimum stack
How to connect the API interface of Taobao open platform (super detailed)
leetcode:221. 最大正方形【dp状态转移的精髓】
NFT: how to make money with unique assets?
2021.12.16-2021.12.20 empty four hand transaction records
函数传递参数小案例
uni-app开发语音识别app,讲究的就是简单快速。
Default parameters of function & multiple methods of function parameters
Taobao short video, why the worse the effect
2021-12-22 transaction record
Introduction to sap ui5 flexiblecolumnlayout control
Difference between JUnit theories and parameterized tests
Pycharm installation third party library diagram
Introduction aux contrôles de la page dynamique SAP ui5
Compile kernel modules separately
SAP UI5 ObjectPageLayout 控件使用方法分享
阿里云SLB负载均衡产品基本概念与购买流程
SAP UI5 DynamicPage 控件介绍
自然语言处理从小白到精通(四):用机器学习做中文邮件内容分类