HTML5 canvas 合成属性
2024-10-14 13:39:14
合成属性
globalAlpha 设置或返回绘图的当前 alpha 或透明值
globalCompositeOperation 设置或返回新图像如何绘制到已有的图像上
<script type="text/javascript">
var arr=new Array();
arr.push("source-atop");
arr.push("source-in");
arr.push("source-out");
arr.push("source-over");
arr.push("destination-atop");
arr.push("destination-in");
arr.push("destination-out");
arr.push("destination-over");
arr.push("lighter");
arr.push("copy");
arr.push("xor");
for (var i=0;i<arr.length;i++){
document.write("<div id='p_"+ i +"'style='float:left;border:1px solid #000'>"+arr[i]+":<br>");
var c=document.createElement("canvas");
c.width=120;
c.height=100;
document.getElementById("p_"+i).appendChild(c);
var ctx=c.getContext("2d");
ctx.fillStyle="blue";
ctx.fillRect(10,10,50,50);
ctx.globalCompositeOperation=arr[i];//设置或返回新图像如何绘制到已有的图像上
ctx.beginPath();
ctx.fillStyle="red";
ctx.globalAlpha=0.8; //设置或返回绘图的当前 alpha 或透明值
ctx.arc(50,50,30,0,2*Math.PI);
ctx.fill();
document.write("</div>");
}
</script>
最新文章
- MS SQL巡检系列&mdash;&mdash;检查重复索引
- UDP Server
- python之初级学习
- SQL查询数据库中所有指定类型的字段名称和所在的表名
- WPF 竖排文字
- Android 4.4 KitKat, the browser and the Chrome WebView
- Selenium2Library系列 keywords 之 _SelectElementKeywords 之 list_should_have_no_selections(self, locator)
- javaweb项目的优化 - 几番思念
- iOS之ViewController的多层presentViewController的dismiss问题
- EOS智能合约存储实例讲解
- Python_程序实现发红包
- React+ES6+Webpack深入浅出
- 【LeetCode每天一题】4Sum(4数之和)
- SQL server 数据库的数据完整性
- C# 获取汉字拼音首字母/全拼
- 删除node_modules
- AngularJs(SPA)单页面SEO以及百度统计应用(上)
- gym 100531 三维几何+搜索
- 迭代最近点算法 Iterative Closest Points
- linux 常用操作以及概念
热门文章
- IIS的安装与配置详细图解教程。
- (转载)偏序集的Dilworth定理学习
- oracle连接总结(内连接、外连接、自然连接,交叉连接,自连接)
- 如何编写一个JSON解析器
- iOS键盘覆盖输入框的处理.doc
- Android 物理按键
- struts2在web.xml中配置详情
- android 使用String.format(";%.2f";,67.876)自已定义语言(俄语、西班牙语)会把小数点变为逗号
- HttpWebRequest get/post方法实现
- xheditor编辑器上传截图图片抓取远程图片代码