) {
+ if (!zeichnetRef.current) return;
+ const canvas = canvasRef.current;
+ const ctx = canvas?.getContext("2d");
+ if (!ctx) return;
+ const { x, y } = getPos(event);
+ ctx.lineWidth = 2;
+ ctx.lineCap = "round";
+ ctx.strokeStyle = "#1a1a1a";
+ ctx.lineTo(x, y);
+ ctx.stroke();
+ setHatInhalt(true);
+ }
+
+ function onPointerUp() {
+ zeichnetRef.current = false;
+ const canvas = canvasRef.current;
+ if (canvas) {
+ setDataUrl(canvas.toDataURL("image/png"));
+ }
+ }
+
+ function loeschen() {
+ const canvas = canvasRef.current;
+ const ctx = canvas?.getContext("2d");
+ if (canvas && ctx) {
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
+ }
+ setHatInhalt(false);
+ setDataUrl("");
+ }
+
+ return (
+
+
+
+ {hatInhalt && (
+
+ )}
+
+ );
+}