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:
parent
867a9e5a49
commit
19f15f34d1
86
draw.go
86
draw.go
|
@ -37,13 +37,14 @@ import "C"
|
||||||
// parameter, but some implementations prevent it.)
|
// parameter, but some implementations prevent it.)
|
||||||
// TODO talk about fill modes
|
// TODO talk about fill modes
|
||||||
type DrawPath struct {
|
type DrawPath struct {
|
||||||
p *C.uiDrawPath
|
p *C.uiDrawPath
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
//
|
//
|
||||||
// TODO disclaimer
|
// TODO disclaimer
|
||||||
type DrawFillMode uint
|
type DrawFillMode uint
|
||||||
|
|
||||||
const (
|
const (
|
||||||
DrawFillModeWinding DrawFillMode = iota
|
DrawFillModeWinding DrawFillMode = iota
|
||||||
DrawFillModeAlternate
|
DrawFillModeAlternate
|
||||||
|
@ -62,7 +63,7 @@ func DrawNewPath(fillMode DrawFillMode) *DrawPath {
|
||||||
panic("invalid fill mode passed to ui.NewPath()")
|
panic("invalid fill mode passed to ui.NewPath()")
|
||||||
}
|
}
|
||||||
return &DrawPath{
|
return &DrawPath{
|
||||||
p: C.uiDrawNewPath(fm),
|
p: C.uiDrawNewPath(fm),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,18 +155,19 @@ func (p *DrawPath) End() {
|
||||||
// At present the only DrawContexts are surfaces associated with
|
// At present the only DrawContexts are surfaces associated with
|
||||||
// Areas and are provided by package ui; see AreaDrawParams.
|
// Areas and are provided by package ui; see AreaDrawParams.
|
||||||
type DrawContext struct {
|
type DrawContext struct {
|
||||||
c *C.uiDrawContext
|
c *C.uiDrawContext
|
||||||
}
|
}
|
||||||
|
|
||||||
// DrawBrushType defines the various types of brushes.
|
// DrawBrushType defines the various types of brushes.
|
||||||
//
|
//
|
||||||
// TODO disclaimer
|
// TODO disclaimer
|
||||||
type DrawBrushType int
|
type DrawBrushType int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
DrawBrushTypeSolid DrawBrushType = iota
|
DrawBrushTypeSolid DrawBrushType = iota
|
||||||
DrawBrushTypeLinearGradient
|
DrawBrushTypeLinearGradient
|
||||||
DrawBrushTypeRadialGradient
|
DrawBrushTypeRadialGradient
|
||||||
DrawBrushTypeImage // presently unimplemented
|
DrawBrushTypeImage // presently unimplemented
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
@ -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
|
||||||
|
@ -194,32 +198,32 @@ const DrawDefaultMiterLimit = 10.0
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
type DrawBrush struct {
|
type DrawBrush struct {
|
||||||
Type DrawBrushType
|
Type DrawBrushType
|
||||||
|
|
||||||
// If Type is Solid.
|
// If Type is Solid.
|
||||||
// TODO
|
// TODO
|
||||||
R float64
|
R float64
|
||||||
G float64
|
G float64
|
||||||
B float64
|
B float64
|
||||||
A float64
|
A float64
|
||||||
|
|
||||||
// If Type is LinearGradient or RadialGradient.
|
// If Type is LinearGradient or RadialGradient.
|
||||||
// TODO
|
// TODO
|
||||||
X0 float64 // start point for both
|
X0 float64 // start point for both
|
||||||
Y0 float64
|
Y0 float64
|
||||||
X1 float64 // linear: end point; radial: circle center
|
X1 float64 // linear: end point; radial: circle center
|
||||||
Y1 float64
|
Y1 float64
|
||||||
OuterRadius float64 // for radial gradients only
|
OuterRadius float64 // for radial gradients only
|
||||||
Stops []DrawGradientStop
|
Stops []DrawGradientStop
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
type DrawGradientStop struct {
|
type DrawGradientStop struct {
|
||||||
Pos float64 // between 0 and 1 inclusive
|
Pos float64 // between 0 and 1 inclusive
|
||||||
R float64
|
R float64
|
||||||
G float64
|
G float64
|
||||||
B float64
|
B float64
|
||||||
A float64
|
A float64
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *DrawBrush) toLibui() *C.uiDrawBrush {
|
func (b *DrawBrush) toLibui() *C.uiDrawBrush {
|
||||||
|
@ -264,12 +268,12 @@ func freeBrush(cb *C.uiDrawBrush) {
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
type DrawStrokeParams struct {
|
type DrawStrokeParams struct {
|
||||||
Cap DrawLineCap
|
Cap DrawLineCap
|
||||||
Join DrawLineJoin
|
Join DrawLineJoin
|
||||||
Thickness float64
|
Thickness float64
|
||||||
MiterLimit float64
|
MiterLimit float64
|
||||||
Dashes []float64
|
Dashes []float64
|
||||||
DashPhase float64
|
DashPhase float64
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sp *DrawStrokeParams) toLibui() *C.uiDrawStrokeParams {
|
func (sp *DrawStrokeParams) toLibui() *C.uiDrawStrokeParams {
|
||||||
|
@ -316,12 +320,12 @@ func (c *DrawContext) Fill(p *DrawPath, b *DrawBrush) {
|
||||||
// TODO
|
// TODO
|
||||||
// TODO should the methods of these return self for chaining?
|
// TODO should the methods of these return self for chaining?
|
||||||
type DrawMatrix struct {
|
type DrawMatrix struct {
|
||||||
M11 float64
|
M11 float64
|
||||||
M12 float64
|
M12 float64
|
||||||
M21 float64
|
M21 float64
|
||||||
M22 float64
|
M22 float64
|
||||||
M31 float64
|
M31 float64
|
||||||
M32 float64
|
M32 float64
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO identity matrix
|
// TODO identity matrix
|
||||||
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue