Create line in canvas word search game

前端 未结 2 1993
孤街浪徒
孤街浪徒 2021-01-07 06:27

I created word search game in canvas. Now I want when user select character for determine word draw line for highlight that but this is my results:

2条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-07 07:06

    Try strokeStyle with rgba and lineCap = 'round'

    var canvas = document.getElementById('myCanvas');
    var context = canvas.getContext('2d');
    context.beginPath();
    context.moveTo(200, 200);
    context.lineTo(400,400);
    context.lineWidth = 20;
    context.strokeStyle = 'rgba(0,0,250,0.5)';
    context.lineCap = 'round';
    context.stroke();
    

    jsfiddle : http://jsfiddle.net/musthaan/0df6Lbfy/

提交回复
热议问题