不同手机上的画布线条显示不同的颜色

时间:2017-07-20 10:19:47

标签: javascript canvas mobile

this is dark in a iphone6

this is white in another iphone

在我的代码中,我写了var rgb =' 255'。不同手机上的画布线显示不同的颜色。我不知道它为什么。所以我问你,请告诉我我所做的。谢谢!

//banner cas
!function() {
var canvas = document.getElementById('cas');
var ctx = canvas.getContext('2d');
var rgb = '255';      // 线条颜色值
var extendDis = 5;   // 可超出的画布边界
var lineDis = 100;    // 连线距离
lineDis *= lineDis;
canvas.width = 1920;
canvas.height = 200;

  // 绘制点
  ctx.fillStyle = 'rgba(' + rgb + ', ' + rgb + ', ' + rgb + ', 1';
  ctx.fillRect(dot.x - 0.5, dot.y - 0.5, 1, 1);
}
}();

0 个答案:

没有答案