/
sample-encode.go
85 lines (77 loc) · 1.46 KB
/
sample-encode.go
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
package main
import (
"os"
"github.com/ARolek/ase"
)
var testColors = []ase.Color{
ase.Color{
Name: "RGB",
Model: "RGB",
Values: []float32{1, 1, 1},
Type: "Normal",
},
ase.Color{
Name: "Grayscale",
Model: "CMYK",
Values: []float32{0, 0, 0, 0.47},
Type: "Spot",
},
ase.Color{
Name: "cmyk",
Model: "CMYK",
Values: []float32{0, 1, 0, 0},
Type: "Spot",
},
ase.Color{
Name: "LAB",
Model: "RGB",
Values: []float32{0, 0.6063648, 0.524658},
Type: "Global",
},
ase.Color{
Name: "PANTONE P 1-8 C",
Model: "LAB",
Values: []float32{0.9137255, -5, 94},
Type: "Spot",
},
}
var testGroup = ase.Group{
Name: "A Color Group",
Colors: []ase.Color{
ase.Color{
Name: "Red",
Model: "RGB",
Values: []float32{1, 0, 0},
Type: "Global",
},
ase.Color{
Name: "Green",
Model: "RGB",
Values: []float32{0, 1, 0},
Type: "Global",
},
ase.Color{
Name: "Blue",
Model: "RGB",
Values: []float32{0, 0, 1},
Type: "Global",
},
},
}
func main() {
// Initialize a sample ASE
sampleAse := ase.ASE{}
sampleAse.Colors = testColors
sampleAse.Groups = append(sampleAse.Groups, testGroup)
// Create the file to write the encoded ASE
f, err := os.Create("./encoded.ase")
if err != nil {
panic(err)
}
// It’s idiomatic to defer a Close immediately after opening a file.
defer f.Close()
// encode our ASE file
if err = ase.Encode(sampleAse, f); err != nil {
panic(err)
}
}