Beispiel #1
0
func (me *Drawer) Draw(c *gfx.Canvas) {
	//clear screen
	c.SetRGB(0, 0, 0)
	c.FillRect(0, 0, gfx.DisplayWidth(), gfx.DisplayHeight())

	c.SetRGBA(0, 0, 255, 255)
	c.FillRect(42, 42, 100, 100)

	//draw box if it's not nil
	if me.box != nil {
		c.DrawImage(me.box, 200, 200)
		c.SetRGBA(0, 0, 0, 100)
		c.FillRect(200, 200, 100, 100)
	}
	c.DrawText(me.text, 400, 400)

	//Note: viewports may be nested
	c.PushViewport(42, 42, 500, 500)
	{
		//draw a green rect in a viewport
		c.SetRGBA(0, 255, 100, 127)
		c.FillRect(42, 42, 100, 100)
		c.SetRGB(0, 0, 0)
		c.FillRect(350, 200, 70, 70)
		c.DrawAnimation(me.anim, 350, 200)
	}
	c.PopViewport()
}
Beispiel #2
0
func (mm *MainMenu) Draw(c *gfx.Canvas) {
	baseHeight := gfx.DisplayHeight()
	baseWidth := gfx.DisplayWidth()
	c.SetRGB(0, 0, 0)
	c.FillRect(0, 0, baseWidth, baseHeight)
	//green square
	c.SetRGBA(0, 255, 100, 127)
	c.FillRect(0, 0, 100, 100)
	if mm.logoX > baseHeight-16 {
		mm.logoX = baseHeight - 16
	}
	if mm.logoY > baseWidth-16 {
		mm.logoY = baseWidth - 16
	}
	if mm.logoX < 0 {
		mm.logoX = 0
	}
	if mm.logoY < 0 {
		mm.logoY = 0
	}

	c.DrawText(mm.Title, baseHeight/4, baseWidth/5)
	for item := range mm.menu {
		c.DrawText(mm.menu[item].text, mm.menu[item].x, mm.menu[item].y)
	}
	c.PushViewport(42, 42, 500, 500)
	{
		//draw a green rect in a viewport
		c.SetRGBA(0, 255, 100, 127)
		c.FillRect(0, 0, 100, 100)
	}
	c.PopViewport()
	c.DrawImage(mm.logo, mm.logoY, mm.logoX)

}