示例#1
0
func NearestNeighbor(c config.Config) ColorStrategy {
	imageSize := 1 << uint(((c.ColorCubeBitSize + c.ColorCubeBitSize + c.ColorCubeBitSize) / 2))
	surface := workSurface.New(imageSize)
	fileName := c.OutputFilename
	cube := colorCube.New(uint8(c.ColorCubeBitSize))
	return nearestNeighborStrategy{list.New(), color.RGBA{255, 255, 255, 255}, surface, fileName, cube}
}
示例#2
0
func (s randomImageStrategy) GenerateImage(doneChan chan bool, imageUpdateChan chan ImageUpdate) {
	imageSize := 1 << uint(((s.cube.BitSize + s.cube.BitSize + s.cube.BitSize) / 2))
	surface := workSurface.New(imageSize)
	for x := 0; x < surface.Size; x++ {
		for y := 0; y < surface.Size; y++ {
			R := uint8(rand.Intn(256))
			G := uint8(rand.Intn(256))
			B := uint8(rand.Intn(256))
			surface.SetColorRGB(x, y, R, G, B)
			surface.SetUsed(x, y)
		}
	}
	surface.ToPng(s.fileName)
	doneChan <- true
}
示例#3
0
func (s iteratorStrategy) GenerateImage(doneChan chan bool, imageUpdateChan chan ImageUpdate) {
	imageSize := 1 << uint(((s.cube.BitSize + s.cube.BitSize + s.cube.BitSize) / 2))
	surface := workSurface.New(imageSize)
	colorStorage := make([]color.RGBA, imageSize*imageSize)
	nextColorSpace := 0
	for x := 0; x < s.cube.SideSize; x++ {
		for y := 0; y < s.cube.SideSize; y++ {
			for z := 0; z < s.cube.SideSize; z++ {
				colorStorage[nextColorSpace] = s.cube.GetColor(x, y, z)
				nextColorSpace++
			}
		}
	}
	nextColorSpace = 0
	for x := 0; x < surface.Size; x++ {
		for y := 0; y < surface.Size; y++ {
			surface.SetColor(x, y, colorStorage[nextColorSpace])
			surface.SetUsed(x, y)
			nextColorSpace++
		}
	}
	surface.ToPng(s.fileName)
	doneChan <- true
}