full prototype
This commit is contained in:
parent
e3443d57f5
commit
3bd611feab
27
apgbpal.go
27
apgbpal.go
@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"log"
|
||||
"os"
|
||||
)
|
||||
|
||||
type RGBA struct {
|
||||
@ -106,7 +107,11 @@ func (o OBJPal) Bytes(indexchar byte) [18]byte {
|
||||
return ret
|
||||
}
|
||||
|
||||
func MustParseOBJPal {
|
||||
func MustParseOBJPal(strs []string) OBJPal {
|
||||
if len(strs) == 4 {
|
||||
log.Info("Discarding index 0 of OBJ pal")
|
||||
strs = strs[1:]
|
||||
}
|
||||
if len(strs) != 3 {
|
||||
log.Fatalf("MustParseObjPal requires length 3, got %d", len(strs))
|
||||
}
|
||||
@ -140,3 +145,23 @@ func (a APGBPal) Bytes() [56]byte {
|
||||
return ret
|
||||
}
|
||||
|
||||
func main() {
|
||||
f, err := os.OpenFile("test.pal", O_WRONLY|O_CREATE|O_EXCL, 0644)
|
||||
if err != nil {
|
||||
log.Fatalf("can't create test.pal: %v", err)
|
||||
}
|
||||
aUpPal := APGBPal {
|
||||
BG: MustParseBGPal([]string{"ffffff", "ff8484", "943a3a", "000000"}),
|
||||
OBJ0: MustParseObjPal([]string{"7bff31", "008400", "000000"}),
|
||||
OBJ1: MustParseObjPal([]string{"63a5ff", "0000ff", "000000"}),
|
||||
}
|
||||
n, err := f.Write(aUpPal.Bytes()[:])
|
||||
if err != nil {
|
||||
log.Fatalf("can't save test.pal: %v", err)
|
||||
}
|
||||
if n != 56 {
|
||||
log.Fatalf("unexpected write length: %d", n)
|
||||
}
|
||||
f.Close()
|
||||
os.Exit(0)
|
||||
}
|
Loading…
Reference in New Issue
Block a user