【发布时间】:2015-06-23 16:10:41
【问题描述】:
所以我尝试在 <canvas> 元素内的对象上使用 globalCompositeOperation,但我的目标是与画布外的对象混合 - 一个普通的 html 标记元素,如段落。
我的最终目标是使用difference 反转页面上的内容,就像 一样
我现有的代码如下。这甚至可能吗?
var canvas = document.getElementById('canvas');
window.onresize=function(){
"use strict";
var winMin = Math.min(window.innerWidth,window.innerHeight);
canvas.width = winMin;
canvas.height = winMin;
var w = winMin / 3;
var ctx = canvas.getContext('2d');
ctx.globalCompositeOperation = 'multiply';
ctx.globalAlpha = .5;
//magenta
ctx.fillStyle = 'rgb(255,0,255)';
ctx.beginPath();
ctx.arc(w, w, w, 0, Math.PI*2, true);
ctx.closePath();
ctx.fill();
//cyan
ctx.fillStyle = 'rgb(0,255,255)';
ctx.beginPath();
ctx.arc(w*2, w, w, 0, Math.PI*2, true);
ctx.closePath();
ctx.fill();
};
window.onresize();
【问题讨论】:
标签: javascript html canvas html5-canvas