避免用影像文档创建网页背景, 可以免去 查找/管理/保存 与网页有关的许多影像文档。
1. 为 html 元素 <div id="cloud"> 创建 非动画 背景:首先在一个不显示(display:none)的
画布(canvas id="can")上用画笔(g)绘出背景,然后用一行代码,就可以搞定:
document.getElementById('cloud').style.backgroundImage = 'url("' + g.canvas.toDataURL() + '")';
案例:
https://runjs.cn/detail/cxknild9
https://runjs.cn/detail/zn51nmko
https://runjs.cn/detail/hahpkvjs
https://runjs.cn/detail/vp4oui3l
2. 为html元素 <div id="cloud"> 创建 动画 背景:只好在 html元素 <div id="cloud"> 的
下面(下一层,即 使用更小的 CSS 的属性 z-index 值),设置画布(canvas)。作为 html 元
素 <div> 的背景,在画布上创建动画。