We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 8055736 + cb53882 commit 5142b90Copy full SHA for 5142b90
src/main/scala/introprog/Image.scala
@@ -25,6 +25,13 @@ class Image (val underlying: java.awt.image.BufferedImage):
25
for x <- 0 until width; y <- 0 until height do
26
update(x, y, f(x, y))
27
28
+ /** Set color of pixels by passing `f(x, y)` and return self*/
29
+ def updated(f: (Int, Int) => Color): Image =
30
+ for x <- 0 until width; y <- 0 until height do
31
+ update(x, y, f(x, y))
32
+ this
33
+
34
35
/** Extract and return image pixels.*/
36
def toMatrix: Array[Array[Color]] =
37
val xs: Array[Array[Color]] = Array.ofDim(width, height)
0 commit comments