Exemplo n.º 1
0
func main() {
	wall, _ := pixelutils.PixelPusher()
	pixel := pixelutils.NewPixel()
	bigPixel := pixelutils.DimensionChanger(pixel, 5*4, 18)
	textPixel := pixelutils.NewImageWriter(bigPixel, pixelutils.Green)

	colons := colonGenerator()
	for {
		pixelutils.Empty(bigPixel)
		textPixel.Cls()
		fmt.Fprintf(textPixel, "%02d%s%02d", time.Now().Hour(), <-colons, time.Now().Minute())
		wall <- pixel
		time.Sleep(500 * time.Millisecond)
	}
}
Exemplo n.º 2
0
func main() {
	wall, _ := pixelutils.PixelPusher()
	pixel := pixelutils.NewPixel()

	bigPixel := pixelutils.DimensionChanger(pixel, 16, 12)
	textPixel := pixelutils.NewImageWriter(bigPixel, pixelutils.Red)
	for i := 0; i < 5; i++ {
		if i > 3 {
			panic("CRASH")
		}
		fmt.Fprintf(textPixel, "%d ", 3-i)
		wall <- pixel
		time.Sleep(1 * time.Second)
	}
}
Exemplo n.º 3
0
func main() {
	wall, _ := pixelutils.PixelPusher()
	pixel := pixelutils.NewPixel()

	board := &ImageBoard{
		Image: &DonutImage{pixelutils.DimensionChanger(pixel, Size, Size)},
		Alive: pixelutils.Green,
		Dead:  pixelutils.Black,
	}
	initBoard(board)
	for {
		wall <- pixel
		NextGen(board)
		time.Sleep(300 * time.Millisecond)
	}
}
Exemplo n.º 4
0
func main() {
	wall, clicks := pixelutils.PixelPusher()

	fullPixel := pixelutils.NewPixel()
	subPixel := pixelutils.SubImage(fullPixel, image.Rect(margin, margin, 256-margin, 256-margin))
	square := pixelutils.SubImage(fullPixel, image.Rect(256-margin, 0, 256, margin))
	textSquare := pixelutils.DimensionChanger(square, 3, 5)
	colors := []color.Color{pixelutils.Red, pixelutils.Green, pixelutils.Blue}
	offset := []int{0, 1, 2}

	drawSignal := make(chan bool)

	go func() {
		for i := 0; i < 5; i++ {
			offset = rand.Perm(3)
			drawSignal <- true
			time.Sleep(200 * time.Millisecond)
		}
		for click := range clicks {
			switch {
			case click.Point().In(subPixel.Bounds()):
				offset[1] = (offset[1] + 1) % len(colors)
			case click.Point().In(square.Bounds()):
				offset[2] = (offset[2] + 1) % len(colors)
			default:
				offset[0] = (offset[0] + 1) % len(colors)
			}
			drawSignal <- true
		}
	}()

	for _ = range drawSignal {
		pixelutils.Fill(fullPixel, colors[offset[0]])
		pixelutils.Fill(subPixel, colors[offset[1]])
		pixelutils.DrawText(textSquare, colors[offset[2]], "2")
		wall <- fullPixel
	}
}