当前位置:网站首页>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 填充渐变,请看我另一篇文章:点击查看
边栏推荐
- [advanced mathematics] [3] Application of differential mean value theorem and derivative
- 毕业从事弱电3个月,我为什么会选择转行网络工程师
- [today in history] July 5: the mother of Google was born; Two Turing Award pioneers born on the same day
- Volcanic engine Xiang Liang: machine learning and intelligent recommendation platform multi cloud deployment solution officially released
- [today in history] July 2: BitTorrent came out; The commercial system linspire was acquired; Sony deploys Playstation now
- [technical dry goods] how to ensure the idempotency of the interface?
- "Shallow in and shallow out" MySQL and InnoDB [it is recommended to collect and share]
- [today in history] July 7: release of C; Chrome OS came out; "Legend of swordsman" issued
- MySQL 日期【加号/+】条件筛选问题
- Mobile web layout method
猜你喜欢

476-82(322、64、2、46、62、114)

Card link

【NOI模拟赛】字符串匹配(后缀自动机SAM,莫队,分块)

Go language go language built-in container

103. (cesium chapter) cesium honeycomb diagram (square)

Key network protocols in tcp/ip four layer model

476-82(322、64、2、46、62、114)
![[today in history] July 13: the father of database passed away; Apple buys cups code; IBM chip Alliance](/img/2d/c23a367c9e8e2806ffd5384de273d2.png)
[today in history] July 13: the father of database passed away; Apple buys cups code; IBM chip Alliance
![[tensorrt] dynamic batch reasoning](/img/59/42ed0074de7162887bfe2c81891e20.png)
[tensorrt] dynamic batch reasoning
![[today in history] July 15: Mozilla foundation was officially established; The first operation of Enigma cipher machine; Nintendo launches FC game console](/img/7d/7a01c8c6923077d6c201bf1ae02c8c.png)
[today in history] July 15: Mozilla foundation was officially established; The first operation of Enigma cipher machine; Nintendo launches FC game console
随机推荐
Matlab---eeglab check EEG signal
[today in history] July 1: the father of time-sharing system was born; Alipay launched barcode payment; The first TV advertisement in the world
MPI学习笔记(二):矩阵相乘的两种实现方法
【ONNX】pytorch模型导出成ONNX格式:支持多参数与动态输入
Yolov7 training error indexerror: list index out of range
Scan delete folder problems
[advanced mathematics] [1] function, limit, continuity
leetcode-114:二叉树展开为链表
MySQL master-slave replication data synchronization, summary of common problems
Today's sleep quality record 75 points
Principle analysis of bootloader
结构体,枚举类型与联合体
[today in history] June 30: von Neumann published the first draft; The semiconductor war in the late 1990s; CBS acquires CNET
每条你收藏的资讯背后,都离不开TA
Explain in detail the principle of MySQL master-slave replication "suggestions collection"
Card link
【TensorRT】动态batch进行推理
Using the OAP aspect causes the controller to be called repeatedly
476-82(322、64、2、46、62、114)
Leetcode-146: LRU cache