Example #1
0
func TweetDrawer(c chan<- draw.Image, pixel draw.Image, tweets <-chan *twitter.Tweet) {
	counter := 0
	bg := image.NewNRGBA(pixel.Bounds())
	pixelutils.StretchCopy(bg, pixel)
	c <- pixel
	avatarArea := pixelutils.SubImage(pixel, image.Rectangle{
		Min: pixel.Bounds().Min,
		Max: pixel.Bounds().Min.Add(image.Point{85, 85}),
	})
	textArea := pixelutils.PixelSizeChanger(pixelutils.SubImage(pixel, image.Rectangle{
		Min: pixel.Bounds().Min.Add(image.Point{90, 0}),
		Max: pixel.Bounds().Max,
	}), 2, 2)
	for tweet := range tweets {
		counter++
		pixelutils.StretchCopy(pixel, bg)
		pixelutils.StretchCopy(avatarArea, tweet.Author.ProfilePicture)
		pixelutils.DrawText(pixelutils.PixelSizeChanger(avatarArea, 3, 3), pixelutils.Red, fmt.Sprintf("%03d", counter))
		pixelutils.DrawText(textArea, pixelutils.White, tweet.Text)
		c <- pixel
	}
}
Example #2
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
	}
}
Example #3
0
func main() {
	cred := loadCredentials()
	fakeC := make(chan draw.Image)
	wall, _ := pixelutils.PixelPusher()
	pixel := pixelutils.NewPixel()

	TweetDispatch(cred)

	for i, section := range TweetSections {
		subPixel := pixelutils.SubImage(pixel, image.Rect(0, i*85, 256, (i+1)*85))
		pixelutils.StretchCopy(subPixel, loadImage(section.BackgroundImage))
		pixelutils.Fill(subPixel, translucentBlack)
		go TweetDrawer(fakeC, subPixel, section.Tweets)
	}

	for _ = range fakeC {
		wall <- pixel
	}
}