Exemplo n.º 1
0
func (p *piece) Create(act, inact *xgraphics.Image) {
	if act != nil {
		if p.active > 0 {
			xgraphics.FreePixmap(p.X, p.active)
		}
		act.CreatePixmap()
		act.XDraw()

		p.active = act.Pixmap
	}
	if inact != nil {
		if p.inactive > 0 {
			xgraphics.FreePixmap(p.X, p.inactive)
		}
		inact.CreatePixmap()
		inact.XDraw()

		p.inactive = inact.Pixmap
	}
}
Exemplo n.º 2
0
// SetImageToBg sets the given image into the background at the proper location
// for the named output to display.
func SetImageToBg(X *xgbutil.XUtil,
	bg *xgraphics.Image,
	img image.Image,
	name string) error {

	output, err := util.GetOutputByName(X, name)
	if err != nil {
		return err
	}
	geom, err := util.OutputRect(X, output)
	if err != nil {
		return err
	}
	if err = bg.CreatePixmap(); err != nil {
		return err
	}
	bg.XDraw()
	draw.Draw(bg, geom, img, img.Bounds().Min, draw.Src)
	return nil
}