gioui.org/ui@v0.0.0-20190926171558-ce74bc0cbaea/internal/ops/ops.go (about)

     1  // SPDX-License-Identifier: Unlicense OR MIT
     2  
     3  package ops
     4  
     5  import (
     6  	"encoding/binary"
     7  	"math"
     8  
     9  	"gioui.org/ui"
    10  	"gioui.org/ui/f32"
    11  	"gioui.org/ui/internal/opconst"
    12  )
    13  
    14  func DecodeTransformOp(d []byte) ui.TransformOp {
    15  	bo := binary.LittleEndian
    16  	if opconst.OpType(d[0]) != opconst.TypeTransform {
    17  		panic("invalid op")
    18  	}
    19  	return ui.TransformOp{}.Offset(f32.Point{
    20  		X: math.Float32frombits(bo.Uint32(d[1:])),
    21  		Y: math.Float32frombits(bo.Uint32(d[5:])),
    22  	})
    23  }