aboutsummaryrefslogtreecommitdiff
path: root/tools/compile_assets/aseprite/README.md
blob: a43b1f1bf290595e38735c66cb6de134eff5ccfb (plain)
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
# Odin Aseprite
Handler for Aseprite's `.ase`/`.aseprite`, `.aseprite-extension` & extended `.gpl` files writen in Odin.   

* `.\`: Main un/marshaler for `.ase`
* `.\utils`: Creates Images, Animations & Sprite Sheets from Documents
* `.\raw`: un/marshals `.ase` exactly as given by the spec
* `.\gpl`: extended & normal .gpl   
* `.\extensions`: .aseprite-extension. WIP   
* `.\tests`: test files

## Examples
### aseprite
```odin
package main

import "core:fmt"
import ase "odin-aseprite"

main :: proc() {
    data := #load("geralt.aseprite")

    doc: ase.Document
    defer ase.destroy_doc(&doc)

    umerr := ase.unmarshal(data[:], &doc)
    if umerr != nil {
        fmt.println(umerr)
        return
    }

    buf: [dynamic]byte
    defer delete(buf)

    written, merr := ase.marshal(&buf, &doc)
    if merr != nil {
        fmt.println(merr)
        return
    }
}
```

### utils
```odin
package main

import "core:fmt"
import ase "odin-aseprite"
import "odin-aseprite/utils"

main :: proc() {
    data := #load("geralt.aseprite")

    doc: ase.Document
    defer ase.destroy_doc(&doc)

    umerr := ase.unmarshal(data[:], &doc)
    if umerr != nil {
        fmt.println(umerr)
        return
    }

    imgs, imgs_err := utils.get_all_images(&doc)
    defer utils.destroy(imgs)

    if imgs_err != nil {
        fmt.println(imgs_err)
        return
    }
}
```

### gpl
```odin
package main

import "core:fmt"
import "odin-aseprite/gpl"

main :: proc() {
    data := #load("geralt.gpl")

    palette, err := gpl.parse(data[:])
    if err != nil {
        fmt.println(err)
        return
    }
    defer destroy_gpl(&palette)

    buf, err2 := gpl.to_bytes(palette)
    if err2 != nil {
        fmt.println(err2)
        return
    } 
    defer delete(buf)
}
```


## Warnings
ICC Colour Profiles aren't supported. The raw data will be saved to doc.   

## Errors
Any errors please make an issue or DM them to me, `blob1807`, on the [Odin Discord](https://discord.com/invite/sVBPHEv).  
If you DM me please include the offending file/s.   
   
If you want to test your own files for errors. Add them to a new folder in `./tests` and run `odin test .` in the `./tests` directory.