简体   繁体   English

画布绘图工具

[英]Canvas drawing tool

How can I get the same effect on canvas like it's shown in the image below (source: here ) 如何在画布上获得相同的效果,如下图所示(来源: here 在此处输入图片说明

I try something like this LINK 我尝试这样的链接

e.preventDefault();
var x =  e.pageX;
var y =  e.pageY;
if (!drawing) return
ctx.beginPath();
ctx.globalAlpha = .3;
ctx.lineJoin ='round';
ctx.lineCap = 'butt'
ctx.shadowBlur = 0;
//ctx.globalCompositeOperation = "copy";
ctx.moveTo(prev.x, prev.y);
ctx.strokeStyle = '#000';
//ctx.strokeStyle = 'rgba(100,0,0,0.1)';
ctx.lineTo(x, y);
ctx.lineWidth = 20;
ctx.stroke();
ctx.closePath();
prev.x = x;
prev.y = y;

It looks like you almost have the effect you want. 看起来您几乎可以达到想要的效果。

(semi-transparent, overlapping rounded strokes with opacity accumulating where they overlap). (半透明,重叠的圆形笔触,在不重叠的地方累积不透明)。

Try changing the globalAlpha to .03 instead of .3. 尝试将globalAlpha更改为.03而不是3。

I've branched your jsFiddle, but I've amended the colour and alpha transparency a bit to get the same colour (ish) as your image : 我已经将您的jsFiddle分支了,但是我对颜色和alpha透明度做了一些修改,以获得与您的图像相同的颜色(ish):

http://jsfiddle.net/rsc8k/2/ http://jsfiddle.net/rsc8k/2/

ctx.globalAlpha = .1;
ctx.strokeStyle = '#337799';

Looks pretty similar. 看起来很相似。 Note that that's all the changes I've made on your jsfiddle. 请注意,这就是我对jsfiddle所做的所有更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM