And migrated the examples back; also fixed a spot I missed.
This commit is contained in:
parent
2c275b76ae
commit
dd9db1c145
2
draw.go
2
draw.go
|
@ -190,7 +190,7 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO document
|
// TODO document
|
||||||
const DefaultMiterLimit = 10.0
|
const DrawDefaultMiterLimit = 10.0
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
type DrawBrush struct {
|
type DrawBrush struct {
|
||||||
|
|
|
@ -29,8 +29,8 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
// helper to quickly set a brush color
|
// helper to quickly set a brush color
|
||||||
func mkSolidBrush(color uint32, alpha float64) *ui.Brush {
|
func mkSolidBrush(color uint32, alpha float64) *ui.DrawBrush {
|
||||||
brush := new(ui.Brush)
|
brush := new(ui.DrawBrush)
|
||||||
brush.Type = ui.DrawBrushTypeSolid
|
brush.Type = ui.DrawBrushTypeSolid
|
||||||
component := uint8((color >> 16) & 0xFF)
|
component := uint8((color >> 16) & 0xFF)
|
||||||
brush.R = float64(component) / 255
|
brush.R = float64(component) / 255
|
||||||
|
@ -64,9 +64,9 @@ func pointLocations(width, height float64) (xs, ys [10]float64) {
|
||||||
return xs, ys
|
return xs, ys
|
||||||
}
|
}
|
||||||
|
|
||||||
func constructGraph(width, height float64, extend bool) *ui.Path {
|
func constructGraph(width, height float64, extend bool) *ui.DrawPath {
|
||||||
xs, ys := pointLocations(width, height)
|
xs, ys := pointLocations(width, height)
|
||||||
path := ui.NewPath(ui.DrawFillModeWinding)
|
path := ui.DrawNewPath(ui.DrawFillModeWinding)
|
||||||
|
|
||||||
path.NewFigure(xs[0], ys[0])
|
path.NewFigure(xs[0], ys[0])
|
||||||
for i := 1; i < 10; i++ {
|
for i := 1; i < 10; i++ {
|
||||||
|
@ -93,7 +93,7 @@ type areaHandler struct{}
|
||||||
func (areaHandler) Draw(a *ui.Area, p *ui.AreaDrawParams) {
|
func (areaHandler) Draw(a *ui.Area, p *ui.AreaDrawParams) {
|
||||||
// fill the area with white
|
// fill the area with white
|
||||||
brush := mkSolidBrush(colorWhite, 1.0)
|
brush := mkSolidBrush(colorWhite, 1.0)
|
||||||
path := ui.NewPath(ui.DrawFillModeWinding)
|
path := ui.DrawNewPath(ui.DrawFillModeWinding)
|
||||||
path.AddRectangle(0, 0, p.AreaWidth, p.AreaHeight)
|
path.AddRectangle(0, 0, p.AreaWidth, p.AreaHeight)
|
||||||
path.End()
|
path.End()
|
||||||
p.Context.Fill(path, brush)
|
p.Context.Fill(path, brush)
|
||||||
|
@ -101,16 +101,16 @@ func (areaHandler) Draw(a *ui.Area, p *ui.AreaDrawParams) {
|
||||||
|
|
||||||
graphWidth, graphHeight := graphSize(p.AreaWidth, p.AreaHeight)
|
graphWidth, graphHeight := graphSize(p.AreaWidth, p.AreaHeight)
|
||||||
|
|
||||||
sp := &ui.StrokeParams{
|
sp := &ui.DrawStrokeParams{
|
||||||
Cap: ui.FlatCap,
|
Cap: ui.DrawLineCapFlat,
|
||||||
Join: ui.MiterJoin,
|
Join: ui.DrawLineJoinMiter,
|
||||||
Thickness: 2,
|
Thickness: 2,
|
||||||
MiterLimit: ui.DefaultMiterLimit,
|
MiterLimit: ui.DrawDefaultMiterLimit,
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw the axes
|
// draw the axes
|
||||||
brush = mkSolidBrush(colorBlack, 1.0)
|
brush = mkSolidBrush(colorBlack, 1.0)
|
||||||
path = ui.NewPath(ui.DrawFillModeWinding)
|
path = ui.DrawNewPath(ui.DrawFillModeWinding)
|
||||||
path.NewFigure(xoffLeft, yoffTop)
|
path.NewFigure(xoffLeft, yoffTop)
|
||||||
path.LineTo(xoffLeft, yoffTop + graphHeight)
|
path.LineTo(xoffLeft, yoffTop + graphHeight)
|
||||||
path.LineTo(xoffLeft + graphWidth, yoffTop + graphHeight)
|
path.LineTo(xoffLeft + graphWidth, yoffTop + graphHeight)
|
||||||
|
@ -119,7 +119,7 @@ func (areaHandler) Draw(a *ui.Area, p *ui.AreaDrawParams) {
|
||||||
path.Free()
|
path.Free()
|
||||||
|
|
||||||
// now transform the coordinate space so (0, 0) is the top-left corner of the graph
|
// now transform the coordinate space so (0, 0) is the top-left corner of the graph
|
||||||
m := ui.NewMatrix()
|
m := ui.DrawNewMatrix()
|
||||||
m.Translate(xoffLeft, yoffTop)
|
m.Translate(xoffLeft, yoffTop)
|
||||||
p.Context.Transform(m)
|
p.Context.Transform(m)
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ func (areaHandler) Draw(a *ui.Area, p *ui.AreaDrawParams) {
|
||||||
// now draw the point being hovered over
|
// now draw the point being hovered over
|
||||||
if currentPoint != -1 {
|
if currentPoint != -1 {
|
||||||
xs, ys := pointLocations(graphWidth, graphHeight)
|
xs, ys := pointLocations(graphWidth, graphHeight)
|
||||||
path = ui.NewPath(ui.DrawFillModeWinding)
|
path = ui.DrawNewPath(ui.DrawFillModeWinding)
|
||||||
path.NewFigureWithArc(
|
path.NewFigureWithArc(
|
||||||
xs[currentPoint], ys[currentPoint],
|
xs[currentPoint], ys[currentPoint],
|
||||||
pointRadius,
|
pointRadius,
|
Loading…
Reference in New Issue