当前位置:网站首页>Cesium 多边形渐变色纹理(Canvas)
Cesium 多边形渐变色纹理(Canvas)
2022-07-25 20:44:00 【最凶残的小海豹】
可以直接使用:Cesium.ImageMaterialProperty(options)方法给Material赋值。
// 绘制canvas渐变(这里用的是 径向/圆 渐变)
var canvas = document.getElementById("myCanvas");
if (canvas && canvas.getContext) {
let ctx = canvas.getContext("2d");
var grad = ctx.createRadialGradient(200, 200, 50, 260, 260, 200) // 创建一个渐变色径向/圆对象
grad.addColorStop(0, "rgba(240,250,40,1)"); // 设置渐变颜色
grad.addColorStop(0.25, "rgba(327,201,64,1)");
grad.addColorStop(0.5, "rgba(22,184,200,1)");
grad.addColorStop(1, "rgba(82,67,192,1)");
ctx.fillStyle = grad; // 设置fillStyle为当前的渐变对象
ctx.fillRect(0, 0, 500, 500); // 绘制渐变图形
}
// 绘制多边形
viewer.entities.add({
polygon: {
// 获取指定属性(positions,holes(图形内需要挖空的区域))
hierarchy: {
positions: Cesium.Cartesian3.fromDegreesArray([
120.9677706, 30.7985748,
110.20, 34.55,
120.20, 50.55
]),
},
extrudedHeight: 0.0,
// 这里可以直接使用canvas元素
material: new Cesium.ImageMaterialProperty({
image: document.getElementById('myCanvas'),
transparent: true
}),
closeTop: false,
closeBottom: false
}
});
// 用完可以删除之前绘制的canvas
document.getElementById('myCanvas').remove();

canvas 填充渐变,请看我另一篇文章:点击查看
边栏推荐
- 增加 swap 空间
- 【TensorRT】动态batch进行推理
- 第六章 修改规范(SPEC)类
- Using the OAP aspect causes the controller to be called repeatedly
- [today in history] July 17: Softbank acquired arm; The first email interruption; Wikimedia International Conference
- Leetcode customs clearance: hash table six, this is really a little simple
- Follow up of Arlo's thinking
- Question and answer 47: geeks have an appointment - the current monitoring system construction of CSC
- Miscellaneous notes -- a hodgepodge
- Today's sleep quality record 75 points
猜你喜欢
![[cloud native] use of Nacos taskmanager task management](/img/af/f1c5359e7dbcf51f02fa32839539b2.png)
[cloud native] use of Nacos taskmanager task management

结构体,枚举类型与联合体

Success factors of software R & D effectiveness measurement

Yolov7 training error indexerror: list index out of range

【TensorRT】动态batch进行推理

Character function and string function (2)

增加 swap 空间

Leetcode customs clearance: hash table six, this is really a little simple

程序的编译和运行

ROS_ Rqt toolbox
随机推荐
LeetCode通关:哈希表六连,这个还真有点简单
PayPal PHP product trial period "recommended collection"
智能电子界桩自然保护区远程监控解决方案
Detailed explanation of document operation
Mobile web layout method
Yolov7 training error indexerror: list index out of range
Clickhouse notes 02 -- installation test clickvisual
Leetcode-6127: number of high-quality pairs
Docker 搭建 Redis Cluster集群
Fanoutexchange switch code tutorial
Myormframeworkjdbc review and problem analysis of user-defined persistence layer framework, and thought analysis of user-defined persistence layer framework
Automated testing ----- selenium (I)
Basic knowledge of Marine Geology
Today's sleep quality record 75 points
Using the OAP aspect causes the controller to be called repeatedly
Docker builds redis cluster
“链”接无限可能:数字资产链,精彩马上来!
Rand1 generates rand9
Key network protocols in tcp/ip four layer model
2022.7.24-----leetcode.1184