var now = Date.now();
context.fillStyle = context.createPattern(rain, 'repeat');
context.save();
context.translate(-256 + (0.1 * now) % 256, -256 + (0.5 * now) % 256);
context.fillRect(0, 0, 400 + 256, 600 + 256);
context.restore();
其中 context.translate(-256 + (0.1 * now) % 256, -256 + (0.5 * now) % 256);这句不是很明白什么意思,这个坐标变换和256有什么关系,为什么要选这个数字呢?
context.fillStyle = context.createPattern(rain, 'repeat');
context.save();
context.translate(-256 + (0.1 * now) % 256, -256 + (0.5 * now) % 256);
context.fillRect(0, 0, 400 + 256, 600 + 256);
context.restore();
其中 context.translate(-256 + (0.1 * now) % 256, -256 + (0.5 * now) % 256);这句不是很明白什么意思,这个坐标变换和256有什么关系,为什么要选这个数字呢?