Added missing bindings for matrix

- .TransformPoint(...) has been proven to work on mac
- .TransformSize(...) should therefore work as well as it's basically the same
- vs code also ran go fmt so there's that
This commit is contained in:
Marvin Musold 2018-10-24 10:12:08 +02:00
parent 867a9e5a49
commit 19f15f34d1
1 changed files with 57 additions and 43 deletions

22
draw.go
View File

@ -44,6 +44,7 @@ type DrawPath struct {
// //
// TODO disclaimer // TODO disclaimer
type DrawFillMode uint type DrawFillMode uint
const ( const (
DrawFillModeWinding DrawFillMode = iota DrawFillModeWinding DrawFillMode = iota
DrawFillModeAlternate DrawFillModeAlternate
@ -161,6 +162,7 @@ type DrawContext struct {
// //
// TODO disclaimer // TODO disclaimer
type DrawBrushType int type DrawBrushType int
const ( const (
DrawBrushTypeSolid DrawBrushType = iota DrawBrushTypeSolid DrawBrushType = iota
DrawBrushTypeLinearGradient DrawBrushTypeLinearGradient
@ -173,6 +175,7 @@ const (
// TODO disclaimer // TODO disclaimer
// TODO rename these to put LineCap at the beginning? or just Cap? // TODO rename these to put LineCap at the beginning? or just Cap?
type DrawLineCap int type DrawLineCap int
const ( const (
DrawLineCapFlat DrawLineCap = iota DrawLineCapFlat DrawLineCap = iota
DrawLineCapRound DrawLineCapRound
@ -183,6 +186,7 @@ const (
// //
// TODO disclaimer // TODO disclaimer
type DrawLineJoin int type DrawLineJoin int
const ( const (
DrawLineJoinMiter DrawLineJoin = iota DrawLineJoinMiter DrawLineJoin = iota
DrawLineJoinRound DrawLineJoinRound
@ -421,14 +425,24 @@ func (m *DrawMatrix) Invert() bool {
return tobool(res) return tobool(res)
} }
// TODO unimplemented // TODO
//
// Transforms a point by this matrix
func (m *DrawMatrix) TransformPoint(x float64, y float64) (xout float64, yout float64) { func (m *DrawMatrix) TransformPoint(x float64, y float64) (xout float64, yout float64) {
panic("TODO") cm := m.toLibui()
cx, cy := C.double(x), C.double(y)
C.uiDrawMatrixTransformPoint(cm, &cx, &cy)
C.pkguiFreeMatrix(cm)
return float64(cx), float64(cy)
} }
// TODO unimplemented // TODO
func (m *DrawMatrix) TransformSize(x float64, y float64) (xout float64, yout float64) { func (m *DrawMatrix) TransformSize(x float64, y float64) (xout float64, yout float64) {
panic("TODO") cm := m.toLibui()
cx, cy := C.double(x), C.double(y)
C.uiDrawMatrixTransformSize(cm, &cx, &cy)
C.pkguiFreeMatrix(cm)
return float64(cx), float64(cy)
} }
// TODO // TODO