arcgis js 4 使用pixi.js 实现贝塞尔曲线飞线
我们已经知道怎么实现贝塞尔曲线, 那么贝赛尔飞线 我们可以模拟sprite 沿着线的轨迹运动有点像飞线的感觉了
首先数据结构定义 其中多了graph 相关就是拖尾运动sprite的设置
-
let option = {
-
renderer:{
-
type: "simple",
-
symbol: {
-
lineColor: "#14ff34",
-
lineWidth: 2,
-
graphColor: "#f4fdff",
-
graphRadius: 3,
-
graphSpeed: 0.5
-
}
-
},
-
data: [
-
{
-
geometry: [
-
[12958063.6570659, 4857420.273468611],
-
[12716675.521741385, 3593151.825632137]
-
],
-
attributes: {
-
name: "北京-武汉",
-
}
-
},
-
{
-
geometry: [[12609052.185915885, 2656339.6069692653],
-
[11855688.835137373, 3458622.655850267]],
-
attributes: {
-
name: "广州-重庆",
-
}
-
},
-
{
-
geometry: [[12609052.185915885, 2656339.6069692653],
-
[13521404.55552746, 3666531.372785874]],
-
attributes: {
-
name: "广州-上海",
-
}
-
},
-
{
-
geometry: [[12609052.185915885, 2656339.6069692653],
-
[13785570.925280986, 1381981.4713991268]],
-
attributes: {
-
name: "广州-菲律宾",
-
}
-
}
-
]
-
};
我们通过一些全局变量保存一些信息
-
//requestAnimationFrame 的id 方便取消动画用
-
this.raf;
-
// 保存小球的数组
-
this.circles = [];
-
this.markT = 0;
-
//获取小球的运动速度,因为样式更改中还要用到该属性,所以在构造函数中定义
-
this.graphSpeed = this.options.renderer.symbol.graphSpeed;
在初始的时候
```javascript
for (let i in data) {
let item = data[i];
//添加贝塞尔曲线参考上一章
/----------------------------------------------/
-
//画一组8个小球,放入列表中
-
let balls = [];
-
for (let i = 0; i < 8; i++) {
-
let circle = new PIXI.Graphics();
-
//小球透明度逐渐减小
-
let alpha = 1/(i*0.5 + 1);
更多参考 https://xiaozhuanlan.com/topic/0821647935
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律