Image Source: https://pixabay.com/photos/pizza-cheese-crust-mozzarella-food-3203417/

When you begin to learn the trending Go lang you may have encounter with the Slice exercise which will ask you to draw an image based on slices. Here is how I implemented it.

package mainimport (
"golang.org/x/tour/pic"
)
func Pic(dx, dy int) [][]uint8 {
pixel := make([][]uint8, dy)
data := make([]uint8, dx)
for i := range pixel {
for j := range data {
data[j] = uint8((i+j)/2)
}
pixel[i] = data
}
return pixel
}
func main() {
pic.Show(Pic)
}

--

--