Exemple #1
0
func ShowBuffer(title string, buffer image.Image) {
	if buffer == nil {
		return
	}
	width, height := int(buffer.Bounds().Max.X), int(buffer.Bounds().Max.Y)
	if width == 0 || height == 0 {
		return
	}
	w, err := xgb.NewWindow(width, height)
	if err != nil {
		return
	}
	w.SetTitle(title)
	for x := 0; x < width; x++ {
		for y := 0; y < height; y++ {
			if (x/10)%2 == (y/10)%2 {
				w.Screen().Set(x, y, color.White)
			} else {
				w.Screen().Set(x, y, color.RGBA{200, 200, 200, 255})
			}
		}
	}
	draw.Draw(w.Screen(), buffer.Bounds(), buffer, image.Point{0, 0}, draw.Over)
	w.FlushImage()
	w.Show()

loop:
	for e := range w.EventChan() {
		switch e.(type) {
		case wde.CloseEvent, wde.MouseDownEvent:
			break loop
		}
	}
	w.Close()
}
Exemple #2
0
func init() {
	WindowGenerator = func(parent wde.Window, width, height int) (window wde.Window, err error) {
		window, err = xgb.NewWindow(width, height)
		return
	}
}