旋转(以中心点为例)
ctx.save();ctx.translate(x, y);ctx.rotate(rotate * Math.PI / 180);ctx.translate(-x, -y);// 在此处绘制ctx.restore();
渐变色(从上往下)
let grad = ctx.createLinearGradient(0, 0, 0, screenHeight);grad.addColorStop(0, 'rgb(105, 230, 240)');grad.addColorStop(1, 'rgb(157, 226, 196)');// 绘制// ctx.fillStyle = grad;// ctx.fillRect();
缩放(中心点)
ctx.save();ctx.translate(centerX * (1 - scale), centerY * (1 - scale));ctx.scale(scale, scale);// 在此处绘制ctx.restore();
文字描边
ctx.lineWidth = 2; // 非必须ctx.strokeStyle = '#ffffff';ctx.strokeText('文字', x, y);ctx.fillStyle = '#f77a25';ctx.fillText('文字', x, y);// stroke fill顺序不同造成效果不同,谁后写,谁效果更大!
