从canvas2D 开始
2025/3/24小于 1 分钟
从canvas2D 开始
创建和获取canvas
html<canvas></canvas>
const canvas = document.querySelector("canvas");
const ctx = canvas.getContext("2d");添加图片
const img = new Image();
img.src = "https://example.com/image.jpg";
img.onload = () => {
ctx.drawImage(img, 0, 0);
};添加文字
ctx.font = "30px Arial";
ctx.fillStyle = "red";
ctx.fillText("Hello, World!", 10, 50);