func (E *Imp) Push(c col.Colour) { // B := make([]byte, zl()) a := 0 copy(B[a:a+8], E.origin.Encode()) a += 8 for d := D0; d < NDirs; d++ { copy(B[a:a+8], E.vec[d].Encode()) a += 8 } copy(B[a:a+97], col.Encode(c)) stack = append(stack, B) }
func (f *Imp) Encode() []byte { // B := make([]byte, f.Codelen()) a := uint(0) B[a] = byte(f.sort) a++ copy(B[a:a+3], col.Encode(f.colour)) a += 3 var n uint if f.sort < Text { n = uint(len(f.x)) } else { n = uint(len(f.tx)) } copy(B[a:a+clz], Encode(n)) a += clz if f.sort < Text { for i := uint(0); i < n; i++ { copy(B[a:a+clz], Encode(f.x[i])) a += clz copy(B[a:a+clz], Encode(f.y[i])) a += clz } } else { // Text, Image copy(B[a:a+clz], Encode(f.x[0])) a += clz copy(B[a:a+clz], Encode(f.y[0])) a += clz if f.sort == Image { copy(B[a:a+clz], Encode(f.x[1])) a += clz copy(B[a:a+clz], Encode(f.y[1])) a += clz } copy(B[a:a+n], []byte(f.tx)) a += n } B[a] = 0 if f.filled { B[a]++ } if f.marked { B[a] += 2 } return B }