当前位置:网站首页>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 填充渐变,请看我另一篇文章:点击查看
边栏推荐
- seven point two three
- [advanced mathematics] [6] differential calculus of multivariate functions
- "Shallow in and shallow out" MySQL and InnoDB [it is recommended to collect and share]
- [today in history] July 3: ergonomic standards act; The birth of pioneers in the field of consumer electronics; Ubisoft releases uplay
- leetcode-79:单词搜索
- Use Navicat to connect to MySQL database through SSH channel (pro test is feasible)
- The database empties the table data and makes the primary key start from 1
- Compilation and operation of program
- 毕业从事弱电3个月,我为什么会选择转行网络工程师
- [today in history] July 18: Intel was founded; The first photo was posted on the world wide web; EBay spins off PayPal
猜你喜欢
![[today in history] June 29: SGI and MIPS merged; Microsoft acquires PowerPoint developer; News corporation sells MySpace](/img/86/abeb82927803712a98d2018421c3a7.png)
[today in history] June 29: SGI and MIPS merged; Microsoft acquires PowerPoint developer; News corporation sells MySpace

Google guava is just a brother. What is the real king of caching? (glory Collection Edition)

How to use buffer queue to realize high concurrent order business (glory Collection Edition)

Learn FPGA from the bottom structure (16) -- customization and testing of pll/mmcm IP

网络协议:TCP Part2

增加 swap 空间

ROS_ Rqt toolbox
![[advanced drawing of single cell] 07. Display of KEGG enrichment results](/img/60/09c5f44d64b96c6e4d57e5f426e4ed.png)
[advanced drawing of single cell] 07. Display of KEGG enrichment results
![[today in history] July 17: Softbank acquired arm; The first email interruption; Wikimedia International Conference](/img/0f/8ce2d5487b16d38a152cfd3ab454bb.png)
[today in history] July 17: Softbank acquired arm; The first email interruption; Wikimedia International Conference

leetcode-6131:不可能得到的最短骰子序列
随机推荐
Today's sleep quality record 75 points
"Shallow in and shallow out" MySQL and InnoDB [it is recommended to collect and share]
Docker builds redis cluster
Golang language quickly get started to comprehensive practical notes (go language, beego framework, high concurrency chat room, crawler)
leetcode-6130:设计数字容器系统
【NOI模拟赛】字符串匹配(后缀自动机SAM,莫队,分块)
leetcode-79:单词搜索
每条你收藏的资讯背后,都离不开TA
Why did I choose to become a network engineer after graduating from weak current for 3 months
Leetcode-6129: number of all 0 subarrays
476-82(322、64、2、46、62、114)
leetcode-6125:相等行列对
[onnx] export pytorch model to onnx format: support multi parameter and dynamic input
Matlab---eeglab check EEG signal
preprocessor directives
Explain in detail the principle of MySQL master-slave replication "suggestions collection"
[advanced mathematics] [6] differential calculus of multivariate functions
[leetcode] 28. Implement strstr ()
Implementation of simple registration and login
Introduction to MySQL engine and InnoDB logical storage structure