Skip to content

Commit

Permalink
add polyline to drawing example
Browse files Browse the repository at this point in the history
  • Loading branch information
csd0117 committed Mar 4, 2016
1 parent 668dc1b commit a4491e9
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions examples/drawing/drawing.go
Expand Up @@ -6,6 +6,7 @@ package main

import (
"log"
"math"
)

import (
Expand Down Expand Up @@ -88,6 +89,16 @@ func (mw *MyMainWindow) drawStuff(canvas *walk.Canvas, updateBounds walk.Rectang
return err
}

points := make([]walk.Point, 10)
dx := bounds.Width / (len(points) - 1)
for i := range points {
points[i].X = i * dx
points[i].Y = int(float64(bounds.Height) / math.Pow(float64(bounds.Width/2), 2) * math.Pow(float64(i*dx-bounds.Width/2), 2))
}
if err := canvas.DrawPolyline(linesPen, points); err != nil {
return err
}

bmpSize := bmp.Size()
if err := canvas.DrawImage(bmp, walk.Point{(bounds.Width - bmpSize.Width) / 2, (bounds.Height - bmpSize.Height) / 2}); err != nil {
return err
Expand Down

0 comments on commit a4491e9

Please sign in to comment.