This commit is contained in:
2026-11-02 22:12:30 +03:00
parent e51ffde305
commit f5a51b92e7
9 changed files with 240 additions and 2 deletions
+23
View File
@@ -0,0 +1,23 @@
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
}