From 48074bb2cc25fd000455e3e550958868bc93aaf4 Mon Sep 17 00:00:00 2001 From: potassium Date: Tue, 12 Dec 2023 10:09:04 +0300 Subject: [PATCH] less confusing names --- resize.go => scale.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) rename resize.go => scale.go (63%) diff --git a/resize.go b/scale.go similarity index 63% rename from resize.go rename to scale.go index f51e1f0..6b318bc 100644 --- a/resize.go +++ b/scale.go @@ -5,18 +5,18 @@ import ( "image/color" ) -type resized struct { +type rescaled struct { src image.Image scale int } // ColorModel implements image.Image interface -func (r resized) ColorModel() color.Model { +func (r rescaled) ColorModel() color.Model { return r.src.ColorModel() } // Bounds implements image.Image interface -func (r resized) Bounds() image.Rectangle { +func (r rescaled) Bounds() image.Rectangle { b := r.src.Bounds() return image.Rectangle{ Min: image.Point{ @@ -31,16 +31,16 @@ func (r resized) Bounds() image.Rectangle { } // At implements image.Image interface -func (r resized) At(x, y int) color.Color { +func (r rescaled) At(x, y int) color.Color { return r.src.At(x/r.scale, y/r.scale) } -// Resize resizes image to a given scale -// and then returns image. +// Scale scales image.Image to a given scale +// and then returns image.Image. // For now it will work only with positive integers. -func Resize(img image.Image, scale int) image.Image { +func Scale(img image.Image, scale int) image.Image { if scale < 1 { scale = 1 } - return resized{img, scale} + return rescaled{img, scale} }