-
{ if (e.button === 0) startDrawing(e); }}
- onMousemove={e => ifDrawing(e)}
- onMouseup={stopDrawing}
- onMouseleave={stopDrawing}>
- {Array.from({length: GRID_SIZE * GRID_SIZE}, (_, i) => {
- const x = i % GRID_SIZE;
- const y = Math.floor(i / GRID_SIZE);
- const key = `${x}-${y}`;
- const color = pixels[key] || '#ffffff';
- return
;
- })}
+
-
diff --git a/packages/pixel-canvas/tsconfig.json b/packages/pixel-canvas/tsconfig.json
new file mode 100644
index 0000000..4e6c6ce
--- /dev/null
+++ b/packages/pixel-canvas/tsconfig.json
@@ -0,0 +1,6 @@
+{
+ "extends": "../../tsconfig.base.json",
+ "include": [
+ "src/**/*"
+ ]
+}
diff --git a/packages/pixel-canvas/vite.config.ts b/packages/pixel-canvas/vite.config.ts
index 5f31783..09116a6 100644
--- a/packages/pixel-canvas/vite.config.ts
+++ b/packages/pixel-canvas/vite.config.ts
@@ -1,7 +1,9 @@
import { defineConfig } from 'vite';
import path from 'path';
+import { dominatorPlugin } from '../core/src/compiler/vite-plugin.ts';
export default defineConfig({
+ plugins: [dominatorPlugin()],
resolve: {
alias: {
'@dominator/core': path.resolve(__dirname, '../core/src/index.ts'),
diff --git a/packages/ralph-loop/package.json b/packages/ralph-loop/package.json
index 6fcbb56..4b6d450 100644
--- a/packages/ralph-loop/package.json
+++ b/packages/ralph-loop/package.json
@@ -4,6 +4,7 @@
"type": "module",
"scripts": {
"dev": "vite",
+ "build": "tsc --noEmit",
"compile": "ts-node --esm ../../scripts/compile.ts src/templates/ralph.dnr src/generated/ralph-render.ts renderRalph"
},
"dependencies": {
diff --git a/packages/ralph-loop/src/generated/ralph-render.ts b/packages/ralph-loop/src/generated/ralph-render.ts
index 48e79b3..720a0a1 100644
--- a/packages/ralph-loop/src/generated/ralph-render.ts
+++ b/packages/ralph-loop/src/generated/ralph-render.ts
@@ -2,48 +2,48 @@ import { effect } from '@dominator/core';
import * as stateModule from '../state';
export const renderRalph = () => {
- const state = stateModule as any;
- const events = (window as any);
+ const state = stateModule;
+ const { fps, getNodes, mode } = state;
- // Dynamic injection of state into local scope
- const { currentColor, tool, pixels, history, redoStack, GRID_SIZE, colorCounts, undo, redo, exportToPNG, startDrawing, ifDrawing, stopDrawing, PARTICLE_COUNT, getParticles, frame, mouse, NODE_COUNT, getNodes, fps, opsPerSec, mode } = state;
- const v1 = document.createElement('div');
- v1.setAttribute('class', "ralph-container");
- const v2 = document.createElement('div');
- v2.setAttribute('class', "status-overlay");
- const v3 = document.createElement('div');
- v3.setAttribute('class', "mode-indicator");
+ const v1 = document.createElement("div");
+ v1.setAttribute("class", "ralph-container");
+ const v2 = document.createElement("div");
+ v2.setAttribute("class", "status-overlay");
+ const v3 = document.createElement("div");
+ v3.setAttribute("class", "mode-indicator");
const v4 = document.createTextNode('');
effect(() => { v4.textContent = String(mode().toUpperCase()); });
v3.appendChild(v4);
v2.appendChild(v3);
v1.appendChild(v2);
- const v5 = document.createElement('div');
- v5.setAttribute('class', "viewport");
+ const v5 = document.createElement("div");
+ v5.setAttribute("class", "viewport");
const v6 = document.createDocumentFragment();
effect(() => {
- v6.textContent = '';
- (getNodes() || []).forEach((n) => {
- const v7 = document.createElement('div');
- v7.setAttribute('class', "node");
- effect(() => { v7.style.transform = n.transform; });
- effect(() => { v7.style.backgroundColor = n.color; });
- v6.appendChild(v7);
- });
+ v6.textContent = '';
+ const v6_a = getNodes() || [];
+ for (let v6_i = 0; v6_i < v6_a.length; v6_i++) {
+ const n = v6_a[v6_i];
+ const v7 = document.createElement("div");
+ v7.setAttribute("class", "node");
+ effect(() => { v7.style.transform = n.transform(); });
+ effect(() => { v7.style.backgroundColor = n.color(); });
+ v6.appendChild(v7);
+ }
});
v5.appendChild(v6);
v1.appendChild(v5);
- const v8 = document.createElement('div');
- v8.setAttribute('class', "dashboard");
- const v9 = document.createElement('div');
- v9.setAttribute('class', "metric");
- const v10 = document.createElement('span');
- v10.setAttribute('class', "value");
+ const v8 = document.createElement("div");
+ v8.setAttribute("class", "dashboard");
+ const v9 = document.createElement("div");
+ v9.setAttribute("class", "metric");
+ const v10 = document.createElement("span");
+ v10.setAttribute("class", "value");
const v11 = document.createTextNode('');
effect(() => { v11.textContent = String(fps()); });
v10.appendChild(v11);
v9.appendChild(v10);
- const v12 = document.createElement('label');
+ const v12 = document.createElement("label");
const v13 = document.createTextNode("FPS");
v12.appendChild(v13);
v9.appendChild(v12);
diff --git a/packages/ralph-loop/src/state.ts b/packages/ralph-loop/src/state.ts
index bea939d..469c4fb 100644
--- a/packages/ralph-loop/src/state.ts
+++ b/packages/ralph-loop/src/state.ts
@@ -1,8 +1,9 @@
import { signal } from '@dominator/core';
export const NODE_COUNT = 3000;
-const WIDTH = window.innerWidth;
-const HEIGHT = window.innerHeight;
+
+const getWidth = () => window.innerWidth;
+const getHeight = () => window.innerHeight;
interface Node {
id: number;
@@ -17,29 +18,29 @@ interface Node {
}
export const nodes = signal
([]);
-export const mouse = { x: WIDTH / 2, y: HEIGHT / 2 };
+export const mouse = { x: getWidth() / 2, y: getHeight() / 2 };
export const fps = signal(0);
export const mode = signal<'chaos' | 'form'>('chaos');
// Generate text targets
const createTextTargets = () => {
const canvas = document.createElement('canvas');
- canvas.width = WIDTH;
- canvas.height = HEIGHT;
+ canvas.width = getWidth();
+ canvas.height = getHeight();
const ctx = canvas.getContext('2d')!;
ctx.font = '900 15vw "Inter", sans-serif';
ctx.fillStyle = 'white';
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
- ctx.fillText('DOMINATOR', WIDTH / 2, HEIGHT / 2);
+ ctx.fillText('DOMINATOR', getWidth() / 2, getHeight() / 2);
- const imageData = ctx.getImageData(0, 0, WIDTH, HEIGHT).data;
+ const imageData = ctx.getImageData(0, 0, getWidth(), getHeight()).data;
const points: { x: number, y: number }[] = [];
// Scan pixel data (step 4 for performance)
- for (let y = 0; y < HEIGHT; y += 6) {
- for (let x = 0; x < WIDTH; x += 6) {
- const alpha = imageData[(y * WIDTH + x) * 4 + 3];
+ for (let y = 0; y < getHeight(); y += 6) {
+ for (let x = 0; x < getWidth(); x += 6) {
+ const alpha = imageData[(y * getWidth() + x) * 4 + 3];
if (alpha > 128) {
points.push({ x, y });
}
@@ -54,8 +55,8 @@ const init = () => {
for (let i = 0; i < NODE_COUNT; i++) {
const target = targets[i % targets.length];
- const x = Math.random() * WIDTH;
- const y = Math.random() * HEIGHT;
+ const x = Math.random() * getWidth();
+ const y = Math.random() * getHeight();
list.push({
id: i,
@@ -63,8 +64,8 @@ const init = () => {
y,
vx: (Math.random() - 0.5) * 5,
vy: (Math.random() - 0.5) * 5,
- tx: target ? target.x : (Math.random() * WIDTH),
- ty: target ? target.y : (Math.random() * HEIGHT),
+ tx: target ? target.x : (Math.random() * getWidth()),
+ ty: target ? target.y : (Math.random() * getHeight()),
transform: signal(`translate3d(${x | 0}px, ${y | 0}px, 0)`),
// Dynamic color signal for the shock effect
color: signal('rgba(0, 112, 243, 0.8)')
@@ -151,10 +152,10 @@ const loop = () => {
// Wrap only in chaos mode
if (!isForming) {
- if (n.x < 0) n.x = WIDTH;
- else if (n.x > WIDTH) n.x = 0;
- if (n.y < 0) n.y = HEIGHT;
- else if (n.y > HEIGHT) n.y = 0;
+ if (n.x < 0) n.x = getWidth();
+ else if (n.x > getWidth()) n.x = 0;
+ if (n.y < 0) n.y = getHeight();
+ else if (n.y > getHeight()) n.y = 0;
}
n.transform.set(`translate3d(${n.x | 0}px, ${n.y | 0}px, 0)`);
diff --git a/packages/ralph-loop/src/templates/ralph.dnr b/packages/ralph-loop/src/templates/ralph.dnr
index f50c3d9..45d87ee 100644
--- a/packages/ralph-loop/src/templates/ralph.dnr
+++ b/packages/ralph-loop/src/templates/ralph.dnr
@@ -7,8 +7,8 @@
{#each getNodes() as n}
{/each}
diff --git a/packages/ralph-loop/tsconfig.json b/packages/ralph-loop/tsconfig.json
new file mode 100644
index 0000000..4e6c6ce
--- /dev/null
+++ b/packages/ralph-loop/tsconfig.json
@@ -0,0 +1,6 @@
+{
+ "extends": "../../tsconfig.base.json",
+ "include": [
+ "src/**/*"
+ ]
+}
diff --git a/packages/ralph-loop/vite.config.ts b/packages/ralph-loop/vite.config.ts
new file mode 100644
index 0000000..dca8b6f
--- /dev/null
+++ b/packages/ralph-loop/vite.config.ts
@@ -0,0 +1,15 @@
+import { defineConfig } from 'vite';
+import path from 'node:path';
+import { dominatorPlugin } from '../core/src/compiler/vite-plugin.ts';
+
+export default defineConfig({
+ plugins: [dominatorPlugin()],
+ resolve: {
+ alias: {
+ '@dominator/core': path.resolve(__dirname, '../core/src/index.ts')
+ }
+ },
+ server: {
+ port: 5173
+ }
+});
diff --git a/packages/scene-editor/index.html b/packages/scene-editor/index.html
new file mode 100644
index 0000000..f3f80b6
--- /dev/null
+++ b/packages/scene-editor/index.html
@@ -0,0 +1,52 @@
+
+
+
+