@theatrejs/loader-aseprite 1.3.0 → 1.4.1
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/package.json +2 -2
- package/sources/aseprite.loader.js +51 -45
package/package.json
CHANGED
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"html",
|
|
31
31
|
"html5",
|
|
32
32
|
"javascript",
|
|
33
|
-
"pixel-art",
|
|
34
33
|
"loader",
|
|
34
|
+
"pixel-art",
|
|
35
35
|
"theatrejs",
|
|
36
36
|
"theatrejs-loader",
|
|
37
37
|
"webgl",
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"postversion": "node ./tools/custom/postversion.cjs"
|
|
58
58
|
},
|
|
59
59
|
"type": "commonjs",
|
|
60
|
-
"version": "1.
|
|
60
|
+
"version": "1.4.1"
|
|
61
61
|
}
|
|
@@ -67,65 +67,71 @@ module.exports = function loader() {
|
|
|
67
67
|
|
|
68
68
|
try {
|
|
69
69
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
70
|
+
if (fs.existsSync(path.resolve(location, sourceTexture)) === false
|
|
71
|
+
|| fs.existsSync(path.resolve(location, sourceData)) === false
|
|
72
|
+
|| fs.statSync(path.resolve(location, sourceTexture)).mtime < fs.statSync(file).mtime
|
|
73
|
+
|| fs.statSync(path.resolve(location, sourceData)).mtime < fs.statSync(file).mtime) {
|
|
74
|
+
|
|
75
|
+
subprocess.execSync(
|
|
76
|
+
|
|
77
|
+
'cd "' + location + '"' +
|
|
78
|
+
|
|
79
|
+
' && "' + aseprite + '"' +
|
|
80
|
+
' --batch "' + file + '"' +
|
|
81
|
+
trim +
|
|
82
|
+
' --sheet "' + sourceTexture + '"' +
|
|
83
|
+
' --sheet-type ' + sheetType +
|
|
84
|
+
' --split-tags' +
|
|
85
|
+
' --data "' + sourceData + '"' +
|
|
86
|
+
' --list-tags' +
|
|
87
|
+
' --format json-array' +
|
|
88
|
+
' --filename-format {tag}#{tagframe001}@{title}.{extension}'
|
|
89
|
+
);
|
|
85
90
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
91
|
+
if (typeof processing !== 'undefined'
|
|
92
|
+
&& Array.isArray(processing.colorswap)
|
|
93
|
+
&& processing.colorswap.length > 0) {
|
|
89
94
|
|
|
90
|
-
|
|
91
|
-
|
|
95
|
+
const bufferSource = fs.readFileSync(path.resolve(location, sourceTexture));
|
|
96
|
+
const image = pngjs.read(bufferSource);
|
|
92
97
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
98
|
+
const pixels = image.data;
|
|
99
|
+
const height = image.height;
|
|
100
|
+
const width = image.width;
|
|
96
101
|
|
|
97
|
-
|
|
102
|
+
processing.colorswap.forEach(({source, target}) => {
|
|
98
103
|
|
|
99
|
-
|
|
100
|
-
|
|
104
|
+
const [redSource, greenSource, blueSource, alphaSource] = source;
|
|
105
|
+
const [redTarget, greenTarget, blueTarget, alphaTarget] = target;
|
|
101
106
|
|
|
102
|
-
|
|
107
|
+
for (let y = 0; y < height; y += 1) {
|
|
103
108
|
|
|
104
|
-
|
|
109
|
+
for (let x = 0; x < width; x += 1) {
|
|
105
110
|
|
|
106
|
-
|
|
111
|
+
const index = (width * y + x) * 4;
|
|
107
112
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
113
|
+
const indexRed = index;
|
|
114
|
+
const indexGreen = index + 1;
|
|
115
|
+
const indexBlue = index + 2;
|
|
116
|
+
const indexAlpha = index + 3;
|
|
112
117
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
118
|
+
if (pixels[indexRed] === redSource
|
|
119
|
+
&& pixels[indexGreen] === greenSource
|
|
120
|
+
&& pixels[indexBlue] === blueSource
|
|
121
|
+
&& pixels[indexAlpha] === alphaSource) {
|
|
117
122
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
123
|
+
pixels[indexRed] = redTarget;
|
|
124
|
+
pixels[indexGreen] = greenTarget;
|
|
125
|
+
pixels[indexBlue] = blueTarget;
|
|
126
|
+
pixels[indexAlpha] = alphaTarget;
|
|
127
|
+
}
|
|
122
128
|
}
|
|
123
129
|
}
|
|
124
|
-
}
|
|
125
|
-
});
|
|
130
|
+
});
|
|
126
131
|
|
|
127
|
-
|
|
128
|
-
|
|
132
|
+
const bufferTarget = pngjs.write(image);
|
|
133
|
+
fs.writeFileSync(path.resolve(location, sourceTexture), bufferTarget);
|
|
134
|
+
}
|
|
129
135
|
}
|
|
130
136
|
|
|
131
137
|
return (
|