[ html canvas globalCompositeOperation ] canvas绘图属性 设置合成图像如何显示 属性演示

 <!DOCTYPE html>
<html lang='zh-cn'>
<head>
<title>Insert you title</title>
<meta name='description' content='this is my page'>
<meta name='keywords' content='keyword1,keyword2,keyword3'>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel='stylesheet' type='text/css' href='./css/index.css' />
<script type='text/javascript' src='./js/jquery-1.12.1.min.js'></script>
<style type='text/css'>
html,body,canvas,div,select,option {
margin: 0; padding: 0;
} html {
height: 100%;
} body {
background: #666;
} #can {
display: block; margin: 25px auto; background: #FFF; border-radius: 2px;
}
</style>
<script type='text/javascript'>
$( document ).ready( function(){
var can = $( '#can' ).get( 0 );
var oCan = can.getContext( '2d' );
oCan.beginPath();
oCan.fillStyle = '#F00';
oCan.fillRect( 100 , 100 , 100 , 100 );
oCan.save();
oCan.globalAlpha = .5;
/*
global : 全球
composite : 混合物
operation : 操作 作用
object.globalCompositeOperatin : 设置或返回新图像是如何绘制到已有的图像上的
属性:
原图像指后绘制的图像,目标图像指已经存在的图像 source-over : 默认 设置目标图像显示在原图像上
source-atop : 在目标图像的顶部显示原图像,原图像位于目标图像之外的部分是不可见的
source-in : 在目标图像中显示原图像,只有目标图像中的原图像会部分显示,目标图像是透明的
source-out : 在目标图像之外显示原图像,只会显示目标图像之外的原图像部分,目标图像是透明的 destination-over : 在原图像上方显示目标图像
destination-atop: 在原图像的顶部显示目标图像,原图像之外的目标图像部分是不可见得
destination-in : 在原图像中显示目标图像,只有愿图像内的目标图像会部分得以显示,原图像是透明
destination-out:在原图像之外显示目标图像,只会显示原图像外的目标图像会部分得以显示,愿图像透明
lighter : 愿图像+目标图像 (交互部分会以合成颜色进行显示)
copy : 显示原图像 , 忽视目标图像
xor : 使用异或对原图像和目标图像进行整合
*/
/* oCan.globalCompositeOperation = 'source-over'; */
/* oCan.globalCompositeOperation = 'destination-over'; */
/* oCan.globalCompositeOperation = 'source-atop'; */
/* oCan.globalCompositeOperation = 'destination-atop'; */
/* oCan.globalCompositeOperation = 'source-in'; */
/* oCan.globalCompositeOperation = 'destination-in'; */
/* oCan.globalCompositeOperation = 'source-out'; */
/* oCan.globalCompositeOperation = 'destination-out'; */
/* oCan.globalCompositeOperation = 'lighter'; */
/* oCan.globalCompositeOperation = 'copy'; */
/* oCan.globalCompositeOperation = 'xor'; */
oCan.globalCompositeOperation = 'destination-in';
oCan.fillStyle = '#0F0';
oCan.fillRect( 150 , 150 , 100 , 100 );
oCan.restore();
oCan.closePath();
} )
</script>
</head>
<body>
<canvas id='can' width='500' height='450'>检测到您的浏览器版本过低请升级您的浏览器以获取更好的用户体验...</canvas>
</body>
</html>
上一篇:在C#应用程序中,利用表值参数过滤重复,批量向数据库导入数据,并且返回重复数据


下一篇:ftp服务器搭建(windows)+实现ftp图片上传对接