create-textmode 1.0.6 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -21
- package/README.md +120 -86
- package/bin/index.js +8 -8
- package/package.json +70 -54
- package/src/args.js +57 -30
- package/src/banner.js +57 -57
- package/src/cli.js +166 -154
- package/src/constants.js +59 -23
- package/src/fs-utils.js +136 -85
- package/src/packageManager.js +18 -18
- package/src/prompts.js +102 -90
- package/src/runCommand.js +46 -46
- package/src/summary.js +43 -33
- package/src/textmodeVersion.js +57 -45
- package/src/usage.js +21 -18
- package/src/versions.js +56 -52
- package/templates/vanilla-js/.prettierrc +8 -8
- package/templates/vanilla-js/_gitignore +2 -2
- package/templates/vanilla-js/eslint.config.js +22 -22
- package/templates/vanilla-js/index.html +25 -25
- package/templates/vanilla-js/package.json +26 -26
- package/templates/vanilla-js/src/sketch.js +28 -28
- package/templates/vanilla-js/vite.config.js +7 -7
- package/templates/vanilla-js-tweakpane/_gitignore +2 -2
- package/templates/vanilla-js-tweakpane/eslint.config.js +22 -22
- package/templates/vanilla-js-tweakpane/index.html +37 -37
- package/templates/vanilla-js-tweakpane/package.json +27 -27
- package/templates/vanilla-js-tweakpane/src/sketch.js +62 -62
- package/templates/vanilla-js-tweakpane/vite.config.js +7 -7
- package/templates/vanilla-ts/.prettierrc +8 -8
- package/templates/vanilla-ts/_gitignore +1 -1
- package/templates/vanilla-ts/eslint.config.js +23 -23
- package/templates/vanilla-ts/index.html +26 -26
- package/templates/vanilla-ts/package.json +30 -30
- package/templates/vanilla-ts/src/sketch.ts +28 -28
- package/templates/vanilla-ts/tsconfig.json +15 -15
- package/templates/vanilla-ts/vite.config.ts +7 -7
- package/templates/vanilla-ts-tweakpane/_gitignore +2 -2
- package/templates/vanilla-ts-tweakpane/eslint.config.js +23 -23
- package/templates/vanilla-ts-tweakpane/index.html +37 -37
- package/templates/vanilla-ts-tweakpane/package.json +32 -32
- package/templates/vanilla-ts-tweakpane/src/sketch.ts +72 -72
- package/templates/vanilla-ts-tweakpane/tsconfig.json +15 -15
- package/templates/vanilla-ts-tweakpane/vite.config.ts +7 -7
- package/templates/vanilla-js-fxhash/_gitignore +0 -2
- package/templates/vanilla-js-fxhash/eslint.config.js +0 -22
- package/templates/vanilla-js-fxhash/index.html +0 -27
- package/templates/vanilla-js-fxhash/package.json +0 -26
- package/templates/vanilla-js-fxhash/public/fxhash.min.js +0 -1
- package/templates/vanilla-js-fxhash/src/sketch.js +0 -101
- package/templates/vanilla-js-fxhash/vite.config.js +0 -7
- package/templates/vanilla-ts-fxhash/_gitignore +0 -2
- package/templates/vanilla-ts-fxhash/eslint.config.js +0 -23
- package/templates/vanilla-ts-fxhash/index.html +0 -27
- package/templates/vanilla-ts-fxhash/package.json +0 -30
- package/templates/vanilla-ts-fxhash/public/fxhash.min.js +0 -1
- package/templates/vanilla-ts-fxhash/src/fxhash.d.ts +0 -54
- package/templates/vanilla-ts-fxhash/src/sketch.ts +0 -108
- package/templates/vanilla-ts-fxhash/tsconfig.json +0 -15
- package/templates/vanilla-ts-fxhash/vite.config.ts +0 -7
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
|
|
4
|
-
<head>
|
|
5
|
-
<meta charset="UTF-8" />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
-
<title>{{name}}</title>
|
|
8
|
-
|
|
9
|
-
<style>
|
|
10
|
-
html,
|
|
11
|
-
body {
|
|
12
|
-
margin: 0;
|
|
13
|
-
padding: 0;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
canvas {
|
|
17
|
-
display: block;
|
|
18
|
-
}
|
|
19
|
-
</style>
|
|
20
|
-
|
|
21
|
-
</head>
|
|
22
|
-
|
|
23
|
-
<body>
|
|
24
|
-
<script type="module" src="/src/sketch.ts"></script>
|
|
25
|
-
</body>
|
|
26
|
-
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="UTF-8" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>{{name}}</title>
|
|
8
|
+
|
|
9
|
+
<style>
|
|
10
|
+
html,
|
|
11
|
+
body {
|
|
12
|
+
margin: 0;
|
|
13
|
+
padding: 0;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
canvas {
|
|
17
|
+
display: block;
|
|
18
|
+
}
|
|
19
|
+
</style>
|
|
20
|
+
|
|
21
|
+
</head>
|
|
22
|
+
|
|
23
|
+
<body>
|
|
24
|
+
<script type="module" src="/src/sketch.ts"></script>
|
|
25
|
+
</body>
|
|
26
|
+
|
|
27
27
|
</html>
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "{{name}}",
|
|
3
|
-
"version": "0.0.0",
|
|
4
|
-
"private": true,
|
|
5
|
-
"type": "module",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"dev": "vite",
|
|
8
|
-
"build": "vite build",
|
|
9
|
-
"preview": "vite preview",
|
|
10
|
-
"format": "prettier --write \"src/**/*.{js,ts}\"",
|
|
11
|
-
"format:check": "prettier --check \"src/**/*.{js,ts}\"",
|
|
12
|
-
"lint": "eslint src --ext .ts",
|
|
13
|
-
"lint:fix": "eslint src --ext .ts --fix",
|
|
14
|
-
"typecheck": "tsc --noEmit"
|
|
15
|
-
},
|
|
16
|
-
"dependencies": {
|
|
17
|
-
"textmode.js": "latest"
|
|
18
|
-
},
|
|
19
|
-
"devDependencies": {
|
|
20
|
-
"@eslint/js": "^9.39.1",
|
|
21
|
-
"@types/node": "^24.10.2",
|
|
22
|
-
"eslint": "^9.39.1",
|
|
23
|
-
"eslint-config-prettier": "^10.1.8",
|
|
24
|
-
"globals": "^15.14.0",
|
|
25
|
-
"prettier": "^3.7.4",
|
|
26
|
-
"typescript": "^5.9.3",
|
|
27
|
-
"typescript-eslint": "^8.49.0",
|
|
28
|
-
"vite": "^7.2.7"
|
|
29
|
-
}
|
|
30
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "{{name}}",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite",
|
|
8
|
+
"build": "vite build",
|
|
9
|
+
"preview": "vite preview",
|
|
10
|
+
"format": "prettier --write \"src/**/*.{js,ts}\"",
|
|
11
|
+
"format:check": "prettier --check \"src/**/*.{js,ts}\"",
|
|
12
|
+
"lint": "eslint src --ext .ts",
|
|
13
|
+
"lint:fix": "eslint src --ext .ts --fix",
|
|
14
|
+
"typecheck": "tsc --noEmit"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"textmode.js": "latest"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@eslint/js": "^9.39.1",
|
|
21
|
+
"@types/node": "^24.10.2",
|
|
22
|
+
"eslint": "^9.39.1",
|
|
23
|
+
"eslint-config-prettier": "^10.1.8",
|
|
24
|
+
"globals": "^15.14.0",
|
|
25
|
+
"prettier": "^3.7.4",
|
|
26
|
+
"typescript": "^5.9.3",
|
|
27
|
+
"typescript-eslint": "^8.49.0",
|
|
28
|
+
"vite": "^7.2.7"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { textmode } from 'textmode.js';
|
|
2
|
-
|
|
3
|
-
const tm = textmode.create({ width: window.innerWidth, height: window.innerHeight });
|
|
4
|
-
|
|
5
|
-
tm.draw(() => {
|
|
6
|
-
tm.background(0);
|
|
7
|
-
|
|
8
|
-
const halfCols = tm.grid.cols / 2 + 1;
|
|
9
|
-
const halfRows = tm.grid.rows / 2 + 1;
|
|
10
|
-
|
|
11
|
-
for (let y = -halfRows; y < halfRows; y++) {
|
|
12
|
-
for (let x = -halfCols; x < halfCols; x++) {
|
|
13
|
-
const dist = Math.sqrt(x * x + y * y);
|
|
14
|
-
const wave = Math.sin(dist * 0.2 - tm.frameCount * 0.1);
|
|
15
|
-
|
|
16
|
-
tm.push();
|
|
17
|
-
tm.translate(x, y, 0);
|
|
18
|
-
tm.char(wave > 0.5 ? '▓' : wave > 0 ? '▒' : '░');
|
|
19
|
-
tm.charColor(0, 150 + wave * 100, 255);
|
|
20
|
-
tm.point();
|
|
21
|
-
tm.pop();
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
tm.windowResized(() => {
|
|
27
|
-
tm.resizeCanvas(window.innerWidth, window.innerHeight);
|
|
28
|
-
});
|
|
1
|
+
import { textmode } from 'textmode.js';
|
|
2
|
+
|
|
3
|
+
const tm = textmode.create({ width: window.innerWidth, height: window.innerHeight });
|
|
4
|
+
|
|
5
|
+
tm.draw(() => {
|
|
6
|
+
tm.background(0);
|
|
7
|
+
|
|
8
|
+
const halfCols = tm.grid.cols / 2 + 1;
|
|
9
|
+
const halfRows = tm.grid.rows / 2 + 1;
|
|
10
|
+
|
|
11
|
+
for (let y = -halfRows; y < halfRows; y++) {
|
|
12
|
+
for (let x = -halfCols; x < halfCols; x++) {
|
|
13
|
+
const dist = Math.sqrt(x * x + y * y);
|
|
14
|
+
const wave = Math.sin(dist * 0.2 - tm.frameCount * 0.1);
|
|
15
|
+
|
|
16
|
+
tm.push();
|
|
17
|
+
tm.translate(x, y, 0);
|
|
18
|
+
tm.char(wave > 0.5 ? '▓' : wave > 0 ? '▒' : '░');
|
|
19
|
+
tm.charColor(0, 150 + wave * 100, 255);
|
|
20
|
+
tm.point();
|
|
21
|
+
tm.pop();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
tm.windowResized(() => {
|
|
27
|
+
tm.resizeCanvas(window.innerWidth, window.innerHeight);
|
|
28
|
+
});
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ESNext",
|
|
4
|
-
"useDefineForClassFields": true,
|
|
5
|
-
"module": "ESNext",
|
|
6
|
-
"moduleResolution": "Node",
|
|
7
|
-
"strict": true,
|
|
8
|
-
"jsx": "preserve",
|
|
9
|
-
"esModuleInterop": true,
|
|
10
|
-
"skipLibCheck": true,
|
|
11
|
-
"types": ["vite/client"]
|
|
12
|
-
},
|
|
13
|
-
"include": ["src"],
|
|
14
|
-
"references": []
|
|
15
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ESNext",
|
|
4
|
+
"useDefineForClassFields": true,
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"moduleResolution": "Node",
|
|
7
|
+
"strict": true,
|
|
8
|
+
"jsx": "preserve",
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"types": ["vite/client"]
|
|
12
|
+
},
|
|
13
|
+
"include": ["src"],
|
|
14
|
+
"references": []
|
|
15
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { defineConfig } from 'vite';
|
|
2
|
-
|
|
3
|
-
export default defineConfig({
|
|
4
|
-
server: {
|
|
5
|
-
open: true
|
|
6
|
-
}
|
|
7
|
-
});
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
server: {
|
|
5
|
+
open: true
|
|
6
|
+
}
|
|
7
|
+
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
node_modules
|
|
2
|
-
dist
|
|
1
|
+
node_modules
|
|
2
|
+
dist
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import js from "@eslint/js";
|
|
2
|
-
import globals from "globals";
|
|
3
|
-
import prettierConfig from "eslint-config-prettier";
|
|
4
|
-
import tseslint from "typescript-eslint";
|
|
5
|
-
|
|
6
|
-
export default tseslint.config(
|
|
7
|
-
{
|
|
8
|
-
ignores: ["dist/**", "node_modules/**"],
|
|
9
|
-
},
|
|
10
|
-
js.configs.recommended,
|
|
11
|
-
...tseslint.configs.recommended,
|
|
12
|
-
prettierConfig,
|
|
13
|
-
{
|
|
14
|
-
files: ["**/*.{ts,tsx}"],
|
|
15
|
-
languageOptions: {
|
|
16
|
-
ecmaVersion: "latest",
|
|
17
|
-
sourceType: "module",
|
|
18
|
-
globals: {
|
|
19
|
-
...globals.browser,
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
}
|
|
23
|
-
);
|
|
1
|
+
import js from "@eslint/js";
|
|
2
|
+
import globals from "globals";
|
|
3
|
+
import prettierConfig from "eslint-config-prettier";
|
|
4
|
+
import tseslint from "typescript-eslint";
|
|
5
|
+
|
|
6
|
+
export default tseslint.config(
|
|
7
|
+
{
|
|
8
|
+
ignores: ["dist/**", "node_modules/**"],
|
|
9
|
+
},
|
|
10
|
+
js.configs.recommended,
|
|
11
|
+
...tseslint.configs.recommended,
|
|
12
|
+
prettierConfig,
|
|
13
|
+
{
|
|
14
|
+
files: ["**/*.{ts,tsx}"],
|
|
15
|
+
languageOptions: {
|
|
16
|
+
ecmaVersion: "latest",
|
|
17
|
+
sourceType: "module",
|
|
18
|
+
globals: {
|
|
19
|
+
...globals.browser,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
}
|
|
23
|
+
);
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
|
|
4
|
-
<head>
|
|
5
|
-
<meta charset="UTF-8" />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
-
<title>{{name}}</title>
|
|
8
|
-
|
|
9
|
-
<style>
|
|
10
|
-
html,
|
|
11
|
-
body {
|
|
12
|
-
margin: 0;
|
|
13
|
-
padding: 0;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
canvas {
|
|
17
|
-
display: block;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
#pane {
|
|
21
|
-
position: fixed;
|
|
22
|
-
top: 12px;
|
|
23
|
-
right: 12px;
|
|
24
|
-
width: 260px;
|
|
25
|
-
z-index: 10;
|
|
26
|
-
pointer-events: auto;
|
|
27
|
-
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
28
|
-
}
|
|
29
|
-
</style>
|
|
30
|
-
</head>
|
|
31
|
-
|
|
32
|
-
<body>
|
|
33
|
-
<div id="pane"></div>
|
|
34
|
-
<script type="module" src="/src/sketch.ts"></script>
|
|
35
|
-
</body>
|
|
36
|
-
|
|
37
|
-
</html>
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="UTF-8" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>{{name}}</title>
|
|
8
|
+
|
|
9
|
+
<style>
|
|
10
|
+
html,
|
|
11
|
+
body {
|
|
12
|
+
margin: 0;
|
|
13
|
+
padding: 0;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
canvas {
|
|
17
|
+
display: block;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
#pane {
|
|
21
|
+
position: fixed;
|
|
22
|
+
top: 12px;
|
|
23
|
+
right: 12px;
|
|
24
|
+
width: 260px;
|
|
25
|
+
z-index: 10;
|
|
26
|
+
pointer-events: auto;
|
|
27
|
+
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
28
|
+
}
|
|
29
|
+
</style>
|
|
30
|
+
</head>
|
|
31
|
+
|
|
32
|
+
<body>
|
|
33
|
+
<div id="pane"></div>
|
|
34
|
+
<script type="module" src="/src/sketch.ts"></script>
|
|
35
|
+
</body>
|
|
36
|
+
|
|
37
|
+
</html>
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "{{name}}",
|
|
3
|
-
"version": "0.0.0",
|
|
4
|
-
"private": true,
|
|
5
|
-
"type": "module",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"dev": "vite",
|
|
8
|
-
"build": "vite build",
|
|
9
|
-
"preview": "vite preview",
|
|
10
|
-
"format": "prettier --write \"src/**/*.{js,ts}\"",
|
|
11
|
-
"format:check": "prettier --check \"src/**/*.{js,ts}\"",
|
|
12
|
-
"lint": "eslint src --ext .ts",
|
|
13
|
-
"lint:fix": "eslint src --ext .ts --fix",
|
|
14
|
-
"typecheck": "tsc --noEmit"
|
|
15
|
-
},
|
|
16
|
-
"dependencies": {
|
|
17
|
-
"textmode.js": "latest",
|
|
18
|
-
"tweakpane": "^4.0.5"
|
|
19
|
-
},
|
|
20
|
-
"devDependencies": {
|
|
21
|
-
"@eslint/js": "^9.39.1",
|
|
22
|
-
"@tweakpane/core": "^2.0.5",
|
|
23
|
-
"@types/node": "^24.10.2",
|
|
24
|
-
"eslint": "^9.39.1",
|
|
25
|
-
"eslint-config-prettier": "^10.1.8",
|
|
26
|
-
"globals": "^15.14.0",
|
|
27
|
-
"prettier": "^3.7.4",
|
|
28
|
-
"typescript": "^5.9.3",
|
|
29
|
-
"typescript-eslint": "^8.49.0",
|
|
30
|
-
"vite": "^7.2.7"
|
|
31
|
-
}
|
|
32
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "{{name}}",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite",
|
|
8
|
+
"build": "vite build",
|
|
9
|
+
"preview": "vite preview",
|
|
10
|
+
"format": "prettier --write \"src/**/*.{js,ts}\"",
|
|
11
|
+
"format:check": "prettier --check \"src/**/*.{js,ts}\"",
|
|
12
|
+
"lint": "eslint src --ext .ts",
|
|
13
|
+
"lint:fix": "eslint src --ext .ts --fix",
|
|
14
|
+
"typecheck": "tsc --noEmit"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"textmode.js": "latest",
|
|
18
|
+
"tweakpane": "^4.0.5"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@eslint/js": "^9.39.1",
|
|
22
|
+
"@tweakpane/core": "^2.0.5",
|
|
23
|
+
"@types/node": "^24.10.2",
|
|
24
|
+
"eslint": "^9.39.1",
|
|
25
|
+
"eslint-config-prettier": "^10.1.8",
|
|
26
|
+
"globals": "^15.14.0",
|
|
27
|
+
"prettier": "^3.7.4",
|
|
28
|
+
"typescript": "^5.9.3",
|
|
29
|
+
"typescript-eslint": "^8.49.0",
|
|
30
|
+
"vite": "^7.2.7"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
import { textmode } from 'textmode.js';
|
|
2
|
-
import { Pane } from 'tweakpane';
|
|
3
|
-
|
|
4
|
-
type RGB = { r: number; g: number; b: number };
|
|
5
|
-
|
|
6
|
-
type Params = {
|
|
7
|
-
speed: number;
|
|
8
|
-
frequency: number;
|
|
9
|
-
amplitude: number;
|
|
10
|
-
baseCharColor: RGB;
|
|
11
|
-
baseCellColor: RGB;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const tm = textmode.create({ width: window.innerWidth, height: window.innerHeight });
|
|
15
|
-
|
|
16
|
-
const params: Params = {
|
|
17
|
-
speed: 0.1,
|
|
18
|
-
frequency: 0.22,
|
|
19
|
-
amplitude: 1.1,
|
|
20
|
-
baseCharColor: { r: 0, g: 170, b: 255 },
|
|
21
|
-
baseCellColor: { r: 0, g: 0, b: 0 }
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const paneContainer = document.querySelector<HTMLElement>('#pane') ?? undefined;
|
|
25
|
-
const pane = new Pane({ title: 'Controls', container: paneContainer });
|
|
26
|
-
|
|
27
|
-
pane.addBinding(params, 'speed', { min: 0, max: 0.4, step: 0.005, label: 'Speed' });
|
|
28
|
-
pane.addBinding(params, 'frequency', { min: 0.05, max: 0.8, step: 0.01, label: 'Frequency' });
|
|
29
|
-
pane.addBinding(params, 'amplitude', { min: 0.5, max: 2.0, step: 0.05, label: 'Amplitude' });
|
|
30
|
-
pane.addBinding(params, 'baseCharColor', { label: 'Base Char Color' });
|
|
31
|
-
pane.addBinding(params, 'baseCellColor', { label: 'Base Cell Color' });
|
|
32
|
-
|
|
33
|
-
const clamp = (value: number, min: number, max: number): number => Math.min(Math.max(value, min), max);
|
|
34
|
-
|
|
35
|
-
const getChar = (wave: number): string => {
|
|
36
|
-
if (wave > 0.6) return '▓';
|
|
37
|
-
if (wave > 0.2) return '▒';
|
|
38
|
-
return '░';
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
tm.draw(() => {
|
|
42
|
-
const halfCols = Math.round(tm.grid.cols / 2) + 1;
|
|
43
|
-
const halfRows = Math.round(tm.grid.rows / 2) + 1;
|
|
44
|
-
|
|
45
|
-
for (let y = -halfRows; y < halfRows; y++) {
|
|
46
|
-
for (let x = -halfCols; x < halfCols; x++) {
|
|
47
|
-
const dist = Math.hypot(x, y);
|
|
48
|
-
const wave = Math.sin(dist * params.frequency - tm.frameCount * params.speed) * params.amplitude;
|
|
49
|
-
const char = getChar(wave);
|
|
50
|
-
|
|
51
|
-
const lightness = 0.35 + 0.65 * ((wave + params.amplitude) / (2 * params.amplitude));
|
|
52
|
-
const charR = clamp(params.baseCharColor.r * lightness, 0, 255);
|
|
53
|
-
const charG = clamp(params.baseCharColor.g * lightness, 0, 255);
|
|
54
|
-
const charB = clamp(params.baseCharColor.b * lightness, 0, 255);
|
|
55
|
-
const cellR = clamp(params.baseCellColor.r * lightness, 0, 255);
|
|
56
|
-
const cellG = clamp(params.baseCellColor.g * lightness, 0, 255);
|
|
57
|
-
const cellB = clamp(params.baseCellColor.b * lightness, 0, 255);
|
|
58
|
-
|
|
59
|
-
tm.push();
|
|
60
|
-
tm.translate(x, y, 0);
|
|
61
|
-
tm.char(char);
|
|
62
|
-
tm.charColor(charR, charG, charB);
|
|
63
|
-
tm.cellColor(cellR, cellG, cellB);
|
|
64
|
-
tm.point();
|
|
65
|
-
tm.pop();
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
tm.windowResized(() => {
|
|
71
|
-
tm.resizeCanvas(window.innerWidth, window.innerHeight);
|
|
72
|
-
});
|
|
1
|
+
import { textmode } from 'textmode.js';
|
|
2
|
+
import { Pane } from 'tweakpane';
|
|
3
|
+
|
|
4
|
+
type RGB = { r: number; g: number; b: number };
|
|
5
|
+
|
|
6
|
+
type Params = {
|
|
7
|
+
speed: number;
|
|
8
|
+
frequency: number;
|
|
9
|
+
amplitude: number;
|
|
10
|
+
baseCharColor: RGB;
|
|
11
|
+
baseCellColor: RGB;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const tm = textmode.create({ width: window.innerWidth, height: window.innerHeight });
|
|
15
|
+
|
|
16
|
+
const params: Params = {
|
|
17
|
+
speed: 0.1,
|
|
18
|
+
frequency: 0.22,
|
|
19
|
+
amplitude: 1.1,
|
|
20
|
+
baseCharColor: { r: 0, g: 170, b: 255 },
|
|
21
|
+
baseCellColor: { r: 0, g: 0, b: 0 }
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const paneContainer = document.querySelector<HTMLElement>('#pane') ?? undefined;
|
|
25
|
+
const pane = new Pane({ title: 'Controls', container: paneContainer });
|
|
26
|
+
|
|
27
|
+
pane.addBinding(params, 'speed', { min: 0, max: 0.4, step: 0.005, label: 'Speed' });
|
|
28
|
+
pane.addBinding(params, 'frequency', { min: 0.05, max: 0.8, step: 0.01, label: 'Frequency' });
|
|
29
|
+
pane.addBinding(params, 'amplitude', { min: 0.5, max: 2.0, step: 0.05, label: 'Amplitude' });
|
|
30
|
+
pane.addBinding(params, 'baseCharColor', { label: 'Base Char Color' });
|
|
31
|
+
pane.addBinding(params, 'baseCellColor', { label: 'Base Cell Color' });
|
|
32
|
+
|
|
33
|
+
const clamp = (value: number, min: number, max: number): number => Math.min(Math.max(value, min), max);
|
|
34
|
+
|
|
35
|
+
const getChar = (wave: number): string => {
|
|
36
|
+
if (wave > 0.6) return '▓';
|
|
37
|
+
if (wave > 0.2) return '▒';
|
|
38
|
+
return '░';
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
tm.draw(() => {
|
|
42
|
+
const halfCols = Math.round(tm.grid.cols / 2) + 1;
|
|
43
|
+
const halfRows = Math.round(tm.grid.rows / 2) + 1;
|
|
44
|
+
|
|
45
|
+
for (let y = -halfRows; y < halfRows; y++) {
|
|
46
|
+
for (let x = -halfCols; x < halfCols; x++) {
|
|
47
|
+
const dist = Math.hypot(x, y);
|
|
48
|
+
const wave = Math.sin(dist * params.frequency - tm.frameCount * params.speed) * params.amplitude;
|
|
49
|
+
const char = getChar(wave);
|
|
50
|
+
|
|
51
|
+
const lightness = 0.35 + 0.65 * ((wave + params.amplitude) / (2 * params.amplitude));
|
|
52
|
+
const charR = clamp(params.baseCharColor.r * lightness, 0, 255);
|
|
53
|
+
const charG = clamp(params.baseCharColor.g * lightness, 0, 255);
|
|
54
|
+
const charB = clamp(params.baseCharColor.b * lightness, 0, 255);
|
|
55
|
+
const cellR = clamp(params.baseCellColor.r * lightness, 0, 255);
|
|
56
|
+
const cellG = clamp(params.baseCellColor.g * lightness, 0, 255);
|
|
57
|
+
const cellB = clamp(params.baseCellColor.b * lightness, 0, 255);
|
|
58
|
+
|
|
59
|
+
tm.push();
|
|
60
|
+
tm.translate(x, y, 0);
|
|
61
|
+
tm.char(char);
|
|
62
|
+
tm.charColor(charR, charG, charB);
|
|
63
|
+
tm.cellColor(cellR, cellG, cellB);
|
|
64
|
+
tm.point();
|
|
65
|
+
tm.pop();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
tm.windowResized(() => {
|
|
71
|
+
tm.resizeCanvas(window.innerWidth, window.innerHeight);
|
|
72
|
+
});
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ESNext",
|
|
4
|
-
"useDefineForClassFields": true,
|
|
5
|
-
"module": "ESNext",
|
|
6
|
-
"moduleResolution": "Node",
|
|
7
|
-
"strict": true,
|
|
8
|
-
"jsx": "preserve",
|
|
9
|
-
"esModuleInterop": true,
|
|
10
|
-
"skipLibCheck": true,
|
|
11
|
-
"types": ["vite/client"]
|
|
12
|
-
},
|
|
13
|
-
"include": ["src"],
|
|
14
|
-
"references": []
|
|
15
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ESNext",
|
|
4
|
+
"useDefineForClassFields": true,
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"moduleResolution": "Node",
|
|
7
|
+
"strict": true,
|
|
8
|
+
"jsx": "preserve",
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"types": ["vite/client"]
|
|
12
|
+
},
|
|
13
|
+
"include": ["src"],
|
|
14
|
+
"references": []
|
|
15
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { defineConfig } from 'vite';
|
|
2
|
-
|
|
3
|
-
export default defineConfig({
|
|
4
|
-
server: {
|
|
5
|
-
open: true
|
|
6
|
-
}
|
|
7
|
-
});
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
server: {
|
|
5
|
+
open: true
|
|
6
|
+
}
|
|
7
|
+
});
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from "eslint/config";
|
|
2
|
-
import js from "@eslint/js";
|
|
3
|
-
import globals from "globals";
|
|
4
|
-
import prettierConfig from "eslint-config-prettier";
|
|
5
|
-
|
|
6
|
-
export default defineConfig([
|
|
7
|
-
{
|
|
8
|
-
ignores: ["dist/**", "node_modules/**"],
|
|
9
|
-
},
|
|
10
|
-
js.configs.recommended,
|
|
11
|
-
prettierConfig,
|
|
12
|
-
{
|
|
13
|
-
files: ["**/*.js"],
|
|
14
|
-
languageOptions: {
|
|
15
|
-
ecmaVersion: "latest",
|
|
16
|
-
sourceType: "module",
|
|
17
|
-
globals: {
|
|
18
|
-
...globals.browser,
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
]);
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
|
|
4
|
-
<head>
|
|
5
|
-
<meta charset="UTF-8" />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
-
<title>{{name}}</title>
|
|
8
|
-
|
|
9
|
-
<style>
|
|
10
|
-
html,
|
|
11
|
-
body {
|
|
12
|
-
margin: 0;
|
|
13
|
-
padding: 0;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
canvas {
|
|
17
|
-
display: block;
|
|
18
|
-
}
|
|
19
|
-
</style>
|
|
20
|
-
</head>
|
|
21
|
-
|
|
22
|
-
<body>
|
|
23
|
-
<script src="/fxhash.min.js"></script>
|
|
24
|
-
<script type="module" src="/src/sketch.js"></script>
|
|
25
|
-
</body>
|
|
26
|
-
|
|
27
|
-
</html>
|