distark-render 1.0.2 → 1.0.3
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/README.md +154 -154
- package/dist/modules/adapters/p5Renderer.d.ts +0 -0
- package/dist/modules/adapters/p5Renderer.d.ts.map +0 -0
- package/dist/modules/adapters/p5Renderer.js +0 -0
- package/dist/modules/adapters/p5Renderer.js.map +0 -0
- package/dist/modules/adapters/skiaRenderer.d.ts +0 -0
- package/dist/modules/adapters/skiaRenderer.d.ts.map +0 -0
- package/dist/modules/adapters/skiaRenderer.js +0 -0
- package/dist/modules/adapters/skiaRenderer.js.map +0 -0
- package/dist/modules/eyeSystem.d.ts +0 -0
- package/dist/modules/eyeSystem.d.ts.map +0 -0
- package/dist/modules/eyeSystem.js +0 -0
- package/dist/modules/eyeSystem.js.map +0 -0
- package/dist/modules/imageLoad.d.ts +0 -0
- package/dist/modules/imageLoad.d.ts.map +0 -0
- package/dist/modules/imageLoad.js +0 -0
- package/dist/modules/imageLoad.js.map +0 -0
- package/dist/modules/mouthSystem.d.ts +0 -0
- package/dist/modules/mouthSystem.d.ts.map +0 -0
- package/dist/modules/mouthSystem.js +0 -0
- package/dist/modules/mouthSystem.js.map +0 -0
- package/dist/modules/renderRig.d.ts +0 -0
- package/dist/modules/renderRig.d.ts.map +0 -0
- package/dist/modules/renderRig.js +0 -0
- package/dist/modules/renderRig.js.map +0 -0
- package/dist/tests/test-joint-movement.d.ts +0 -0
- package/dist/tests/test-joint-movement.d.ts.map +0 -0
- package/dist/tests/test-joint-movement.js +0 -0
- package/dist/tests/test-joint-movement.js.map +0 -0
- package/dist/tests/test-skia.d.ts +0 -0
- package/dist/tests/test-skia.d.ts.map +0 -0
- package/dist/tests/test-skia.js +0 -0
- package/dist/tests/test-skia.js.map +0 -0
- package/dist/tests/test-visual-verification.d.ts +0 -0
- package/dist/tests/test-visual-verification.d.ts.map +0 -0
- package/dist/tests/test-visual-verification.js +0 -0
- package/dist/tests/test-visual-verification.js.map +0 -0
- package/dist/types.d.ts +0 -0
- package/dist/types.d.ts.map +0 -0
- package/dist/types.js +0 -0
- package/dist/types.js.map +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,154 +1,154 @@
|
|
|
1
|
-
# Distark Render
|
|
2
|
-
|
|
3
|
-
Rendering-agnostic character rig system with TypeScript. Render 2D character rigs to HTML Canvas with automatic image loading and caching.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install distark-render
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Usage
|
|
12
|
-
|
|
13
|
-
### Browser (ES Modules)
|
|
14
|
-
|
|
15
|
-
```html
|
|
16
|
-
<canvas id="canvas" width="800" height="800"></canvas>
|
|
17
|
-
|
|
18
|
-
<script type="module">
|
|
19
|
-
import { ImageLoader, CharacterRigRenderer } from 'https://unpkg.com/distark-render';
|
|
20
|
-
|
|
21
|
-
const imageLoader = new ImageLoader();
|
|
22
|
-
const renderer = new CharacterRigRenderer(imageLoader);
|
|
23
|
-
const canvas = document.getElementById('canvas');
|
|
24
|
-
|
|
25
|
-
// Load character data
|
|
26
|
-
const characterData = await fetch('character.json').then(r => r.json());
|
|
27
|
-
|
|
28
|
-
// Render to canvas
|
|
29
|
-
await renderer.render(canvas, characterData);
|
|
30
|
-
</script>
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
### Node.js
|
|
34
|
-
|
|
35
|
-
```javascript
|
|
36
|
-
import { ImageLoader, CharacterRigRenderer } from 'distark-render';
|
|
37
|
-
|
|
38
|
-
const imageLoader = new ImageLoader();
|
|
39
|
-
const renderer = new CharacterRigRenderer(imageLoader);
|
|
40
|
-
const canvas = document.getElementById('canvas');
|
|
41
|
-
const characterData = await fetch('character.json').then(r => r.json());
|
|
42
|
-
await renderer.render(canvas, characterData);
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
## Features
|
|
46
|
-
|
|
47
|
-
- 🎨 Rendering-agnostic architecture
|
|
48
|
-
- 🖼️ Automatic image loading and caching
|
|
49
|
-
- 🔄 Support for MD5 hashes and direct URLs
|
|
50
|
-
- 👁️ Eye and mouth animation systems
|
|
51
|
-
- ⚡ TypeScript support with full type definitions
|
|
52
|
-
- 🌐 Works in browser and Node.js
|
|
53
|
-
|
|
54
|
-
## Testing
|
|
55
|
-
|
|
56
|
-
### Automated Test Suite
|
|
57
|
-
|
|
58
|
-
Run all automated tests to verify rendering and joint movement:
|
|
59
|
-
|
|
60
|
-
```bash
|
|
61
|
-
# Run all tests (visual verification + joint movement)
|
|
62
|
-
npm test
|
|
63
|
-
|
|
64
|
-
# Or run tests individually
|
|
65
|
-
npm run test-visual # Eyes and mouth rendering
|
|
66
|
-
npm run test-joints # Joint movement and limb positioning
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
### Visual Verification Test
|
|
70
|
-
|
|
71
|
-
Verify that eyes and mouth are rendering correctly using automated color comparison:
|
|
72
|
-
|
|
73
|
-
```bash
|
|
74
|
-
# Test a specific character file
|
|
75
|
-
npm run test-visual
|
|
76
|
-
node dist/tests/test-visual-verification.js character.json
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
**What it tests:**
|
|
80
|
-
- ✅ Left eye region has rendered content
|
|
81
|
-
- ✅ Right eye region has rendered content
|
|
82
|
-
- ✅ Mouth region has rendered content
|
|
83
|
-
|
|
84
|
-
The test uses pixel sampling and color comparison to verify that character features are actually being rendered to the canvas. It calculates expected regions based on the rig data and checks that those regions contain pixels different from the background color.
|
|
85
|
-
|
|
86
|
-
### Joint Movement Test
|
|
87
|
-
|
|
88
|
-
Verify that character joints move correctly and limbs appear in expected screen sectors:
|
|
89
|
-
|
|
90
|
-
```bash
|
|
91
|
-
# Test joint movements
|
|
92
|
-
npm run test-joints
|
|
93
|
-
node dist/tests/test-joint-movement.js character.json
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
**What it tests:**
|
|
97
|
-
- ✅ **Arm Raised**: Left arm rotates upward and appears in top/middle-left sector
|
|
98
|
-
- ✅ **Leg Forward**: Right leg moves forward and appears in middle/bottom-right sector
|
|
99
|
-
- ✅ **Head Rotation**: Head turns and remains in top/middle-center sector
|
|
100
|
-
- ✅ **Multiple Joints**: Arms spread and legs move simultaneously (T-pose)
|
|
101
|
-
|
|
102
|
-
The test modifies joint rotation values and verifies that limbs render in the expected screen sectors by sampling pixels and checking for content (non-background pixels). This ensures the rendering pipeline correctly applies transformations to the character rig.
|
|
103
|
-
|
|
104
|
-
### Manual Testing with Command Line
|
|
105
|
-
|
|
106
|
-
You can also manually test character rigs and save rendered output:
|
|
107
|
-
|
|
108
|
-
```bash
|
|
109
|
-
# Build the project first
|
|
110
|
-
npm run build
|
|
111
|
-
|
|
112
|
-
# Run test-skia with default settings (renders tank.json)
|
|
113
|
-
npm run test-skia
|
|
114
|
-
|
|
115
|
-
# Or run directly with custom parameters:
|
|
116
|
-
node dist/tests/test-skia.js [input.json] [output.png] [width] [height]
|
|
117
|
-
|
|
118
|
-
# Examples:
|
|
119
|
-
node dist/tests/test-skia.js tank.json output.png 1000 1000
|
|
120
|
-
node dist/tests/test-skia.js character.json render.png 800 600
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
**Parameters:**
|
|
124
|
-
- `input.json` - Path to your character rig JSON file (default: `assets/tank.json`)
|
|
125
|
-
- `output.png` - Output image filename (default: `output-tank.png`)
|
|
126
|
-
- `width` - Canvas width in pixels (default: `1000`)
|
|
127
|
-
- `height` - Canvas height in pixels (default: `1000`)
|
|
128
|
-
|
|
129
|
-
The test script will:
|
|
130
|
-
1. Load your character rig JSON
|
|
131
|
-
2. Automatically fetch and cache all images
|
|
132
|
-
3. Render the character to a PNG file
|
|
133
|
-
4. Show pivot points for debugging
|
|
134
|
-
|
|
135
|
-
## API
|
|
136
|
-
|
|
137
|
-
### ImageLoader
|
|
138
|
-
|
|
139
|
-
Handles loading images from URLs or MD5 hashes with automatic caching.
|
|
140
|
-
|
|
141
|
-
```typescript
|
|
142
|
-
const imageLoader = new ImageLoader(baseHost?: string);
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
### CharacterRigRenderer
|
|
146
|
-
|
|
147
|
-
Renders character rigs to canvas.
|
|
148
|
-
|
|
149
|
-
```typescript
|
|
150
|
-
const renderer = new CharacterRigRenderer(imageLoader?: ImageLoader);
|
|
151
|
-
await renderer.render(canvas, rigData, loadedImages?, cameraOffset?, showPivotPoints?);
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
|
|
1
|
+
# Distark Render
|
|
2
|
+
|
|
3
|
+
Rendering-agnostic character rig system with TypeScript. Render 2D character rigs to HTML Canvas with automatic image loading and caching.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install distark-render
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### Browser (ES Modules)
|
|
14
|
+
|
|
15
|
+
```html
|
|
16
|
+
<canvas id="canvas" width="800" height="800"></canvas>
|
|
17
|
+
|
|
18
|
+
<script type="module">
|
|
19
|
+
import { ImageLoader, CharacterRigRenderer } from 'https://unpkg.com/distark-render';
|
|
20
|
+
|
|
21
|
+
const imageLoader = new ImageLoader();
|
|
22
|
+
const renderer = new CharacterRigRenderer(imageLoader);
|
|
23
|
+
const canvas = document.getElementById('canvas');
|
|
24
|
+
|
|
25
|
+
// Load character data
|
|
26
|
+
const characterData = await fetch('character.json').then(r => r.json());
|
|
27
|
+
|
|
28
|
+
// Render to canvas
|
|
29
|
+
await renderer.render(canvas, characterData);
|
|
30
|
+
</script>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Node.js
|
|
34
|
+
|
|
35
|
+
```javascript
|
|
36
|
+
import { ImageLoader, CharacterRigRenderer } from 'distark-render';
|
|
37
|
+
|
|
38
|
+
const imageLoader = new ImageLoader();
|
|
39
|
+
const renderer = new CharacterRigRenderer(imageLoader);
|
|
40
|
+
const canvas = document.getElementById('canvas');
|
|
41
|
+
const characterData = await fetch('character.json').then(r => r.json());
|
|
42
|
+
await renderer.render(canvas, characterData);
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Features
|
|
46
|
+
|
|
47
|
+
- 🎨 Rendering-agnostic architecture
|
|
48
|
+
- 🖼️ Automatic image loading and caching
|
|
49
|
+
- 🔄 Support for MD5 hashes and direct URLs
|
|
50
|
+
- 👁️ Eye and mouth animation systems
|
|
51
|
+
- ⚡ TypeScript support with full type definitions
|
|
52
|
+
- 🌐 Works in browser and Node.js
|
|
53
|
+
|
|
54
|
+
## Testing
|
|
55
|
+
|
|
56
|
+
### Automated Test Suite
|
|
57
|
+
|
|
58
|
+
Run all automated tests to verify rendering and joint movement:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
# Run all tests (visual verification + joint movement)
|
|
62
|
+
npm test
|
|
63
|
+
|
|
64
|
+
# Or run tests individually
|
|
65
|
+
npm run test-visual # Eyes and mouth rendering
|
|
66
|
+
npm run test-joints # Joint movement and limb positioning
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Visual Verification Test
|
|
70
|
+
|
|
71
|
+
Verify that eyes and mouth are rendering correctly using automated color comparison:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
# Test a specific character file
|
|
75
|
+
npm run test-visual
|
|
76
|
+
node dist/tests/test-visual-verification.js character.json
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**What it tests:**
|
|
80
|
+
- ✅ Left eye region has rendered content
|
|
81
|
+
- ✅ Right eye region has rendered content
|
|
82
|
+
- ✅ Mouth region has rendered content
|
|
83
|
+
|
|
84
|
+
The test uses pixel sampling and color comparison to verify that character features are actually being rendered to the canvas. It calculates expected regions based on the rig data and checks that those regions contain pixels different from the background color.
|
|
85
|
+
|
|
86
|
+
### Joint Movement Test
|
|
87
|
+
|
|
88
|
+
Verify that character joints move correctly and limbs appear in expected screen sectors:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
# Test joint movements
|
|
92
|
+
npm run test-joints
|
|
93
|
+
node dist/tests/test-joint-movement.js character.json
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**What it tests:**
|
|
97
|
+
- ✅ **Arm Raised**: Left arm rotates upward and appears in top/middle-left sector
|
|
98
|
+
- ✅ **Leg Forward**: Right leg moves forward and appears in middle/bottom-right sector
|
|
99
|
+
- ✅ **Head Rotation**: Head turns and remains in top/middle-center sector
|
|
100
|
+
- ✅ **Multiple Joints**: Arms spread and legs move simultaneously (T-pose)
|
|
101
|
+
|
|
102
|
+
The test modifies joint rotation values and verifies that limbs render in the expected screen sectors by sampling pixels and checking for content (non-background pixels). This ensures the rendering pipeline correctly applies transformations to the character rig.
|
|
103
|
+
|
|
104
|
+
### Manual Testing with Command Line
|
|
105
|
+
|
|
106
|
+
You can also manually test character rigs and save rendered output:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
# Build the project first
|
|
110
|
+
npm run build
|
|
111
|
+
|
|
112
|
+
# Run test-skia with default settings (renders tank.json)
|
|
113
|
+
npm run test-skia
|
|
114
|
+
|
|
115
|
+
# Or run directly with custom parameters:
|
|
116
|
+
node dist/tests/test-skia.js [input.json] [output.png] [width] [height]
|
|
117
|
+
|
|
118
|
+
# Examples:
|
|
119
|
+
node dist/tests/test-skia.js tank.json output.png 1000 1000
|
|
120
|
+
node dist/tests/test-skia.js character.json render.png 800 600
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
**Parameters:**
|
|
124
|
+
- `input.json` - Path to your character rig JSON file (default: `assets/tank.json`)
|
|
125
|
+
- `output.png` - Output image filename (default: `output-tank.png`)
|
|
126
|
+
- `width` - Canvas width in pixels (default: `1000`)
|
|
127
|
+
- `height` - Canvas height in pixels (default: `1000`)
|
|
128
|
+
|
|
129
|
+
The test script will:
|
|
130
|
+
1. Load your character rig JSON
|
|
131
|
+
2. Automatically fetch and cache all images
|
|
132
|
+
3. Render the character to a PNG file
|
|
133
|
+
4. Show pivot points for debugging
|
|
134
|
+
|
|
135
|
+
## API
|
|
136
|
+
|
|
137
|
+
### ImageLoader
|
|
138
|
+
|
|
139
|
+
Handles loading images from URLs or MD5 hashes with automatic caching.
|
|
140
|
+
|
|
141
|
+
```typescript
|
|
142
|
+
const imageLoader = new ImageLoader(baseHost?: string);
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### CharacterRigRenderer
|
|
146
|
+
|
|
147
|
+
Renders character rigs to canvas.
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
const renderer = new CharacterRigRenderer(imageLoader?: ImageLoader);
|
|
151
|
+
await renderer.render(canvas, rigData, loadedImages?, cameraOffset?, showPivotPoints?);
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/tests/test-skia.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/types.d.ts
CHANGED
|
File without changes
|
package/dist/types.d.ts.map
CHANGED
|
File without changes
|
package/dist/types.js
CHANGED
|
File without changes
|
package/dist/types.js.map
CHANGED
|
File without changes
|