package rotate import ( "image" "math" ) func Rotate(img image.Image, angle float64) image.Image { newImg := image.NewRGBA(img.Bounds()) w, h := img.Bounds().Dx(), img.Bounds().Dy() hh, hw := float64(h/2), float64(w/2) for y := 0; y < w; y++ { for x := 0; x < h; x++ { newImg.Set( int(hh-math.Cos(angle)), int(hw-math.Sin(angle)), img.At(x, y), ) } } return newImg }