diff options
| -rw-r--r-- | .geminiignore | 34 | ||||
| -rw-r--r-- | tools/editor/dct.js | 29 | ||||
| -rw-r--r-- | tools/editor/sdf.js | 39 |
3 files changed, 102 insertions, 0 deletions
diff --git a/.geminiignore b/.geminiignore new file mode 100644 index 0000000..57c68ff --- /dev/null +++ b/.geminiignore @@ -0,0 +1,34 @@ +# Gemini Ignore File +# This file specifies patterns for files and directories that Gemini's tools should ignore. + +# --- Build Artifacts --- +# Ignore all generated build directories +build/ +build_strip/ + +# --- Dependency Build Artifacts --- +# Ignore build artifacts from vendored or submoduled dependencies, such as Rust's target directory +third_party/**/target/ + +# --- Generated Assets & Data --- +# Assets themselves (like .spec files) are part of the system, so they are NOT ignored here. +# However, if any temporary generated files were created outside the standard asset pipeline, +# they could be listed here. For now, we assume standard assets are handled by the pipeline. + +# --- Distribution / Archives --- +# Ignore large distribution archives that are generated once and not modified during development. +archive/ + +# --- Temporary Files --- +# Ignore general temporary files or logs +tmp/ +*.tmp +*.log +*.swp +*.swo + +# --- IDE / Editor Specific --- +# Ignore common IDE or editor configuration/cache files +.vscode/ +.idea/ +*.iml diff --git a/tools/editor/dct.js b/tools/editor/dct.js new file mode 100644 index 0000000..f60f27e --- /dev/null +++ b/tools/editor/dct.js @@ -0,0 +1,29 @@ +// --- Utility Functions for Audio Processing --- +// JavaScript equivalent of C++ idct_512 +function javascript_idct_512(input) { + const output = new Float32Array(dctSize); + const PI = Math.PI; + const N = dctSize; + + for (let n = 0; n < N; ++n) { + let sum = input[0] / 2.0; + for (let k = 1; k < N; ++k) { + sum += input[k] * Math.cos((PI / N) * k * (n + 0.5)); + } + output[n] = sum * (2.0 / N); + } + return output; +} + +// Hanning window for smooth audio transitions (JavaScript equivalent) +function hanningWindow(size) { + const window = new Float32Array(size); + const PI = Math.PI; + for (let i = 0; i < size; i++) { + window[i] = 0.5 * (1 - Math.cos((2 * PI * i) / (size - 1))); + } + return window; +} + +const hanningWindowArray = hanningWindow(dctSize); // Pre-calculate window + diff --git a/tools/editor/sdf.js b/tools/editor/sdf.js new file mode 100644 index 0000000..c68d79a --- /dev/null +++ b/tools/editor/sdf.js @@ -0,0 +1,39 @@ +// --- Signed Distance Functions (SDFs) --- +// Generic 2D vector operations +function vec2(x, y) { return { x: x, y: y }; } +function length(v) { return Math.sqrt(v.x * v.x + v.y * v.y); } +function dot(v1, v2) { return v1.x * v2.x + v1.y * v2.y; } +function sub(v1, v2) { return vec2(v1.x - v2.x, v1.y - v2.y); } +function mul(v, s) { return vec2(v.x * s, v.y * s); } +function div(v, s) { return vec2(v.x / s, v.y / s); } +function normalize(v) { return div(v, length(v)); } +function clamp(x, minVal, maxVal) { return Math.max(minVal, Math.min(x, maxVal)); } +function abs(v) { return vec2(Math.abs(v.x), Math.abs(v.y)); } +function max(v1, v2) { return vec2(Math.max(v1.x, v2.x), Math.max(v1.y, v2.y)); } +function sign(x) { return (x > 0) ? 1 : ((x < 0) ? -1 : 0); } + +// sdSegment(p, a, b) - signed distance to a line segment +// p: point, a: segment start, b: segment end +function sdSegment(p, a, b) { + const pa = sub(p, a); + const ba = sub(b, a); + const h = clamp(dot(pa, ba) / dot(ba, ba), 0.0, 1.0); + return length(sub(pa, mul(ba, h))); +} + +// sdEllipse(p, r) - signed distance to an ellipse (p relative to center, r is half-extents) +// p: point relative to ellipse center, r: half-extents (rx, ry) +function sdEllipse(p, r) { + const k0 = vec2(1, length(div(p, r))); + const k1 = vec2(length(div(p, r)), 1); + const f = ((dot(div(mul(p, p), k0), vec2(1, 1)) < dot(div(mul(p, p), k1), vec2(1, 1))) ? k0 : k1); + return length(sub(p, mul(r, normalize(mul(f, p))))) * sign(length(p) - r.x); // Simplified, original has length(p)-r.x which is only for circular +} + +// sdBox(p, r) - signed distance to a rectangle (p relative to center, r is half-extents) +// p: point relative to box center, r: half-extents (hx, hy) +function sdBox(p, r) { + const q = sub(abs(p), r); + return length(max(q, vec2(0, 0))) + Math.min(0.0, Math.max(q.x, q.y)); +} + |
