pureimage
pureimage copied to clipboard
Image.map is confusing
So it seems like Image.map
takes the size of the old image, but a new (Int, Int) => A
function which it uses (ignoring the old raster's function).
This is a bit odd, right? I would imagine the map method as looking something more like this:
trait Image[A] { self =>
...
def map[B](f: A => B): Image[B] = new Image[B] {
def width = self.width
def height = self.height
def apply(x: Int, y: Int): B = f(self(x, y))
}
}
I feel like the current map maybe belongs in a companion object? What is the advantage over just doing this:
object Image {
def apply[A](w: Int, h: Int)(f: (Int, Int) => A): Image[A] = ...
}
What do you think?
You're right. I should get rid of it.