cesium 地图颜色滤镜

实现地图颜色滤镜

这是cesium提供的更改地图颜色的效果

ImageryLayer提供了修改 brightness图层亮度 contrast对比度 hue色相 saturation饱和度 gamma伽玛校正 这些属性

但是用完你会发现,调不出来我想要的颜色,产品想要的一个颜色效果,用这些配置根本达不到要求,所以需要增加一个颜色属性,然后再配合这些属性进行微调

修改源码实现

仿照ImageryLayer源码的原有属性的代码,在其相关地方加入filterRGB属性用于设置颜色

这里为了使用方便,对颜色值进行一个调整

上面实现了一种滤镜颜色效果,进一步优化,再增加一种灰度反色滤镜效果。

业务端调用

ts 复制代码
  // 部分代码,业务端调用时修改这些属性就可以了
  let layersLength = this.viewerCesium.imageryLayers.length;
  if (layersLength === 0) return false;

  for (let j = 0; j < layersLength; j++) {
    let imageryLayer = this.viewerCesium.imageryLayers.get(j);
    imageryLayer.alpha = mapBottomParam.alpha;
    imageryLayer.brightness = mapBottomParam.brightness;
    imageryLayer.contrast = mapBottomParam.contrast;
    imageryLayer.saturation = mapBottomParam.saturation;

    if (mapBottomParam.filterColor) {
      const color = Color.fromCssColorString(mapBottomParam.filterColor);
      if (mapMode === 1) {
        // @ts-ignore
        imageryLayer.color = new Cartesian3(color.red, color.green, color.blue);
        // @ts-ignore
        imageryLayer.colorEnable = true;
        // @ts-ignore
        imageryLayer.filterColorEnable = false;
        imageryLayer.gamma = 0.3;
      } else if (mapMode === 3) {
        // @ts-ignore
        imageryLayer.filterColor = new Cartesian3(color.red, color.green, color.blue);
        // @ts-ignore
        imageryLayer.filterColorEnable = true;
        // @ts-ignore
        imageryLayer.colorEnable = false;
      }
    }
  }

效果

相关推荐
共享家95271 小时前
搭建 AI 聊天机器人:”我的人生我做主“
前端·javascript·css·python·pycharm·html·状态模式
Halo_tjn3 小时前
基于封装的专项 知识点
java·前端·python·算法
m0_748229995 小时前
Vue2 vs Vue3:核心差异全解析
前端·javascript·vue.js
C澒5 小时前
前端监控系统的最佳实践
前端·安全·运维开发
xiaoxue..6 小时前
React 手写实现的 KeepAlive 组件
前端·javascript·react.js·面试
hhy_smile6 小时前
Class in Python
java·前端·python
小邓吖6 小时前
自己做了一个工具网站
前端·分布式·后端·中间件·架构·golang
南风知我意9576 小时前
【前端面试2】基础面试(杂项)
前端·面试·职场和发展
LJianK17 小时前
BUG: Uncaught Error: [DecimalError] Invalid argument: .0
前端
No Silver Bullet7 小时前
Nginx 内存不足对Web 应用的影响分析
运维·前端·nginx