-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGraphicConverterMD.html
399 lines (368 loc) · 23.5 KB
/
GraphicConverterMD.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
<!doctype html>
<html lang="en">
<head>
<title>MegaDrive Graphic Converter Script</title>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="./include/jquery.min.js"></script>
<link rel="stylesheet" href="./include/bootstrap.min.css">
<script src="./include/bootstrap.min.js"></script>
<link rel="stylesheet" href="./GraphicConverterMD.css">
<script src="./include/Heap.js"></script>
<script src="./include/ColorQuantizer.js"></script>
<script src="./MiscColorFuncs.js"></script>
<script src="./GraphicConverterMD.js"></script>
</head>
<body>
<div class="container">
<div class="page-header">
<h1>
<strong>MegaDrive Graphic Converter Script </strong>alpha 0.2<br>
<small>by <a href="http://twitter.com/luceraproject" target="_blank">@luceraproject</a></small>
</h1>
<p>inspired by the work of <a href="http://twitter.com/pixelartm" target="_blank">@pixelartm</a></p>
</div>
<form id="page_form">
<div id="page_file">
<!-- Use external Palette -->
<div class="row" style="background-color: #eee">
<strong>External Palette:</strong>
<hr>
<div class="w-100"></div>
<div class="custom-control custom-checkbox">
<input class="custom-control-input" type="checkbox" id="palette_checkbox" onchange="SetUseExternalPalette(this.checked)">
<label class="custom-control-label" for="palette_checkbox">Use external Palette</label>
</div>
<div class="w-100"></div>
<div class="input-group" id="palette_group">
<div class="input-group-prepend">
<span class="input-group-text">Select palette image:</span>
</div>
<div class="custom-file">
<label class="custom-file-label" for="fileInputPal" id="fileInputPalLabel" style="background-color: #e9ecef"></label>
<input class="custom-file-input" type="file" id="fileInputPal" onchange="ReadFilePalette(this)" disabled>
<div class="input-group-append">
<button class="btn btn-outline-primary" type="button" style="border-radius: 0;" onclick="$('#fileInputPal').trigger('click');">Browse</button>
</div>
</div>
<div class="input-group-append">
<input class="input-group-append" type="url" id="remote_pal" style="background-color: #e9ecef; border: solid 1px #ced4da" value="">
</div>
</div>
<div class="custom-control custom-checkbox">
<input class="custom-control-input" type="checkbox" checked id="fix_palette_colors_checkbox" onchange="SetFixPaletteColors(this.checked)">
<label class="custom-control-label" for="fix_palette_colors_checkbox">Fix palette colors<small> (try to avoid them from color reduction)</small></label>
</div>
</div>
<!-- Define transparent color -->
<br/>
<div class="row" style="background-color: #eee">
<strong>Transparent Color:</strong>
<hr>
<div class="w-100"></div>
<div class="custom-control custom-checkbox">
<input class="custom-control-input" type="checkbox" checked id="transparent_color_checkbox" onchange="SetUseExtTransparentColor(this.checked)">
<label class="custom-control-label" for="transparent_color_checkbox">Define default transparent colors<small> (or use colors from palette)</small></label>
</div>
<div class="w-100"></div>
<div class="input-group" id="transparent_color_group">
<div class="col-3" style="padding: 0;">
<span class="input-group-text" style="border-radius: 0;"> Palette 1: </span>
</div>
<input class="input-group-text col-2" type="text" id="ext_transparent_color0" value="#fc00fc" style="background-color:#fc00fc; border-radius: 0;" onchange="SetExtTransparentColor(0, this.value)" />
<input class="input-group-text col-2" type="text" id="ext_transparent_color_md0" value="MD: #fc00fc" style="background-color:#fc00fc; border-radius: 0;" disabled/>
<div class="col-5" style="padding: 0">
<span class="input-group-text" id="ext_transparent_color_error0" style="border-radius: 0;">Ok</span>
</div>
<div class="w-100"></div>
<div class="col-3" style="padding: 0;">
<span class="input-group-text" style="border-radius: 0;"> Palette 2: </span>
</div>
<input class="input-group-text col-2" type="text" id="ext_transparent_color1" value="#d800d8" style="background-color:#d800d8; border-radius: 0;" onchange="SetExtTransparentColor(1, this.value)" />
<input class="input-group-text col-2" type="text" id="ext_transparent_color_md1" value="MD: #d800d8" style="background-color:#d800d8; border-radius: 0;" disabled/>
<div class="col-5" style="padding: 0">
<span class="input-group-text" id="ext_transparent_color_error1" style="border-radius: 0;">Ok</span>
</div>
<div class="w-100"></div>
<div class="col-3" style="padding: 0;">
<span class="input-group-text" style="border-radius: 0;"> Palette 3: </span>
</div>
<input class="input-group-text col-2" type="text" id="ext_transparent_color2" value="#b400b4" style="background-color:#b400b4; border-radius: 0;" onchange="SetExtTransparentColor(2, this.value)" />
<input class="input-group-text col-2" type="text" id="ext_transparent_color_md2" value="MD: #b400b4" style="background-color:#b400b4; border-radius: 0;" disabled/>
<div class="col-5" style="padding: 0">
<span class="input-group-text" id="ext_transparent_color_error2" style="border-radius: 0;">Ok</span>
</div>
<div class="w-100"></div>
<div class="col-3" style="padding: 0;">
<span class="input-group-text" style="border-radius: 0;"> Palette 4: </span>
</div>
<input class="input-group-text col-2" type="text" id="ext_transparent_color3" value="#900090" style="background-color:#900090; border-radius: 0;" onchange="SetExtTransparentColor(3, this.value)" />
<input class="input-group-text col-2" type="text" id="ext_transparent_color_md3" value="MD: #900090" style="background-color:#900090; border-radius: 0;" disabled/>
<div class="col-5" style="padding: 0">
<span class="input-group-text" id="ext_transparent_color_error3" style="border-radius: 0;">Ok</span>
</div>
</div>
<div class="custom-control custom-checkbox">
<input class="custom-control-input" type="checkbox" checked id="fix_transparent_color_checkbox" onchange="SetFixTransparentColor(this.checked)">
<label class="custom-control-label" for="fix_transparent_color_checkbox">Fix transparent color<small> (avoid it from color reduction)</small></label>
</div>
</div>
<!-- Image MegaDrive Config: -->
<br/>
<div class="row" style="background-color: #eee">
<strong>Image MegaDrive Config:</strong>
<hr>
<div class="w-100"></div>
<!-- Limit number of colors -->
<div class="custom-control custom-checkbox">
<input class="custom-control-input" type="checkbox" id="limit_colors_checkbox" onchange="SetUseLimitColors(this.checked)">
<label class="custom-control-label" for="limit_colors_checkbox">Limit number of colors</label>
</div>
<div class="w-100"></div>
<div class="form-check" id="limit_colors_group">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">Colors: </span>
</div>
<input class="form-control" type="text" id="num_colors" value="16" disabled>
<div class="input-group-append">
<button class="btn btn-primary" type="button" id="num_colors-16" onclick="SetLimitColorsTo(16);">16</button>
</div>
<div class="input-group-append">
<button class="btn btn-outline-primary" type="button" id="num_colors-32" onclick="SetLimitColorsTo(32);">32</button>
</div>
<div class="input-group-append">
<button class="btn btn-outline-primary" type="button" id="num_colors-48" onclick="SetLimitColorsTo(48);">48</button>
</div>
<div class="input-group-append">
<button class="btn btn-outline-primary" type="button" id="num_colors-64" onclick="SetLimitColorsTo(64);">64</button>
</div>
</div>
</div>
<!-- Use Blue Noise -->
<div class="w-100"></div>
<div class="custom-control custom-checkbox">
<input class="custom-control-input" type="checkbox" id="blue_noise_checkbox" onchange="SetUseBlueNoise(this.checked)">
<label class="custom-control-label" for="blue_noise_checkbox">Use Blue Noise</label>
</div>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">Select image:</span>
</div>
<div class="custom-file">
<label class="custom-file-label" for="fileInputBlueNoise" id="fileInputBlueNoiseLabel" style="background-color: #e9ecef"></label>
<input class="custom-file-input" type="file" id="fileInputBlueNoise" onchange="ReadFileBlueNoise(this)">
<div class="input-group-append">
<button class="btn btn-outline-primary" type="button" style="border-radius: 0;" onclick="$('#fileInputBlueNoise').trigger('click');">Browse</button>
</div>
</div>
<div class="input-group-append">
<input class="input-group-append" type="url" id="remote_blue_noise" style="background-color: #e9ecef; border: solid 1px #ced4da" value="">
</div>
</div>
<!-- Use dithering -->
<div class="w-100"></div>
<div class="custom-control custom-checkbox">
<input class="custom-control-input" type="checkbox" id="dithering_checkbox" onchange="SetUseDithering(this.checked)">
<label class="custom-control-label" for="dithering_checkbox">Use dithering</label>
</div>
<div class="w-100"></div>
<!-- Add image colors to palette -->
<div class="custom-control custom-checkbox">
<input class="custom-control-input" type="checkbox" id="add_image_colors_checkbox" onchange="SetAddImageColors(this.checked)">
<label class="custom-control-label" for="add_image_colors_checkbox">Add image colors to palette</label>
</div>
</div>
<!-- Use external Tileset -->
<br/>
<div class="row" style="background-color: #eee">
<strong>External Tileset:</strong>
<hr>
<div class="w-100"></div>
<div class="custom-control custom-checkbox">
<input class="custom-control-input" type="checkbox" id="tileset_checkbox" onchange="SetUseExternalTileset(this.checked)">
<label class="custom-control-label" for="tileset_checkbox">Use external Tileset</label>
</div>
<div class="w-100"></div>
<div class="input-group" id="tileset_group">
<div class="input-group-prepend">
<span class="input-group-text">Select tileset image:</span>
</div>
<div class="custom-file">
<label class="custom-file-label" for="fileInputTileset" id="fileInputTilesetLabel" style="background-color: #e9ecef"></label>
<input class="custom-file-input" type="file" id="fileInputTileset" onchange="ReadFileTileset(this)" disabled>
<div class="input-group-append">
<button class="btn btn-outline-primary" type="button" style="border-radius: 0;" onclick="$('#fileInputTileset').trigger('click');">Browse</button>
</div>
</div>
<div class="input-group-append">
<input class="input-group-append" type="url" id="remote_tileset" style="background-color: #e9ecef; border: solid 1px #ced4da" value="">
</div>
</div>
</div>
<!-- Output Mode -->
<br/>
<div class="row" style="background-color: #eee">
<strong>Output Mode:</strong>
<hr>
<div class="w-100"></div>
<!-- Just Palette -->
<div class="w-100"></div>
<div class="form-check">
<label class="form-check-label">
<input type="radio" class="form-check-input" name="mode_radio" checked value="0" onchange="SetOutputMode(this.value);">Just give me the palette
</label>
</div>
<!-- Generate Sprites -->
<div class="w-100"></div>
<div class="form-check">
<label class="form-check-label">
<input type="radio" class="form-check-input" name="mode_radio" value="1" onchange="SetOutputMode(this.value);">Generate sprite data
</label>
<div class="w-100"></div>
<div id="mode_sprite_group">
<div class="custom-control custom-checkbox">
<input class="custom-control-input" type="checkbox" id="optimize_sprite_checkbox" onchange="SetOptimizeSpriteData(this.checked)">
<label class="custom-control-label" for="optimize_sprite_checkbox">Optimize sprite data</label>
</div>
<div class="w-100"></div>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">Width: </span>
</div>
<input class="form-control" type="text" id="spt_width" value="8" disabled>
<div class="input-group-append">
<button class="btn btn-primary" type="button" id="spt_width-8" onclick="SetSpriteWidth(8);"> 8</button>
</div>
<div class="input-group-append">
<button class="btn btn-outline-primary" type="button" id="spt_width-16" onclick="SetSpriteWidth(16);">16</button>
</div>
<div class="input-group-append">
<button class="btn btn-outline-primary" type="button" id="spt_width-24" onclick="SetSpriteWidth(24);">24</button>
</div>
<div class="input-group-append">
<button class="btn btn-outline-primary" type="button" id="spt_width-32" onclick="SetSpriteWidth(32);">32</button>
</div>
</div>
<div class="w-100"></div>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">Height:</span>
</div>
<input class="form-control" type="text" id="spt_height" value="8" disabled>
<div class="input-group-append">
<button class="btn btn-primary" type="button" id="spt_height-8" onclick="SetSpriteHeight(8);"> 8</button>
</div>
<div class="input-group-append">
<button class="btn btn-outline-primary" type="button" id="spt_height-16" onclick="SetSpriteHeight(16);">16</button>
</div>
<div class="input-group-append">
<button class="btn btn-outline-primary" type="button" id="spt_height-24" onclick="SetSpriteHeight(24);">24</button>
</div>
<div class="input-group-append">
<button class="btn btn-outline-primary" type="button" id="spt_height-32" onclick="SetSpriteHeight(32);">32</button>
</div>
</div>
</div>
</div>
<!-- Generate Image -->
<div class="w-100"></div>
<div class="form-check">
<label class="form-check-label">
<input type="radio" class="form-check-input" name="mode_radio" value="2" onchange="SetOutputMode(this.value);">Generate plane data
</label>
<div class="w-100"></div>
<div id="mode_image_group">
<div class="custom-control custom-checkbox">
<input class="custom-control-input" type="checkbox" id="optimize_image_checkbox" onchange="SetOptimizeImageData(this.checked)">
<label class="custom-control-label" for="optimize_image_checkbox">Optimize image data</label>
</div>
<div class="w-100"></div>
<div class="custom-control custom-checkbox">
<input class="custom-control-input" type="checkbox" id="add_metadata_checkbox" onchange="SetAddMetadata(this.checked)">
<label class="custom-control-label" for="add_metadata_checkbox">Add metadata to tiles (Palette, FlipH, FlipV)</label>
</div>
</div>
</div>
</div>
<!-- Select Image -->
<br/>
<div class="row" style="background-color: #eee">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">Select image:</span>
</div>
<div class="custom-file">
<label class="custom-file-label" for="fileInputImage" id="fileInputImageLabel" style="background-color: #e9ecef"></label>
<input class="custom-file-input" type="file" id="fileInputImage" onchange="ReadFileImage(this)">
<div class="input-group-append">
<button class="btn btn-outline-primary" type="button" style="border-radius: 0;" onclick="$('#fileInputImage').trigger('click');">Browse</button>
</div>
</div>
<div class="input-group-append">
<input class="input-group-append" type="url" id="remote_img" style="background-color: #e9ecef; border: solid 1px #ced4da" value="">
</div>
<div class="input-group-append">
<button class="btn btn-primary" type="button" onclick="$('#page_form').submit()">Run!</button>
</div>
</div>
</div>
</div>
</form>
<!-- Messages -->
<br/>
<div class="row" style="background-color: #eee">
<h5>Messages:</h5>
<div class="w-100"></div>
<div id="messages"></div>
</div>
<br/>
<div class="row" style="background-color: #eee">
<h5>Image Original:</h5>
<div class="w-100"></div>
<div id="image"></div>
</div>
<br/>
<div class="row" style="background-color: #eee">
<h5>Image MegaDrive:</h5>
<div class="w-100"></div>
<div id="image_md"></div>
</div>
<br/>
<div class="row" style="background-color: #eee">
<h5>Color Table:</h5>
<div class="w-100"></div>
<table class="table table-bordered table-fixed" id="palette_table"></table>
</div>
<br/>
<div class="row" style="background-color: #eee">
<h5>Palette:</h5>
<div class="w-100"></div>
<div id="palette"></div>
</div>
<br/>
<div class="row" style="background-color: #eee">
<h5>TileSet:</h5>
<div class="w-100"></div>
<div id="tile_set" style="padding-left: 16px"></div>
</div>
<br/>
<div class="row" style="background-color: #eee">
<h5>Tiles:</h5>
<div class="w-100"></div>
<div id="tiles_table" style="padding-left: 16px"></div>
</div>
<br/>
<div class="row" style="background-color: #eee">
<h5>Output:</h5>
<div class="w-100"></div>
<pre id="output"></pre>
</div>
</div>
<script>
Init();
</script>
</body>
</html>