OEKGYL6XZFMUSQPDFFMGGNAPDDKNW4XJNY6ALYQILBLNCRD5BFRAC
XF75MWE3S7HPZXDNR5A5BCRAYO3AYCPUQ4KS6JAAH5DWJRYBKJTQC
5BA7VZ3D36S2TC7NZ64R3O364TGXPY5BJUJTGCFZHWZ6JWAXJMUQC
BHSJJQZKFNLL4KWBKDU5MUWK5HZ7HGNXUFC2UHAEGTIXN7ARY3UAC
YNOQHSPKQHAODMORMW4GKQZK5SCC2LYAFLJHH3GEMZTDM7N52JAAC
import React, { useEffect, useRef } from "react";
import React, { useEffect, useRef, useState } from "react";
* @param props
const [counter, setCounter] = useState(0);
const [width, height, pixelRatio] = [100, 100, 1.0];
const [width, height, pixelRatio] = [200, 100, 1.0]; useEffect(() => { const current: HTMLCanvasElement = canvasRef.current!; current.onclick = (e) => { console.log(e); }; }, []);
const [width, height, pixelRatio] = [200, 100, 1.0];
useEffect(() => {
const current: HTMLCanvasElement = canvasRef.current!;
current.onclick = (e) => {
console.log(e);
};
}, []);
if (!counter) { initialBackground(); }
if (!counter) {
initialBackground();
}
ctx.save(); ctx.scale(pixelRatio, pixelRatio); ctx.fillStyle = "hsl(0, 0%, 95%)"; ctx.fillRect(0, 0, width, height);
ctx.save();
ctx.scale(pixelRatio, pixelRatio);
ctx.fillStyle = "hsl(0, 0%, 95%)";
ctx.fillRect(0, 0, width, height);
ctx.arc(width / 2, height / 2, width / 4, 0, Math.PI * 2);
ctx.arc(width / 2 + counter, height / 2, width / 4, 0, Math.PI * 2);
ctx.restore(); });
ctx.restore();
});
}, [counter]);
const initialBackground = () => { const canvas: HTMLCanvasElement = canvasRef.current as any; const ctx = canvas.getContext("2d")!; ctx.save(); ctx.scale(pixelRatio, pixelRatio); ctx.fillStyle = "hsl(0, 0%, 95%)"; ctx.fillRect(0, 0, width, height); ctx.restore(); };
const initialBackground = () => {
const canvas: HTMLCanvasElement = canvasRef.current as any;
const ctx = canvas.getContext("2d")!;
console.log(e.target); setCounter((count) => count + 1);
console.log(e.target);
setCounter((count) => count + 1);