import React, { useState, useEffect, useRef, useCallback } from "react"; import { Download, Upload, Share2, BookOpen, Linkedin, Menu, X, Feather, Crown, RotateCcw, } from "lucide-react"; const App = () => { const [currentSection, setCurrentSection] = useState("home"); const [mobileMenuOpen, setMobileMenuOpen] = useState(false); const [scrollY, setScrollY] = useState(0); const [isLoaded, setIsLoaded] = useState(false); const [uploadedImage, setUploadedImage] = useState(null); const [processedImageUrl, setProcessedImageUrl] = useState( null ); const [isProcessing, setIsProcessing] = useState(false); const [generatorSettings, setGeneratorSettings] = useState({ quality: "low", palette: "math", }); const canvasRef = useRef(null); useEffect(() => { const handleScroll = () => setScrollY(window.scrollY); window.addEventListener("scroll", handleScroll); return () => window.removeEventListener("scroll", handleScroll); }, []); useEffect(() => setIsLoaded(true), []); const processImage = async (imageFile: File) => { // Normalize values before sending const quality = generatorSettings.quality.toLowerCase(); const palette = generatorSettings.palette.toLowerCase(); const fd = new FormData(); fd.append("file", imageFile); fd.append("quality", quality); fd.append("palette", palette); console.log("Sending to backend:", { quality, palette, file: imageFile.name, }); try { setIsProcessing(true); const apiUrl = import.meta.env.DEV ? "http://localhost:5000/process" : "/process"; const res = await fetch(apiUrl, { method: "POST", body: fd, }); if (!res.ok) { const err = await res.json().catch(() => null); throw new Error(err?.detail || `Server returned ${res.status}`); } const blob = await res.blob(); const url = URL.createObjectURL(blob); setProcessedImageUrl(url); } catch (err: any) { console.error("Processing failed:", err); alert("Processing failed: " + (err.message || err)); } finally { setIsProcessing(false); } }; const handleImageUpload = async (e: React.ChangeEvent) => { const file = e.target.files?.[0]; if (!file) return; setUploadedImage(file); setProcessedImageUrl(null); await processImage(file); }; const handleRegenerate = async () => { if (!uploadedImage) return; setProcessedImageUrl(null); await processImage(uploadedImage); }; const exportCanvas = () => { if (processedImageUrl) { const link = document.createElement("a"); link.href = processedImageUrl; link.download = "symbol_art.png"; document.body.appendChild(link); link.click(); document.body.removeChild(link); } }; const shareArt = () => { alert("Sharing functionality is not implemented yet."); }; const renderNav = useCallback(() => { const navItems = [ { name: "Home", section: "home", icon: , }, { name: "About", section: "about", icon: , }, ]; return ( ); }, [scrollY, currentSection, mobileMenuOpen]); // Reusable ornate button component for quality selection const QualityButton = ({ value, label }: { value: string, label: string }) => ( ); const renderSection = () => (
{/* Home Section */} {currentSection === "home" && (
{/* Decorative background elements */}

The Art of
Equations

"Logic and beauty are two sides of the same coin. Let your images speak the language of the universe."

{/* Canvas & Controls Section */}

Your Canvas

{/* The Frame / Display */}
{isProcessing ? (

Weaving Symbols...

) : processedImageUrl ? ( Processed Art ) : (

"Silence awaits your vision."

)}
{/* The Controls */}
{/* Upload */}

1. The Source

Select the image you wish to transmute.

{/* Settings */}

2. The Complexity

{/* Preserving exactly the titles: Low, Medium */}
{/* Regenerate Button */} {uploadedImage && (
)}
)} {/* About Section */} {currentSection === "about" && (

The Philosophy

In a world of pixels, we search for meaning. Symbol Art is not just a generator; it is an exploration of the underlying mathematical beauty that governs our reality.

By converting raw imagery into fundamental symbols, we strip away the noise and reveal the structural elegance hidden within. It is a tribute to the language of the universe.

)} {/* FOOTER: 'Where it is made' functionality preservation */}
Symbol Art
"Where Logic Meets Emotion"
{/* Preserved attribution */}

Created by Rizul Garg

); return (
{renderNav()} {renderSection()}
); }; export default App;