这是我的代码,我做错了什么?图像当前显示在浏览器中,但没有减轻...
这是我的HTML代码,它链接到从他们的下载站点构建的custom.js文件(它包括核心和闪电,就是它)
<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript" charset="utf-8" src="pixastic.custom (5).js"></script>
<style>
body {
margin: 0px;
padding: 0px;
}
#myCanvas {
border: 1px solid #9C9898;
}
</style>
<script>
window.onload = function() {
var canvas = document.getElementById("myCanvas");
var context = canvas.getContext("2d");
var imageObj = new Image();
imageObj.onload = function() {
var options ={};
Pixastic.process(imageObj, "lighten", options)
{amount : .5
};
options.resultCanvas;
context.drawImage(imageObj, 80, 60);
}
imageObj.src = "IMAG8703.jpg";
};
</script>
</head>
<body>
<canvas id="myCanvas" width="2000" height="4000"></canvas>
</body>
</html>
答案 0 :(得分:0)
看起来您的选项语法错误。要么直接在process
函数中传递选项,请执行以下操作:
Pixastic.process(imageObj, "lighten", {amount: .5});
或者,使用以下数量初始化options
变量:
var options = {amount: .5};
Pixastic.process(imageObj, "lighten", options);
修改强>
此外,它在文档中指出,通过调用options.resultCanvas
,您将获得新的画布。所以,听起来你想做的就是把它设置成这样的东西:
canvas = options.resultCanvas;