-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaseprite.ksy
850 lines (838 loc) · 26.8 KB
/
aseprite.ksy
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
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
meta:
id: aseprite
endian: le
file-extension:
- aseprite
- ase
seq:
- id: header
type: header
- id: frames
type: frame
repeat: expr
repeat-expr: header.num_frames
types:
header:
seq:
- id: file_size
type: u4
doc: |
File size
- id: magic
contents: [0xE0, 0xA5]
doc: |
Magic Number (0xA5E0)
- id: num_frames
type: u2
doc: |
The number of frames in the animation
- id: width
type: u2
doc: |
The width of the sprite, in pixels
- id: height
type: u2
doc: |
The height of the sprite, in pixels
- id: pixel_format
type: u2
enum: pixel_format_enum
doc: |
The color depth of the sprite:
- "rgba" -> 32bpp, full RGB with alpha (8bpc)
- "grayscale" -> 16bpp, value and alpha (8bpc)
- "indexed" -> 8bpp indexed
- id: flags
type: flags_bitset
doc: |
Various boolean flags about the ASE file
- id: speed
type: u2
doc: |
DEPRECATED!
The speed of the animation (the number of milliseconds
between frames).
You should use the frame duration field from each frame
header from now on instead of using this field.
- type: u8
- id: transparent_index
type: u1
doc: |
Palette entry (index) which represents the transparent
color in all non-background layers (only for
pixel_format=indexed (8bpp) sprites).
- type: b24
- id: num_colors
type: u2
doc: |
Number of colors (0 means 256 for old sprites).
- id: pixel_width
type: u1
doc: |
Per-pixel width (pixel ratio is pixel_width/pixel_height).
If this or pixel_height field is zero, pixel ratio is 1:1.
- id: pixel_height
type: u1
doc: |
Per-pixel height (pixel ratio is pixel_width/pixel_height).
If this or pixel_width field is zero, pixel ratio is 1:1.
- id: grid_x
type: s2
doc: |
The X position of the grid
- id: grid_y
type: s2
doc: |
The Y position of the grid
- id: grid_width
type: u2
doc: |
Grid width (zero if there is no grid, grid size
is 16x16 on Aseprite by default)
- id: grid_height
type: u2
doc: |
Grid height (zero if there is no grid, grid size
is 16x16 on Aseprite by default)
- size: 84
enums:
pixel_format_enum:
32: rgba
16: grayscale
8: indexed
types:
flags_bitset:
seq:
- type: b7
- id: valid_opacity
type: b1
doc: Layer opacity has a valid value
- type: b24
frame:
seq:
- id: header
type: header
- id: chunks
type: chunk
repeat: expr
repeat-expr: |
header.num_chunks == 0 ? header.num_chunks_old : header.num_chunks
types:
header:
seq:
- id: frame_bytes
type: u4
doc: |
Bytes in this frame
- id: magic
contents: [0xFA, 0xF1]
doc: |
Magic number (always 0xF1FA)
- id: num_chunks_old
type: u2
doc: |
Old field which specifies the number of "chunks"
in this frame. If this value is 0xFFFF, we might
have more chunks to read in this frame.
- id: duration
type: u2
doc: |
Frame duration, in milliseconds.
If this value is 0, replace it with the `speed` value
from the main ASE header. If you are writing this ASE
file back out, be sure to set this field to the `speed` value
instead of keeping it as 0, since the `speed` field
is deprecated.
- size: 2
- id: num_chunks
type: u4
doc: |
New field which specifies the number of "chunks"
in this frame (if this is 0, use the num_chunks_old
field).
chunk:
seq:
- id: size
type: u4
doc: |
The size, in bytes, of the chunk (including
.size and .type fields).
- id: type
type: u2
enum: chunk_type_enum
doc: |
The chunk type
- id: data
type:
switch-on: type
cases:
'chunk_type_enum::palette_old_1': palette_old_chunk
'chunk_type_enum::palette_old_2': palette_old_chunk
'chunk_type_enum::layer': layer_chunk
'chunk_type_enum::cel': cel_chunk
'chunk_type_enum::cel_extra': cel_extra_chunk
'chunk_type_enum::color_profile': color_profile_chunk
'chunk_type_enum::mask': mask_chunk
'chunk_type_enum::tags': tags_chunk
'chunk_type_enum::palette': palette_chunk
'chunk_type_enum::userdata': userdata_chunk
'chunk_type_enum::slice': slice_chunk
_: dummy_chunk
enums:
chunk_type_enum:
0x0004: palette_old_1
0x0011: palette_old_2
0x2004: layer
0x2005: cel
0x2006: cel_extra
0x2007: color_profile
0x2016: mask
0x2017: path
0x2018: tags
0x2019: palette
0x2020: userdata
0x2022: slice
types:
dummy_chunk:
seq:
- size: _parent.size - 6
palette_chunk:
seq:
- id: num_entries
type: u4
doc: |
New palette size (total number of entries)
- id: first_index
type: u4
doc: |
First color index to change
- id: last_index
type: u4
doc: |
Last color index to change
- size: 8
- id: entries
type: entry
repeat: expr
repeat-expr: num_entries
doc: |
The palette entries
types:
entry:
seq:
- id: flags
type: flag_bitset
doc: |
Entry flags
- id: r
type: u1
doc: |
Red channel (0-255)
- id: g
type: u1
doc: |
Green channel (0-255)
- id: b
type: u1
doc: |
Blue channel (0-255)
- id: a
type: u1
doc: |
Alpha channel (0-255)
- id: name_length
type: u2
if: flags.has_name == true
- id: name
type: str
size: name_length
encoding: utf-8
if: flags.has_name == true
doc: |
The name of the palette entry
types:
flag_bitset:
seq:
- type: b7
- id: has_name
type: b1
- type: b8
color_profile_chunk:
seq:
- id: type
type: u2
enum: type_enum
doc: |
The color profile type
- id: flags
type: flags
- id: fixed_gamma
type: fixed_float
doc: |
Fixed gamma (1.0 = linear)
Note: The gamma in sRGB is 2.2 in overall but it doesn't use
this fixed gamma, because sRGB uses different gamma sections
(linear and non-linear). If sRGB is specified with a fixed
gamma = 1.0, it means that this is Linear sRGB.
- size: 8
- id: icc_length
type: u4
if: type == type_enum::embedded_icc
doc: |
ICC profile data length
- id: icc_data
size: icc_length
if: type == type_enum::embedded_icc
doc: |
ICC profile data. More info: http://www.color.org/ICC1V42.pdf
enums:
type_enum:
0: none
1: srgb
2: embedded_icc
types:
flags:
seq:
- type: b7
- id: fixed_gamma
type: b1
doc: |
Use special fixed gamma
- type: b8
fixed_float:
seq:
- id: int
type: u2
doc: |
The integer part of the fixed float
- id: dec
type: u2
doc: |
The decimal part of the fixed float
palette_old_chunk:
seq:
- id: num_packets
type: u2
doc: |
Number of packets
- id: packets
type: packet
repeat: expr
repeat-expr: num_packets
doc: |
The chunk's packets
types:
packet:
seq:
- id: skip
type: u1
doc: |
The number of palette entries to skip from the last
packet (start from 0)
- id: num_colors
type: u1
doc: |
The number of colors in the packet (0 means 256)
- id: colors
type: color
repeat: expr
repeat-expr: |
num_colors == 0 ? 256 : num_colors
doc: |
The packet's colors
types:
color:
seq:
- id: r
type: u1
doc: |
Red channel (0-255)
- id: g
type: u1
doc: |
Green channel (0-255)
- id: b
type: u1
doc: |
Blue channel (0-255)
layer_chunk:
seq:
- id: flags
type: flag_bitset
doc: |
Layer flags
- id: type
type: u2
enum: type_enum
doc: |
Layer type
- id: child_level
type: u2
doc: |
Layer child level
The child level is used to show the relationship of this
layer with the last one read, for example:
Layer name and hierarchy Child Level
-----------------------------------------------
- Background 0
`- Layer1 1
- Foreground 0
|- My set1 1
| `- Layer2 2
`- Layer3 1
- id: layer_width
type: u2
doc: |
IGNORED. Default layer width in pixels.
- id: layer_height
type: u2
doc: |
IGNORED. Default layer height in pixels.
- id: blend_mode
type: u2
enum: blend_mode_enum
doc: |
The layer blend mode (always 0 for group layers)
- id: opacity
type: u1
doc: |
Layer opacity (0-255)
NOTE: Only valid if flags.visible==true.
- size: 3
- id: name_size
type: u2
- id: name
type: str
size: name_size
encoding: utf-8
doc: |
Layer name
enums:
type_enum:
0: image
1: group
blend_mode_enum:
0: normal
1: multiply
2: screen
3: overlay
4: darken
5: lighten
6: color_dodge
7: color_burn
8: hard_light
9: soft_light
10: difference
11: exclusion
12: hue
13: saturation
14: color
15: luminosity
16: addition
17: subtract
18: divide
types:
flag_bitset:
seq:
- type: b1
- id: reference
type: b1
doc: |
The layer is a reference layer
- id: collapsed
type: b1
doc: |
The layer group should be displayed collapsed
- id: prefer_linked
type: b1
doc: |
Prefer linked cels
- id: background
type: b1
doc: |
Layer is a background
- id: lock_movement
type: b1
doc: |
Lock any movement on the layer
- id: editable
type: b1
doc: |
Layer is editable
- id: visible
type: b1
doc: |
Layer is visible
- type: u1
cel_chunk:
seq:
- id: layer_index
type: u2
doc: |
Layer index
The layer index is a number to identify any layer in the
sprite, for example:
Layer name and hierarchy Layer index
-----------------------------------------------
- Background 0
`- Layer1 1
- Foreground 2
|- My set1 3
| `- Layer2 4
`- Layer3 5
- id: x
type: s2
doc: |
X position
- id: y
type: s2
doc: |
Y position
- id: opacity
type: u1
doc: |
Opacity level (0-255)
- id: type
type: u2
enum: cel_type_enum
doc: |
The format of the cel's contents
- size: 7
- id: raw_width
type: u2
if: type == cel_type_enum::raw
doc: |
The cel width in pixels
- id: raw_height
type: u2
if: type == cel_type_enum::raw
doc: |
The cel height in pixels
- id: pixels
size: _parent.size - 26
if: type == cel_type_enum::raw
doc: |
The cel's pixel data
NOTE: This is raw byte data because Kaitai cannot accurately
represent the variable types here. You will need to check
the color_profile layer to check which format these pixels
will be in:
- rgba == 4 bytes
- grayscale == 2 bytes
- indexed = 1 byte
Pixels are read row by row from top to bottom,
for each scanline read pixels from left to right.
- id: frame_link
type: u2
if: type == cel_type_enum::linked
doc: |
The frame position to link with
- id: width
type: u2
if: type == cel_type_enum::compressed
doc: |
The width in pixels
- id: height
type: u2
if: type == cel_type_enum::compressed
doc: |
The height in pixels
- id: pixels_compressed
if: type == cel_type_enum::compressed
size: _parent.size - 26
doc: |
The compressed pixel data. Must be inflated (Kaitai does not
support this out of the box).
NOTE: This is raw byte data because Kaitai cannot accurately
represent the variable types here. You will need to check
the color_profile layer to check which format these pixels
will be in:
- rgba == 4 bytes
- grayscale == 2 bytes
- indexed = 1 byte
Pixels are read row by row from top to bottom,
for each scanline read pixels from left to right.
enums:
cel_type_enum:
0: raw
1: linked
2: compressed
cel_extra_chunk:
seq:
- id: flags
type: flags_bitset
doc: |
Flags (set to zero)
- id: precise_x
type: fixed
doc: |
Precise X position
- id: precise_y
type: fixed
doc: |
Precise Y position
- id: width
type: fixed
doc: |
Width of the cel in the sprite (scaled in real-time)
- id: height
type: fixed
doc: |
Height of the cel in the sprite (scaled in real-time)
- size: 16
types:
flags_bitset:
seq:
- type: b7
- id: precise_bounds
type: b1
doc: |
Precise bounds are set
fixed:
seq:
- id: int
type: u2
doc: |
The integer part of the fixed float
- id: dec
type: u2
doc: |
The decimal part of the fixed float
slice_chunk:
seq:
- id: num_keys
type: u4
doc: |
Number of "slice keys"
- id: flags
type: flags_bitset
doc: |
Slice flags
- type: u4
- id: name_size
type: u2
- id: name
type: str
size: name_size
encoding: utf-8
doc: |
The slice's name
- id: keys
type: key
repeat: expr
repeat-expr: num_keys
doc: |
The slice's list of keys
types:
flags_bitset:
seq:
- type: b6
- id: has_pivot
type: b1
doc: |
Has pivot information
- id: patch9
type: b1
doc: |
It's a 9-patches slice
- type: b24
key:
seq:
- id: frame_no
type: u4
doc: |
Frame number (this slice is valid from thie frame to
the end of the animation)
- id: x
type: s4
doc: |
Slice X origin coordinate in the sprite
- id: y
type: s4
doc: |
Slice Y origin coordinate in the sprite
- id: width
type: u4
doc: |
Slice width (can be 0 if this slice is hidden
in the animation from the given frame)
- id: height
type: u4
doc: |
Slice height (can be 0 if this slice is hidden
in the animation from the given frame)
- id: center_x
type: s4
if: _parent.flags.patch9 == true
doc: |
Center X position (relative to slice bounds)
- id: center_y
type: s4
if: _parent.flags.patch9 == true
doc: |
Center Y position (relative to slice bounds)
- id: center_width
type: u4
if: _parent.flags.patch9 == true
doc: |
Center width
- id: center_height
type: u4
if: _parent.flags.patch9 == true
doc: |
Center height
- id: pivot_x
type: s4
if: _parent.flags.has_pivot == true
doc: |
Pivot X position (relative to the slice origin)
- id: pivot_y
type: s4
if: _parent.flags.has_pivot == true
doc: |
Pivot y position (relative to the slice origin)
tags_chunk:
seq:
- id: num_tags
type: u2
doc: |
The number of tags
- size: 8
- id: tags
type: tag
repeat: expr
repeat-expr: num_tags
doc: |
The sprite's list of tags
types:
tag:
seq:
- id: from
type: u2
doc: |
From frame
- id: to
type: u2
doc: |
To frame
- id: direction
type: u1
enum: direction_enum
doc: |
Loop animation direction
- size: 8
- id: color
type: color
doc: |
The tag's color
- type: u1
- id: name_size
type: u2
- id: name
type: str
size: name_size
encoding: utf-8
doc: |
The tag's name
enums:
direction_enum:
0: forward
1: reverse
2: ping_pong
types:
color:
seq:
- id: r
type: u1
doc: |
The red channel (0-255)
- id: g
type: u1
doc: |
The green channel (0-255)
- id: b
type: u1
doc: |
The blue channel (0-255)
userdata_chunk:
seq:
- id: flags
type: flags_bitset
doc: |
Flags for the userdata
- id: text_size
type: u2
if: flags.has_text == true
- id: text
type: str
size: text_size
encoding: utf-8
if: flags.has_text == true
doc: |
Userdata text
- id: r
type: u1
if: flags.has_color == true
doc: |
The red channel (0-255)
- id: g
type: u1
if: flags.has_color == true
doc: |
The green channel (0-255)
- id: b
type: u1
if: flags.has_color == true
doc: |
The blue channel (0-255)
- id: a
type: u1
if: flags.has_color == true
doc: |
The alpha channel (0-255)
types:
flags_bitset:
seq:
- type: b6
- id: has_color
type: b1
doc: |
Userdata has color information
- id: has_text
type: b1
doc: |
Userdata has textual information
- type: b24
mask_chunk:
seq:
- id: x
type: s2
doc: |
X position
- id: y
type: s2
doc: |
Y position
- id: width
type: u2
doc: |
Mask width
- id: height
type: u2
doc: |
Mask height
- size: 8
- id: name_size
type: u2
- id: name
type: str
size: name_size
encoding: utf-8
doc: |
Mask name
- id: bitmap
size: |
height * ( ( width + 7 ) / 8 )
doc: |
Each byte contains 8 pixels (the leftmost pixels
are packed into the high order bits)