From 105c5b257564b7b832b0ca5384010bba9f327f91 Mon Sep 17 00:00:00 2001 From: Zylan Date: Fri, 25 Apr 2025 01:43:33 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E6=9C=AA=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E7=9A=84Image=E5=AF=BC=E5=85=A5=EF=BC=8C=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=8B=BC=E8=B1=86=E5=9B=BE=E6=A1=88=E7=9A=84=E7=BD=91=E6=A0=BC?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=8C=BA=E5=9F=9F=E5=92=8C=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E6=8C=89=E9=92=AE=EF=BC=8C=E6=9B=B4=E6=96=B0=E9=A1=B5=E8=84=9A?= =?UTF-8?q?=E4=BB=A5=E9=93=BE=E6=8E=A5=E5=88=B0GitHub=E6=BA=90=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/page.tsx | 60 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 57 insertions(+), 3 deletions(-) diff --git a/src/app/page.tsx b/src/app/page.tsx index a7885f8..306209b 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -3,7 +3,7 @@ import React, { useState, useRef, ChangeEvent, DragEvent, useEffect } from 'react'; // Image component from next/image might not be strictly needed if you only use canvas and basic elements, // but keep it if you plan to add other images later or use the SVG icon below. -import Image from 'next/image'; +// Removed unused Image import // Helper function to convert Hex to RGB function hexToRgb(hex: string): { r: number; g: number; b: number } | null { @@ -396,7 +396,6 @@ export default function Home() { return () => clearTimeout(timeoutId); // Cleanup timeout on unmount or change } } - // eslint-disable-next-line react-hooks/exhaustive-deps -- pixelateImage is stable if defined outside useEffect }, [originalImageSrc, granularity]); // Dependencies: run when image or granularity changes // Download function @@ -599,12 +598,67 @@ export default function Home() { )} + + {/* Grid Display Area */} + {mappedPixelData && gridDimensions && ( +
+

拼豆图案 ({gridDimensions.M} x {gridDimensions.N})

+
+ {mappedPixelData.flat().map((cell, index) => ( +
+ {/* Optionally display the key inside */} + {/* {cell.key} */} +
+ ))} +
+ {/* Download Buttons */} +
+ + +
+
+ )} );