Exemplo n.º 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
	}
}
Exemplo n.º 2
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
	}
}