-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_img.go
48 lines (40 loc) · 850 Bytes
/
make_img.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package main
import (
"github.com/mweiden/basis/sorting"
"image"
"image/png"
"math/rand"
"os"
)
func make_img() {
//logn := uint(9)
//height := 1 << logn
height := 1500
colorInds := rand.Perm(height)
imgData := sorting.HeapSort(colorInds)
iters := len(imgData)
heightMult := 7
widthMult := 1
// Create an image
img := image.NewRGBA(image.Rect(0, 0, iters*widthMult, height*heightMult))
for i := 0; i < iters; i++ {
for j := 0; j < height; j++ {
for ii := 0; ii < widthMult; ii++ {
for jj := 0; jj < heightMult; jj++ {
img.Set(i*widthMult+ii, j*heightMult+jj, imgData[i][j])
}
}
}
}
// Save to out.png
f, _ := os.OpenFile("out.png", os.O_WRONLY|os.O_CREATE, 0600)
defer f.Close()
png.Encode(f, img)
last := -1
for _, ele := range colorInds {
if ele <= last {
os.Exit(1)
}
last = ele
}
}