Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript HTML5画布颜料混合颜色工具_Javascript_Html_Canvas_Brush - Fatal编程技术网

Javascript HTML5画布颜料混合颜色工具

Javascript HTML5画布颜料混合颜色工具,javascript,html,canvas,brush,Javascript,Html,Canvas,Brush,您好,我需要创建混合颜色工具,我尝试使用getImageData从画布中获取颜色像素,并与我选择的颜色混合,获得平均颜色,我可以轻松获得: /* r1 = red channel from getImageData g1 = green channel from getImageData b1 = blue channel from getImageData r2 = red channel my selected color g2,b2 same */ var

您好,我需要创建混合颜色工具,我尝试使用getImageData从画布中获取颜色像素,并与我选择的颜色混合,获得平均颜色,我可以轻松获得:

/* r1 = red channel from getImageData
   g1 = green channel from getImageData
   b1 = blue channel from getImageData

   r2 = red channel my selected color
   g2,b2 same
*/   
var avR = Math.round(0.5*r1 + 0.5*r2);
var avG = Math.round(0.5*g1 + 0.5*g2);
var avB = Math.round(0.5*b1 + 0.5*b2);
当我画画时,我尝试混合这种颜色,但混合效果不可用

也许有人能帮我?

我需要那个工具可以在左边得到图像:
您没有说明足够的细节,但下面是如何在画布上使用混合模式。请注意,IE目前还不支持这些功能,除非是普通功能,所以请在最近的Firefox或Chrome中进行测试

当前修订的画布标准中的所有混合模式都列在可用于选择模式的下拉列表中。通过这种方式,您可以看到哪种模式最适合您的需要尝试一些事情,例如以低alpha值的强光作为开始

是的,我觉得很无聊

var cont=document.getElementByIdspots,//UI元素 canvas=document.getElementByIdcanvas, alpha=document.getElementByIdalpha, modes=document.getElementByIdmodes, ctx=canvas.getContext2d, isDown=false,//默认值 颜色=rgb107、122、174; //使用自定义聚光灯对象设置调色板 //这将在单击时使用回调函数,以 //更改当前颜色 函数Spotcolor,cont,回调{ var div=document.createElementdiv; div.style.cssText=宽度:50px;高度:50px;边框:1px实心000;边距:0 1px 1px 0;背景:+颜色; div.onclick=函数{callbackcolor}; 续:附件二; } //在调色板容器中添加一些专色 新Spotcolor,cont,setColor; 新Spotrgb107、174、170,续,setColor; 新Spot00f,cont,setColor; 新Spotff0,cont,setColor; 新Spot0ff,cont,setColor; 新Spotf0f,cont,setColor; //这将根据单击的点设置当前填充样式 函数setColorc{ctx.fillStyle=c} //设置默认值 ctx.fillStyle=颜色; ctx.globalAlpha=0.5; //事件 canvas.onmousedown=函数{isDown=true}; window.onmouseup=函数{isDown=false}; window.onmousemove=函数e{ 如果!是向下返回; var r=canvas.getBoundingClientRect, x=e.clientX-r.left, y=e.clientY-r.top; ctx.beginPath; ctx.arcx,y,25,0,2*Math.PI; ctx.fill; }; alpha.onchange=函数{ctx.globalAlpha=alpha.value*0.01}; modes.onchange=函数{ctx.globalCompositeOperation=modes.value}; 正文{字体:14px无衬线;背景:333;颜色:eee} 斑点{float:right} 画布{背景:fff;光标:十字线;边框:1px solid 777} 混合模式: 典型的 乘 屏幕 覆盖 变暗 减轻 颜色减淡 色斑 强光 柔和的光线 差别 排斥 颜色 饱和 颜色 光度 阿尔法:
您没有陈述足够的细节,但下面是如何使用画布的混合模式。请注意,IE目前还不支持这些功能,除非是普通功能,所以请在最近的Firefox或Chrome中进行测试

当前修订的画布标准中的所有混合模式都列在可用于选择模式的下拉列表中。通过这种方式,您可以看到哪种模式最适合您的需要尝试一些事情,例如以低alpha值的强光作为开始

是的,我觉得很无聊

var cont=document.getElementByIdspots,//UI元素 canvas=document.getElementByIdcanvas, alpha=document.getElementByIdalpha, modes=document.getElementByIdmodes, ctx=canvas.getContext2d, isDown=false,//默认值 颜色=rgb107、122、174; //使用自定义聚光灯对象设置调色板 //这将在单击时使用回调函数,以 //更改当前颜色 函数Spotcolor,cont,回调{ var div=document.createElementdiv; div.style.cssText=宽度:50px;高度:50px;边框:1px实心000;边距:0 1px 1px 0;背景:+颜色; div.onclick=函数{callbackcolor}; 续:附件二; } //在调色板容器中添加一些专色 新Spotcolor,cont,setColor; 新Spotrgb107、174、170,续,setColor; 新Spot00f,cont,setColor; 新Spotff0,cont,setColor; 新Spot0ff,cont,setColor; 新Spotf0f,cont,setColor; //这将根据单击的点设置当前填充样式 函数setColorc{ctx.fillStyle=c} //设置默认值 ctx.fillStyle=颜色; ctx.globalAlpha=0.5; //事件 canvas.onmousedown=函数{isDown=true}; window.onmouseup=函数{isDown=false}; window.onmousemove=函数e{ 如果!是向下返回; var r=canvas.getBoundingClientRect, x=e.clientX-r.left, y=e.clientY-r.top; ctx.beginPath; ctx.arcx,y,25,0,2*Math.PI; ctx.fill; }; alpha.onchange=函数{ctx.globalAlpha=alpha.value*0.01}; modes.onchange=函数{ctx.globalCompositeOperation=modes.value}; 正文{字体:14px无衬线;背景:333;颜色:eee} 斑点{float:right} 画布{背景:fff;光标:十字线;边框:1px solid 777} 混合模式: 典型的 乘 屏幕 覆盖 变暗 减轻 C 彩色减淡 色斑 强光 柔和的光线 差别 排斥 颜色 饱和 颜色 光度 阿尔法: