我有一个用于收集用户签名的画布。线的厚度必须根据片剂的方向而改变。当这个脚本执行时,我希望线条的粗细为6或10,但它仍然是默认值1.有人能够解释为什么吗?
var canvas = $("#signature_canvas")[0];
var context = canvas.getContext("2d");
var pendown = false;
function resize_canvas(){
if(screen.height > screen.width){
context.lineWidth = 6;
canvas.width = screen.width;
canvas.height = (screen.width / screen.height) * screen.width;
}else{
context.lineWidth = 10;
canvas.width = screen.width;
canvas.height = screen.height;
}
};
resize_canvas();
console.log(context.lineWidth);