已采納回答 / Gatling
是cointext.moveTo()? 你到后面4行寫成canvas.moveTo()了? 瀏覽器調(diào)試欄里有報(bào)錯(cuò)吧
2019-06-10
//接上
if(i%2==0){
ctx.strokeStyle='red';
}else{
ctx.strokeStyle='white';
}
ctx.closePath();
ctx.stroke();
}
ctx.restore();
}
if(i%2==0){
ctx.strokeStyle='red';
}else{
ctx.strokeStyle='white';
}
ctx.closePath();
ctx.stroke();
}
ctx.restore();
}
2019-03-30
function dashedLine(x,y,len,dashedLen,rad){
ctx.save();ctx.lineWidth=2;
for(var i= 0; i<len/dashedLen; i++){
ctx.beginPath();
ctx.moveTo((x+dashedLen*i)*Math.cos(rad),(y+dashedLen*i)*Math.sin(rad));
ctx.lineTo((x+dashedLen*(i+1))*Math.cos(rad),(y+dashedLen*(i+1))*Math.sin(rad));
ctx.save();ctx.lineWidth=2;
for(var i= 0; i<len/dashedLen; i++){
ctx.beginPath();
ctx.moveTo((x+dashedLen*i)*Math.cos(rad),(y+dashedLen*i)*Math.sin(rad));
ctx.lineTo((x+dashedLen*(i+1))*Math.cos(rad),(y+dashedLen*(i+1))*Math.sin(rad));
2019-03-30
給大家提供一種在手機(jī)上看效果的實(shí)現(xiàn)方法:
1. 電腦上安裝nginx
2. 配置conf,如下:
server{
listen 3002;
server_name localhost;
location / {
root 你的文件的絕對(duì)路徑目錄;
access_log on;
autoindex on;
}
}
之后查看你的內(nèi)網(wǎng)ip,通過 http://你的內(nèi)網(wǎng)ip:3002/index.html 就可以在手機(jī)上查看效果啦!
1. 電腦上安裝nginx
2. 配置conf,如下:
server{
listen 3002;
server_name localhost;
location / {
root 你的文件的絕對(duì)路徑目錄;
access_log on;
autoindex on;
}
}
之后查看你的內(nèi)網(wǎng)ip,通過 http://你的內(nèi)網(wǎng)ip:3002/index.html 就可以在手機(jī)上查看效果啦!
2019-03-04
由于只能寫300字 所以把canvasWidth,canvasHeight等變量簡(jiǎn)化了一下,可以在同一個(gè)循環(huán)里畫完米線
2018-03-03
虛線可以這樣畫,把一條線分成紅白兩半,然后紅白交替拼接
var size = 35;
for(var i=0;i<size;i++){
context.beginPath();
if(i % 2 == 0){
context.moveTo(cW * i / size, cH * i / size);
context.lineTo(cW * (i+1) / size, cH * (i+1) / size);
context.stroke();
}
}
var size = 35;
for(var i=0;i<size;i++){
context.beginPath();
if(i % 2 == 0){
context.moveTo(cW * i / size, cH * i / size);
context.lineTo(cW * (i+1) / size, cH * (i+1) / size);
context.stroke();
}
}
2018-03-03