ggfx/shapes.go

17 lines
410 B
Go

package ggfx
import "math"
import "image"
func Circle (resolution int, radius float64, center image.Point) []image.Point {
points := make([]image.Point, resolution)
for index := range points {
angle := float64(index) * ((2 * math.Pi) / float64(len(points)))
point := image.Pt (
int(math.Cos(angle) * radius),
int(math.Sin(angle) * radius))
points[index] = point.Add(center)
}
return points
}