25 lines
507 B
Go
25 lines
507 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"image/color"
|
||
|
)
|
||
|
|
||
|
func getColor(c color.Color, width, height int) [][][4]uint32 {
|
||
|
var pixelmatrix [][][4]uint32
|
||
|
|
||
|
for x := 0; x < width; x++ {
|
||
|
var xRow [][4]uint32
|
||
|
for y := 0; y < height; y++ {
|
||
|
var pixel [4]uint32
|
||
|
pixel[0], pixel[1], pixel[2], pixel[3] = c.RGBA()
|
||
|
pixel[0] = pixel[0] >>8
|
||
|
pixel[1] = pixel[1] >>8
|
||
|
pixel[2] = pixel[2] >>8
|
||
|
pixel[3] = pixel[3] >>8
|
||
|
xRow = append(xRow, pixel)
|
||
|
}
|
||
|
pixelmatrix = append(pixelmatrix, xRow)
|
||
|
}
|
||
|
return pixelmatrix
|
||
|
}
|