op: add package op for operations

Extract operation types from package ui into package op.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-09-30 15:41:15 +02:00
parent eba1b3a95f
commit 8cf35a1f97
27 changed files with 225 additions and 227 deletions
+3 -3
View File
@@ -6,17 +6,17 @@ import (
"encoding/binary"
"math"
"gioui.org/ui"
"gioui.org/f32"
"gioui.org/internal/opconst"
"gioui.org/op"
)
func DecodeTransformOp(d []byte) ui.TransformOp {
func DecodeTransformOp(d []byte) op.TransformOp {
bo := binary.LittleEndian
if opconst.OpType(d[0]) != opconst.TypeTransform {
panic("invalid op")
}
return ui.TransformOp{}.Offset(f32.Point{
return op.TransformOp{}.Offset(f32.Point{
X: math.Float32frombits(bo.Uint32(d[1:])),
Y: math.Float32frombits(bo.Uint32(d[5:])),
})