An interference pattern (Implemented in Go)

Check out this picture:

_config.yml

I love it. Why? It reminds me of an inteference pattern, i.e. diffraction drawings.

It was made using Go. The code is relatively simple:

Substitute the below in the above code editor:

package main

import "golang.org/x/tour/pic"

func Pic(dx, dy int) [][]uint8 {
	final := make([][]uint8, dy) // make an array of arrays
	
	for x := 0; x < dx; x++ {				 
		for y := 0; y < dy; y++ {		
			final[y] = make([]uint8, dx)
			
			for x := range final[y] {
        		final[y][x] = uint8(imageFunction(x, y))
			}			
		}
	}
	
	return final
}

func imageFunction(x,y int) int {
   // return x + y
   return x*x + y*y 
}

func main() {
	pic.Show(Pic)
}
Written on December 24, 2024