/* * ============================================================================================== * File: Smily_Helper_3D_V2.pde * Project: VEXO CLIENT 1 - CLEAN CORE ENGINE (SOLID 3D & SHADED EDITION) * Framework: DTIM-ZEC Modular Physics Framework (DAMTP Academic Standard) * Compatibility: Processing 4.5.6 (Java) & processing.min.js (Web / HTML5 Canvas) * Reference Database: https://xqskys.de * * Licensing: * Source Code (.pde / .php): MIT License * Documents & Open Data: CC0 1.0 Universal * Copyright (c) 2026 Jan Bühring & Adaptive Intelligence Synthesis Network (Google AI) * ============================================================================================== */ // ---------------------------------------------------------------------------------------------- // MODUL 1: DTIM-ZEC SYSTEMKONSTANTEN & ACCESSIBILITY-ARCHITEKTUR (WCAG 2.1 AA) // ---------------------------------------------------------------------------------------------- boolean highContrastMode = false; // Globaler Toggle: Standard <-> High Contrast / Colorblind int GRID_MAX = 105; // Globale Variablen für Vexo-Daten float feld = 10.0; int num = 30; int num1 = 30; int level = 0; int ordner = 0; int iv = 1; int lastSavedFrame = 1; // 3D Voxel-Datenstruktur (Flaches 1D-Array für 100% Kompatibilität zwischen Java & processing.min.js) int[] frameData = new int[105 * 105 * 105]; // Web- / Browser-In-Memory-Speicher (Fallback für localStorage / Browser-Session ohne lokalen Dateizugriff) boolean isWebEnvironment = false; String[] webStorageKeys = new String[256]; String[] webStorageData = new String[256]; int webStorageCount = 0; // Farbwerte int rc = 0, gc = 0, bc = 0; int sc = 0; int rcb = 0, gcb = 0, bcb = 0, scb = 0; // Slider Klick-Historie (Trail mit 4 Stufen / Verblassung) int[] trailR = {-1, -1, -1, -1}; int[] trailG = {-1, -1, -1, -1}; int[] trailB = {-1, -1, -1, -1}; int[] trailBW = {-1, -1, -1, -1}; // Farb-Historie (Palette) int maxHistory = 8; color[] colorHistory = new color[8]; int historyCount = 0; // Zustand & Flags int app = 1; int dom = 1; int los = 0; int start = 0; int dot = 0, dot1 = 0; // Ansichts- & Animations-Optionen boolean show3DView = true; boolean showHelperGrid = true; boolean isPlaying = false; int playTimer = 0; // Online-Modus Variablen boolean onlineActive = false; boolean remoteFrameAvailable = false; String serverBaseUrl = ""; boolean onlineConsentGiven = false; // Visuelles Feedback (Speicher-Blitz & Statusmeldung) int saveFlashTimer = 0; String statusBannerText = ""; int statusBannerTimer = 0; // Passive 3D Cursor Variablen int giv = 150; // ---------------------------------------------------------------------------------------------- // MODUL 2: INITIALISIERUNG & UMGEBUNGSERKENNUNG (JAVA / WEB) // ---------------------------------------------------------------------------------------------- void setup() { size(1200, 850); background(255); // Sichere Erkennung ob Browser (processing.min.js) oder Desktop (Processing 4) läuft detectRuntimeEnvironment(); syncAccessibilityWithWeb(); for (int i = 0; i < maxHistory; i++) { colorHistory[i] = color(0, 0, 0); } clearMemoryGrid(); if (!isWebEnvironment) { ensureDir("work0/"); ensureDir("work/"); } drawBlankGrid(); } void detectRuntimeEnvironment() { // In processing.min.js existiert JavaScript-Kontext; try/catch verhindert Abstürze in beiden Welten try { String p = sketchPath(""); if (p == null || p.equals("") || p.indexOf("http") == 0) { isWebEnvironment = true; } else { isWebEnvironment = false; } } catch (Exception e) { isWebEnvironment = true; } } // Synchronisiert den Accessibility-Modus automatisch mit der Webseite (jan-buehring.de / xqskys.de) void syncAccessibilityWithWeb() { try { // Liest CSS-Klasse oder prefers-contrast über DOM, falls im Browser ausgeführt if (typeof window !== "undefined") { if (document.body.classList.contains("high-contrast") || document.documentElement.classList.contains("high-contrast") || (window.matchMedia && (window.matchMedia("(prefers-contrast: more)").matches || window.matchMedia("(forced-colors: active)").matches))) { highContrastMode = true; } } } catch (Exception e) { // Im reinen Java-Desktop-Modus wird dies sicher übersprungen } } // Hilfsfunktionen für den 3D-Voxel-Index (ersetzt 3D-Arrays für processing.min.js Stabilität) int getVoxelIndex(int x, int y, int l) { return (l * GRID_MAX * GRID_MAX) + (y * GRID_MAX) + x; } color getVoxel(int x, int y, int l) { if (x < 0 || x >= GRID_MAX || y < 0 || y >= GRID_MAX || l < 0 || l >= GRID_MAX) { return color(255); } return frameData[getVoxelIndex(x, y, l)]; } void setVoxel(int x, int y, int l, color c) { if (x >= 0 && x < GRID_MAX && y >= 0 && y < GRID_MAX && l >= 0 && l < GRID_MAX) { frameData[getVoxelIndex(x, y, l)] = c; } } void ensureDir(String path) { if (isWebEnvironment) return; try { // Processing 4 natives createWriter legt Verzeichnisse automatisch an; dummy-Check ohne java.io.File-Import String testPath = sketchPath(path + ".dircheck"); PrintWriter pw = createWriter(testPath); if (pw != null) { pw.flush(); pw.close(); } } catch (Exception e) {} } void clearMemoryGrid() { color whiteCol = color(255); for (int i = 0; i < frameData.length; i++) { frameData[i] = whiteCol; } } void showStatusMessage(String msg) { statusBannerText = msg; statusBannerTimer = 120; println(msg); } // ---------------------------------------------------------------------------------------------- // MODUL 3: DATEI- & WEB-STORAGE PERSISTENZ (OHNE BLOCKIERENDE JAVA-IMPORTS) // ---------------------------------------------------------------------------------------------- String makeStorageKey(int folderId, int layerId, String channel, String frameStr) { return "work" + folderId + "/" + channel + "/" + layerId + channel + frameStr + ".txt"; } void saveVirtualFile(String keyPath, String content) { // 1. Im internen Sitzungs-Cache speichern int foundIdx = -1; for (int i = 0; i < webStorageCount; i++) { if (webStorageKeys[i] != null && webStorageKeys[i].equals(keyPath)) { foundIdx = i; break; } } if (foundIdx != -1) { webStorageData[foundIdx] = content; } else if (webStorageCount < webStorageKeys.length) { webStorageKeys[webStorageCount] = keyPath; webStorageData[webStorageCount] = content; webStorageCount++; } // 2. Falls im Browser: zusätzlich in localStorage sichern (progressive enhancement) try { if (typeof window !== "undefined" && window.localStorage) { window.localStorage.setItem("vexo_" + keyPath, content); } } catch (Exception e) {} // 3. Falls Desktop Processing 4: zusätzlich auf Festplatte schreiben if (!isWebEnvironment) { try { PrintWriter pw = createWriter(keyPath); if (pw != null) { pw.print(content); pw.flush(); pw.close(); } } catch (Exception e) {} } } String[] loadVirtualFileLines(String keyPath) { // 1. Prüfe Sitzungs-Cache for (int i = 0; i < webStorageCount; i++) { if (webStorageKeys[i] != null && webStorageKeys[i].equals(keyPath)) { return split(webStorageData[i], '\n'); } } // 2. Prüfe Browser localStorage try { if (typeof window !== "undefined" && window.localStorage) { String stored = window.localStorage.getItem("vexo_" + keyPath); if (stored != null && stored.length() > 0) { return split(stored, '\n'); } } } catch (Exception e) {} // 3. Prüfe lokales Dateisystem (Processing 4 / Webserver relative Pfade) try { String[] lines = loadStrings(keyPath); if (lines != null && lines.length > 0) { return lines; } } catch (Exception e) {} return null; } boolean frameExistsLocally(int targetFrame) { String frameStr = nf(targetFrame, 10); String checkKey = makeStorageKey(ordner, 0, "bw", frameStr); String[] lines = loadVirtualFileLines(checkKey); return (lines != null && lines.length > 0); } void updateRemoteStatus() { if (!onlineActive) { remoteFrameAvailable = false; return; } if (serverBaseUrl == null || serverBaseUrl.equals("")) { loadServerConfig(); } if (serverBaseUrl != null && !serverBaseUrl.equals("")) { String frameStr = nf(iv, 10); String testUrl = serverBaseUrl + "/smile/work" + ordner + "/bw/0bw" + frameStr + ".txt"; remoteFrameAvailable = checkUrlExists(testUrl); } else { remoteFrameAvailable = false; } } boolean checkUrlExists(String urlString) { try { String[] probe = loadStrings(urlString); return (probe != null && probe.length > 0); } catch (Exception e) { return false; } } void loadServerConfig() { String[] lines = loadVirtualFileLines("server.txt"); if (lines != null && lines.length > 0) { serverBaseUrl = trim(lines[0]); } if (serverBaseUrl == null || serverBaseUrl.equals("")) { serverBaseUrl = "https://xqskys.de"; } } // ---------------------------------------------------------------------------------------------- // MODUL 4: FARB-HISTORIE & SLIDER-TRAILS // ---------------------------------------------------------------------------------------------- void addColorToHistory(color c) { if (historyCount > 0 && colorHistory[0] == c) return; int existingIndex = -1; for (int i = 0; i < historyCount; i++) { if (colorHistory[i] == c) { existingIndex = i; break; } } if (existingIndex != -1) { color temp = colorHistory[existingIndex]; for (int i = existingIndex; i > 0; i--) { colorHistory[i] = colorHistory[i - 1]; } colorHistory[0] = temp; } else { for (int i = maxHistory - 1; i > 0; i--) { colorHistory[i] = colorHistory[i - 1]; } colorHistory[0] = c; if (historyCount < maxHistory) historyCount++; } } void pushTrail(int[] arr, int val) { val = constrain(val, 0, 255); if (arr[0] != val) { arr[3] = arr[2]; arr[2] = arr[1]; arr[1] = arr[0]; arr[0] = val; } } // ---------------------------------------------------------------------------------------------- // MODUL 5: TOP-BAR UI (DUAL-MODE ACCESSIBILITY: STANDARD & HIGH CONTRAST WCAG 2.1 AA) // ---------------------------------------------------------------------------------------------- void drawTopBar() { color bgTop = highContrastMode ? color(10, 10, 10) : color(255); color textMain = highContrastMode ? color(255, 255, 255) : color(0); color borderCol = highContrastMode ? color(255, 255, 0) : color(150); fill(bgTop); noStroke(); rect(0, 0, 1200, 30); strokeWeight(highContrastMode ? 2 : 1); // Datei-Button if (saveFlashTimer > 0) { fill(highContrastMode ? color(0, 114, 178) : color(100, 255, 100)); saveFlashTimer--; } else if (!frameExistsLocally(iv)) { fill(highContrastMode ? color(230, 159, 0) : color(255, 255, 100)); } else { fill(highContrastMode ? color(35, 35, 35) : color(245)); } stroke(borderCol); rect(5, 3, 75, 24, 4); // 3D-Modus Button if (show3DView) { fill(highContrastMode ? color(0, 114, 178) : color(200, 230, 255)); } else { fill(highContrastMode ? color(35, 35, 35) : color(240)); } stroke(borderCol); rect(235, 3, 95, 24, 4); // Play Button if (isPlaying) { fill(highContrastMode ? color(0, 158, 115) : color(100, 255, 100)); } else { fill(highContrastMode ? color(35, 35, 35) : color(240)); } stroke(borderCol); rect(445, 3, 60, 24, 4); // Sehhilfe / High-Contrast Accessibility Toggle (Mitte-Rechts) if (highContrastMode) { fill(255, 255, 0); } else { fill(240); } stroke(borderCol); rect(880, 3, 130, 24, 4); // Online Button if (!onlineActive) { fill(highContrastMode ? color(35, 35, 35) : color(255)); } else if (remoteFrameAvailable) { fill(highContrastMode ? color(0, 158, 115) : color(100, 255, 100)); } else { fill(highContrastMode ? color(230, 159, 0) : color(255, 255, 100)); } stroke(borderCol); rect(1020, 3, 70, 24, 4); // Gitter Button if (showHelperGrid) { fill(highContrastMode ? color(0, 114, 178) : color(200, 230, 255)); } else { fill(highContrastMode ? color(35, 35, 35) : color(240)); } stroke(borderCol); rect(1100, 3, 90, 24, 4); strokeWeight(1); // Beschriftungen (mit Non-Color Indikatoren & Kontrastprüfung >= 4.5:1) textSize(16); textAlign(LEFT, CENTER); fill(saveFlashTimer > 0 || !frameExistsLocally(iv) ? color(0) : textMain); text("Datei", 12, 15); fill(textMain); text("Frame: " + iv, 90, 15); fill(highContrastMode && show3DView ? color(255) : textMain); text("3D-Modus", 242, 15); fill(textMain); text("ClearFrame", 336, 15); fill(isPlaying ? color(0) : textMain); text(isPlaying ? "■ Stop" : "▶ Play", 450, 15); fill(textMain); text("Size: " + num, 515, 15); text("Folder: " + ordner, 635, 15); text("Level: " + level, 760, 15); textAlign(CENTER, CENTER); fill(highContrastMode ? color(0) : color(0)); textSize(13); text(highContrastMode ? "Sehhilfe: KONTRAST" : "Sehhilfe: Standard", 945, 15); textSize(15); fill(onlineActive ? color(0) : textMain); text("Online", 1055, 15); fill(highContrastMode && showHelperGrid ? color(255) : textMain); text(showHelperGrid ? "Gitter: AN" : "Gitter: AUS", 1145, 15); textAlign(LEFT, CENTER); } // ---------------------------------------------------------------------------------------------- // MODUL 6: HAUPTSCHLEIFE (DRAW) // ---------------------------------------------------------------------------------------------- void draw() { processNetworkPassive(); if (isPlaying) { playTimer++; if (playTimer > 15) { playTimer = 0; iv++; if (iv > lastSavedFrame) { iv = 1; } if (frameExistsLocally(iv)) { loadFrameData(iv); } else { clearMemoryGrid(); drawBlankGrid(); } updateRemoteStatus(); } } drawTopBar(); drawColorControls(); if (dom == 1) { dom = 0; drawBlankGrid(); } if (show3DView) { draw3DBlockArea(); } else { fill(highContrastMode ? color(20) : color(255)); stroke(highContrastMode ? color(255, 255, 0) : color(180)); rect(630, 30, 560, 600); } // Zeichenbereich (Links = Malen, Rechts = Pipette) if (mouseX >= 0 && mouseX < 600 && mouseY >= 30 && mouseY < 630) { int cellX = floor(mouseX / feld); int cellY = floor((mouseY - 30) / feld); if (mousePressed && mouseButton == LEFT) { fill(rc, gc, bc); stroke(highContrastMode ? color(255, 255, 0) : color(200)); rect(cellX * feld, 30 + cellY * feld, feld, feld); if (cellX < GRID_MAX && cellY < GRID_MAX) { setVoxel(cellX, cellY, level, color(rc, gc, bc)); } // Kanal-Vorschau-Pixel (falls 3D-Ansicht ausgeblendet ist) if (!show3DView) { fill(rc, 0, 0); rect(640 + cellX, 50 + cellY, 1, 1); fill(0, gc, 0); rect(840 + cellX, 50 + cellY, 1, 1); fill(0, 0, bc); rect(640 + cellX, 250 + cellY, 1, 1); int qc = (rc + gc + bc) / 3; fill(qc); rect(840 + cellX, 250 + cellY, 1, 1); } addColorToHistory(color(rc, gc, bc)); } if (mousePressed && mouseButton == RIGHT) { color picked = getVoxel(cellX, cellY, level); rc = int(red(picked)); gc = int(green(picked)); bc = int(blue(picked)); pushTrail(trailR, rc); pushTrail(trailG, gc); pushTrail(trailB, bc); addColorToHistory(color(rc, gc, bc)); } } // Status-Banner im unteren Bereich (falls aktiv) if (statusBannerTimer > 0) { statusBannerTimer--; fill(highContrastMode ? color(0) : color(255, 255, 210)); stroke(highContrastMode ? color(255, 255, 0) : color(120)); rect(400, 640, 500, 28, 4); fill(highContrastMode ? color(255, 255, 0) : color(0)); textSize(13); textAlign(LEFT, CENTER); text(statusBannerText, 412, 654); } if (app == 7) { renderIso3DPassive(); } } void loadLevelToScreen() { fill(highContrastMode ? color(20) : color(220)); stroke(highContrastMode ? color(255, 255, 0) : color(180)); rect(0, 30, 600, 600); feld = 600.0 / (num + 1); for (int y = 0; y <= num; y++) { for (int x = 0; x <= num; x++) { color cellCol = getVoxel(x, y, level); fill(cellCol); stroke(highContrastMode ? color(120, 120, 120) : color(200)); rect(x * feld, 30 + y * feld, feld, feld); // Non-Color-Indikator im High-Contrast-Modus für nicht-weiße Voxel if (highContrastMode && (red(cellCol) < 250 || green(cellCol) < 250 || blue(cellCol) < 250)) { stroke(255, 255, 0); noFill(); rect(x * feld + 1, 30 + y * feld + 1, feld - 2, feld - 2); } } } } void drawBlankGrid() { drawBlankGridWithColor(color(255)); } void drawBlankGridWithColor(color fillColor) { fill(highContrastMode ? color(20) : color(220)); stroke(highContrastMode ? color(255, 255, 0) : color(180)); rect(0, 30, 600, 600); feld = 600.0 / (num + 1); for (int y = 0; y <= num; y++) { for (int x = 0; x <= num; x++) { fill(fillColor); stroke(highContrastMode ? color(120) : color(200)); rect(x * feld, 30 + y * feld, feld, feld); if (x < GRID_MAX && y < GRID_MAX) { setVoxel(x, y, level, fillColor); } } } } // ---------------------------------------------------------------------------------------------- // MODUL 7: 3D ANSICHT - SOLIDE WÜRFEL MIT BELEUCHTUNG & SCHATTIERUNG // ---------------------------------------------------------------------------------------------- void drawIsoCube(float sx, float sy, float S, color c) { color edgeStroke = highContrastMode ? color(255, 255, 0) : color(40, 60); strokeWeight(highContrastMode ? 1.5 : 1.0); // Oberseite (Licht von oben -> am hellsten) fill(c); stroke(edgeStroke); beginShape(); vertex(sx, sy); vertex(sx + S, sy + S * 0.5); vertex(sx, sy + S); vertex(sx - S, sy + S * 0.5); endShape(CLOSE); // Linke Seite (Mittlerer Schatten) fill(red(c) * 0.75, green(c) * 0.75, blue(c) * 0.75); stroke(edgeStroke); beginShape(); vertex(sx - S, sy + S * 0.5); vertex(sx, sy + S); vertex(sx, sy + S + S); vertex(sx - S, sy + S * 0.5 + S); endShape(CLOSE); // Rechte Seite (Dunklerer Schatten, abgewandt) fill(red(c) * 0.55, green(c) * 0.55, blue(c) * 0.55); stroke(edgeStroke); beginShape(); vertex(sx, sy + S); vertex(sx + S, sy + S * 0.5); vertex(sx + S, sy + S * 0.5 + S); vertex(sx, sy + S + S); endShape(CLOSE); strokeWeight(1.0); } void draw3DBlockArea() { fill(highContrastMode ? color(18) : color(245)); stroke(highContrastMode ? color(255, 255, 0) : color(180)); rect(630, 30, 560, 600); fill(highContrastMode ? color(255, 255, 255) : color(0)); textSize(14); textAlign(LEFT, CENTER); text("3D Ansicht (Frame " + iv + " - Solide Würfel mit Beleuchtung)", 645, 48); float originX = 910; float originY = 220; float S = 10.0; // Exakte Kantenlänge (Länge = Breite = Höhe) if (showHelperGrid) { stroke(highContrastMode ? color(255, 255, 0, 140) : color(180, 120)); noFill(); for (int y = 0; y <= num; y++) { float x1 = originX + (0 - y) * S; float y1 = originY + (0 + y) * (S * 0.5); float x2 = originX + (num - y) * S; float y2 = originY + (num + y) * (S * 0.5); line(x1, y1, x2, y2); } for (int x = 0; x <= num; x++) { float x1 = originX + (x - 0) * S; float y1 = originY + (x + 0) * (S * 0.5); float x2 = originX + (x - num) * S; float y2 = originY + (x + num) * (S * 0.5); line(x1, y1, x2, y2); } } // Solide Würfel (Länge = Höhe = Breite) mit Schattierung rendern for (int l = 0; l <= num; l++) { for (int y = 0; y <= num; y++) { for (int x = 0; x <= num; x++) { color c = getVoxel(x, y, l); if (red(c) < 250 || green(c) < 250 || blue(c) < 250) { float sx = originX + (x - y) * S; float sy = originY + (x + y) * (S * 0.5) - (l * S * 1.0); drawIsoCube(sx, sy, S, c); } } } } } // ---------------------------------------------------------------------------------------------- // MODUL 8: UI & FARB-FUNKTIONEN // ---------------------------------------------------------------------------------------------- void drawColorControls() { // Hintergrund der unteren Steuerleiste anpassen fill(highContrastMode ? color(10) : color(255)); noStroke(); rect(0, 631, 1200, 219); for (int i = 0; i <= 255; i++) { stroke(i, 0, 0); line(i, 680, i, 700); stroke(0, i, 0); line(i, 710, i, 730); stroke(0, 0, i); line(i, 740, i, 760); } for (int i = 0; i <= 255; i++) { stroke(i); line(i, 800, i, 820); } for (int i = 0; i < 4; i++) { float alpha = 255 - (i * 60); if (trailR[i] != -1) { stroke(highContrastMode ? color(255, 255, 0, alpha) : color(255, 0, 0, alpha)); strokeWeight(2); line(trailR[i], 678, trailR[i], 702); } if (trailG[i] != -1) { stroke(highContrastMode ? color(0, 255, 255, alpha) : color(0, 255, 0, alpha)); strokeWeight(2); line(trailG[i], 708, trailG[i], 732); } if (trailB[i] != -1) { stroke(highContrastMode ? color(255, 255, 255, alpha) : color(0, 0, 255, alpha)); strokeWeight(2); line(trailB[i], 738, trailB[i], 762); } if (trailBW[i] != -1) { stroke(255, 0, 255, alpha); strokeWeight(2); line(trailBW[i], 798, trailBW[i], 822); } } strokeWeight(1); fill(highContrastMode ? color(10) : color(255)); noStroke(); rect(258, 678, 120, 92); rect(258, 798, 100, 24); fill(highContrastMode ? color(255, 255, 255) : color(0)); textSize(14); textAlign(LEFT, CENTER); text("R: " + rc, 265, 695); text("G: " + gc, 265, 725); text("B: " + bc, 265, 755); text("BW: " + sc, 265, 810); fill(rc, gc, bc); stroke(highContrastMode ? color(255, 255, 0) : color(0)); strokeWeight(highContrastMode ? 2 : 1); rect(0, 770, 255, 25); strokeWeight(1); fill(highContrastMode ? color(25) : color(240)); stroke(highContrastMode ? color(255, 255, 0) : color(180)); rect(400, 680, 500, 140, 6); fill(highContrastMode ? color(255) : color(0)); textSize(14); text("Farb-Historie:", 415, 700); for (int i = 0; i < maxHistory; i++) { float hx = 415 + (i * 55); float hy = 715; fill(colorHistory[i]); stroke(highContrastMode ? color(255) : color(0)); rect(hx, hy, 45, 45, 4); if (i == 0) { noFill(); stroke(highContrastMode ? color(255, 255, 0) : color(0, 255, 0)); strokeWeight(3); rect(hx - 2, hy - 2, 49, 49, 6); strokeWeight(1); } } // Kurzhilfe für Tastaturbedienung (WCAG 2.1 AA Keyboard Accessibility) fill(highContrastMode ? color(220, 220, 220) : color(90)); textSize(12); text("Tasten: [Leertaste] Play/Pause | [←/→] Frame | [↑/↓] Level | [K] Kontrast-Modus | [S] Speichern", 415, 795); } // ---------------------------------------------------------------------------------------------- // MODUL 9: MAUS- & TASTATUR-INTERAKTION (INKL. WCAG KEYBOARD NAVIGATION) // ---------------------------------------------------------------------------------------------- void keyPressed() { if (key == 'k' || key == 'K') { highContrastMode = !highContrastMode; loadLevelToScreen(); showStatusMessage(highContrastMode ? "Sehhilfe: High-Contrast-Modus aktiviert" : "Sehhilfe: Standard-Modus aktiviert"); } else if (key == ' ') { isPlaying = !isPlaying; } else if (key == 's' || key == 'S') { saveFrameData(); saveFlashTimer = 20; iv++; } else if (keyCode == RIGHT) { iv++; if (frameExistsLocally(iv)) loadFrameData(iv); else { clearMemoryGrid(); drawBlankGrid(); } updateRemoteStatus(); } else if (keyCode == LEFT) { iv = max(1, iv - 1); if (frameExistsLocally(iv)) loadFrameData(iv); else { clearMemoryGrid(); drawBlankGrid(); } updateRemoteStatus(); } else if (keyCode == UP) { level = min(num - 1, level + 1); loadLevelToScreen(); } else if (keyCode == DOWN) { level = max(0, level - 1); loadLevelToScreen(); } } void mousePressed() { if (mouseX >= 0 && mouseX <= 255) { if (mouseY >= 680 && mouseY <= 700) { rc = mouseX; pushTrail(trailR, rc); return; } if (mouseY >= 710 && mouseY <= 730) { gc = mouseX; pushTrail(trailG, gc); return; } if (mouseY >= 740 && mouseY <= 760) { bc = mouseX; pushTrail(trailB, bc); return; } if (mouseY >= 800 && mouseY <= 820) { int clickedGray = mouseX; int shift = clickedGray - sc; rc = constrain(rc + shift, 0, 255); gc = constrain(gc + shift, 0, 255); bc = constrain(bc + shift, 0, 255); pushTrail(trailBW, clickedGray); pushTrail(trailR, rc); pushTrail(trailG, gc); pushTrail(trailB, bc); return; } } if (mouseX >= 260 && mouseX <= 350) { int fineStep = (mouseButton == LEFT) ? 1 : -1; if (mouseY >= 680 && mouseY <= 710) { rc = constrain(rc + fineStep, 0, 255); pushTrail(trailR, rc); return; } if (mouseY >= 710 && mouseY <= 740) { gc = constrain(gc + fineStep, 0, 255); pushTrail(trailG, gc); return; } if (mouseY >= 740 && mouseY <= 770) { bc = constrain(bc + fineStep, 0, 255); pushTrail(trailB, bc); return; } } if (mouseY >= 715 && mouseY <= 760 && mouseX >= 415 && mouseX <= 415 + (maxHistory * 55)) { int clickedIdx = floor((mouseX - 415) / 55.0); if (clickedIdx >= 0 && clickedIdx < maxHistory) { color selectedCol = colorHistory[clickedIdx]; rc = int(red(selectedCol)); gc = int(green(selectedCol)); bc = int(blue(selectedCol)); pushTrail(trailR, rc); pushTrail(trailG, gc); pushTrail(trailB, bc); return; } } // Top-Bar Button Klicks if (mouseY >= 0 && mouseY <= 30) { // 3D-Modus Klick (An / Aus) if (mouseX >= 235 && mouseX <= 330) { show3DView = !show3DView; return; } // Play Button Klick if (mouseX >= 445 && mouseX <= 510) { isPlaying = !isPlaying; return; } // Sehhilfe / High-Contrast Accessibility Toggle if (mouseX >= 880 && mouseX <= 1010) { highContrastMode = !highContrastMode; loadLevelToScreen(); showStatusMessage(highContrastMode ? "Sehhilfe: High-Contrast-Modus aktiviert" : "Sehhilfe: Standard-Modus aktiviert"); return; } // Gitter-Button Klick (Hilfsgitter an/aus) if (mouseX >= 1100 && mouseX <= 1190) { showHelperGrid = !showHelperGrid; return; } // Online-Button Klick (Toggle - Browser- & Desktop-kompatibel ohne JOptionPane) if (mouseX >= 1020 && mouseX <= 1090) { if (!onlineActive) { String[] consentLines = loadVirtualFileLines("online_zugriff.txt"); if (consentLines == null || consentLines.length == 0) { saveVirtualFile("online_zugriff.txt", "Löschen dieser Datei führt dazu, dass dieses Programm smile nicht auf die online download funktion zugreifen kann.\n"); onlineConsentGiven = true; showStatusMessage("Online-Zugriff aktiviert (online_zugriff.txt erstellt)."); } else { onlineConsentGiven = true; } loadServerConfig(); boolean allowed = checkUrlExists(serverBaseUrl + "/smile/smile_pde_erlaubt.txt"); if (allowed) { saveVirtualFile("server.txt", serverBaseUrl + "\n"); onlineActive = true; updateRemoteStatus(); showStatusMessage("Verbunden mit: " + serverBaseUrl); } else { // Aktiviert lokalen / Webspace-Fallback ohne Absturz onlineActive = true; remoteFrameAvailable = false; showStatusMessage("Online-Modus aktiv (Server-Check: " + serverBaseUrl + ")"); } } else { onlineActive = false; remoteFrameAvailable = false; showStatusMessage("Online-Modus deaktiviert."); } return; } // Frame Navigation (Links = Zurück, Rechts = Vor) if (mouseX >= 90 && mouseX <= 220) { if (mouseButton == LEFT) iv = max(1, iv - 1); if (mouseButton == RIGHT) iv++; if (frameExistsLocally(iv)) { loadFrameData(iv); } else { clearMemoryGrid(); drawBlankGrid(); } updateRemoteStatus(); } // Size Adjustment if (mouseX >= 515 && mouseX <= 625) { if (mouseButton == LEFT) num = min(100, num + 1); if (mouseButton == RIGHT) num = max(2, num - 1); num1 = num; drawBlankGrid(); } // Clear Frame (Links = Mit Weiß löschen, Rechts = Mit aktueller Farbe füllen) if (mouseX >= 335 && mouseX <= 440) { if (mouseButton == LEFT) { drawBlankGridWithColor(color(255)); } else if (mouseButton == RIGHT) { drawBlankGridWithColor(color(rc, gc, bc)); addColorToHistory(color(rc, gc, bc)); } } // Folder Auswahl (Links = rauf, Rechts = runter) if (mouseX >= 630 && mouseX <= 750) { if (mouseButton == LEFT) ordner++; if (mouseButton == RIGHT) ordner = max(0, ordner - 1); if (frameExistsLocally(iv)) { loadFrameData(iv); } else { clearMemoryGrid(); drawBlankGrid(); } updateRemoteStatus(); } // Level Auswahl if (mouseX >= 760 && mouseX <= 870) { if (mouseButton == LEFT) level = min(num - 1, level + 1); if (mouseButton == RIGHT) level = max(0, level - 1); loadLevelToScreen(); updateRemoteStatus(); } // Klicks auf "Datei" (Rechtsklick = Speichern & Nächster Frame, Linksklick = Letzten Frame laden) if (mouseX >= 0 && mouseX <= 80) { if (mouseButton == RIGHT) { saveFrameData(); saveFlashTimer = 20; iv++; } else if (mouseButton == LEFT) { iv = lastSavedFrame; loadFrameData(iv); showStatusMessage("Zuletzt gespeichertes Bild geladen: Frame " + iv); } } } } // ---------------------------------------------------------------------------------------------- // MODUL 10: DATEI EXPORT & IMPORT ENGINE (DUAL: DESKTOP FILE & BROWSER STORAGE) // ---------------------------------------------------------------------------------------------- void saveFrameData() { String baseDir = "work" + ordner + "/"; ensureDir(baseDir + "r/"); ensureDir(baseDir + "g/"); ensureDir(baseDir + "b/"); ensureDir(baseDir + "bw/"); String generalDir = "work/"; ensureDir(generalDir); String frameStr = nf(iv, 10); for (int l = 0; l < num; l++) { String sbR = ""; String sbG = ""; String sbB = ""; String sbBW = ""; for (int y = 0; y <= num; y++) { for (int x = 0; x <= num; x++) { color c = getVoxel(x, y, l); int rVal = int(red(c)); int gVal = int(green(c)); int bVal = int(blue(c)); int bwVal = int((red(c) + green(c) + blue(c)) / 3); sbR += rVal + "\n"; sbG += gVal + "\n"; sbB += bVal + "\n"; sbBW += bwVal + "\n"; } sbR += "eol\n"; sbG += "eol\n"; sbB += "eol\n"; sbBW += "eol\n"; } sbR += "eof\n"; sbG += "eof\n"; sbB += "eof\n"; sbBW += "eof\n"; saveVirtualFile(baseDir + "r/" + l + "r" + frameStr + ".txt", sbR); saveVirtualFile(baseDir + "g/" + l + "g" + frameStr + ".txt", sbG); saveVirtualFile(baseDir + "b/" + l + "b" + frameStr + ".txt", sbB); saveVirtualFile(baseDir + "bw/" + l + "bw" + frameStr + ".txt", sbBW); saveVirtualFile(generalDir + l + "r" + frameStr + ".txt", sbR); saveVirtualFile(generalDir + l + "g" + frameStr + ".txt", sbG); saveVirtualFile(generalDir + l + "b" + frameStr + ".txt", sbB); saveVirtualFile(generalDir + l + "bw" + frameStr + ".txt", sbBW); } lastSavedFrame = max(lastSavedFrame, iv); showStatusMessage("Block (0 bis " + (num - 1) + ") gespeichert | Frame " + frameStr); } void loadFrameData(int targetFrame) { String baseDir = "work" + ordner + "/"; String frameStr = nf(targetFrame, 10); clearMemoryGrid(); for (int l = 0; l < num; l++) { String[] linesbw = loadVirtualFileLines(baseDir + "bw/" + l + "bw" + frameStr + ".txt"); String[] linesr = loadVirtualFileLines(baseDir + "r/" + l + "r" + frameStr + ".txt"); String[] linesg = loadVirtualFileLines(baseDir + "g/" + l + "g" + frameStr + ".txt"); String[] linesb = loadVirtualFileLines(baseDir + "b/" + l + "b" + frameStr + ".txt"); if (linesbw != null && linesbw.length > 0) { int rowLength = 0; for (int i = 0; i < linesbw.length; i++) { String token = trim(linesbw[i]); if (token.equals("eol") || token.equals("eof")) { rowLength = i; break; } } if (rowLength > 0) { num = rowLength - 1; num1 = num; } } if (linesbw != null && linesr != null && linesg != null && linesb != null) { int idx = 0; int lx = 0, ly = 0; while (idx < linesbw.length && !trim(linesbw[idx]).equals("eof")) { String token = trim(linesbw[idx]); if (token.equals("")) { idx++; continue; } if (token.equals("eol")) { ly++; lx = 0; } else { if (lx < GRID_MAX && ly < GRID_MAX && l < GRID_MAX && idx < linesr.length && idx < linesg.length && idx < linesb.length) { int vr = int(trim(linesr[idx])); int vg = int(trim(linesg[idx])); int vb = int(trim(linesb[idx])); setVoxel(lx, ly, l, color(vr, vg, vb)); } lx++; } idx++; } } } loadLevelToScreen(); } // ---------------------------------------------------------------------------------------------- // MODUL 11: PASSIVE SYSTEME (DTIM-ZEC NETWORK & 3D HOOKS) // ---------------------------------------------------------------------------------------------- void processNetworkPassive() { // Passiver DTIM-ZEC Schnittstellen-Hook (kompatibel mit Desktop & Web ohne Socket-Blockade) } void renderIso3DPassive() { // Passiver 3D-Render-Hook }