私はパス化のために正常に動作しているthis code、持っている:ラインを赤と青にする方法は?
をしかし、私はREDとエンドラインBLUEを始める必要がある、私はcontext.strokeStyle =「ブルー」を入れてみました。それは失敗しました。
どうすればいいのですか?
canvas.width = canvas.height = 500;
var context = canvas.getContext('2d');
var shape = new Path2D();
function init(){
context.lineWidth = 1;
context.strokeStyle = 'red';
// RED RED RED
shape.moveTo(100,20);
shape.lineTo(200, 160);
shape.quadraticCurveTo(0, 200, 250, 120);
shape.bezierCurveTo(290, -40, 300, 200, 400, 150);
// BLUE BLUE
//---- make this BLUE BLUE BLUE BLUE not RED RED RED
//---- make this BLUE BLUE BLUE BLUE not RED RED RED
// line 2
//---- make this BLUE BLUE BLUE BLUE not RED RED RED
//---- make this BLUE BLUE BLUE BLUE not RED RED RED
shape.lineTo(500, 90);
draw();
}
var pos = 0;
var l = 760;
function draw() {
context.clearRect(0,0,canvas.width, canvas.height);
context.setLineDash([pos, l-pos]);
context.stroke(shape);
pos = pos+3;
if(pos >= l){
blink();
return;
}
requestAnimationFrame(draw);
};
var i = 0;
function blink(){
context.clearRect(0,0,canvas.width, canvas.height);
if((++i % 30) > 15){
context.stroke(shape);
}
requestAnimationFrame(blink);
};
init();
で描画する私の答えをチェックし...私の答えで – ASK
見て、それはあなたが望む正確な効果を与えるだろう... – ASK