FAQ
Rectangle is a struct, so you can just use it. You can also use existing
implementations from the color package for Model and Color. E.g. RGBAModel
and RGBA.
On Wednesday, March 19, 2014 2:48:15 PM UTC-4, Carlo Tambuatco wrote:

I just want a solution to the following exercise on the tour.golang.orgwebsite,
exercise #62.

http://tour.golang.org/#62

The exercise is to implement the image interface:

type Image interface {
// ColorModel returns the Image's color model.
ColorModel() color <http://golang.org/pkg/image/color/>.Model <http://golang.org/pkg/image/color/#Model>
// Bounds returns the domain for which At can return non-zero color.
// The bounds do not necessarily contain the point (0, 0).
Bounds() Rectangle <http://golang.org/pkg/image/#Rectangle>
// At returns the color of the pixel at (x, y).
// At(Bounds().Min.X, Bounds().Min.Y) returns the upper-left pixel of the grid.
// At(Bounds().Max.X-1, Bounds().Max.Y-1) returns the lower-right one.
At(x, y int <http://golang.org/pkg/builtin/#int>) color <http://golang.org/pkg/image/color/>.Color <http://golang.org/pkg/image/color/#Color>
}

I'm just learning Go, and I've worked through every exercise except this
one, because
of the different interfaces involved such as Color, Rectangle, etc, I'm
having trouble
with whether or not I should implement every interface involved because
Color,
Rectangle, and color.Model etc are interfaces themselves...

provide one
possible solution so I can study it?
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.

## Related Discussions

 view thread | post posts ‹ prev | 2 of 5 | next ›
Discussion Overview
 group golang-nuts categories go posted Mar 19, '14 at 6:48p active Mar 19, '14 at 8:31p posts 5 users 4 website golang.org

### 4 users in discussion

Content

People

Support

Translate

site design / logo © 2021 Grokbase