arcgis js 4 使用pixi.js滤镜构建一个发光圆

这次我们用pixi.js 做一个发光扩散圆和arcgis js结合

我们先定义一下 传入数据结构

  • let option = {
  • renderer: {
  • type: "simple",
  • symbol: {
  • color: "#ffda1a",
  • radius: 12,
  • width: 2,
  • }
  • },
  • data: [
  • {
  • geometry: [12956152.73135875, 4855356.473704897],
  • attributes: {
  • name: "北京"
  • }
  • },
  • {
  • geometry: [12697872.012783196, 2577456.5937789795],
  • attributes: {
  • name: "深圳"
  • }
  • }
  • ]
  • };

对于缩放动画 我们使用gsap 来建立

  • import {TimelineMax, TweenLite} from "gsap/gsap-core";

对于symbol 里面的color转换 我们写一个方法转成pixi的color 范式

  • function getColor(str: string, alpha = 1){
  • if (alpha > 1 || alpha < 0) {
  • return "透明度 Error value!";
  • }
  • //如果传入常规的颜色值,去除#
  • str = str.toString();
  • if (str.startsWith('#')) {
  • str = str.replace('#', '');
  • }
  • alpha = 255 * alpha;
  • // @ts-ignore
  • alpha = alpha.toString(16);
  • str = alpha + str;
  • alpha = parseInt(str, 16);
  • return alpha;
  • }

对于圆形带有发光效果 我们使用pixi.js 滤镜库

```javascript
//添加发光滤镜
let glow_filter = new GlowFilter(10, 2, 6, g_color, 0.5);

posted @ 2022-01-20 17:18  haibalai  阅读(190)  评论(0编辑  收藏  举报