Exemple #1
0
func main() {
	defer Recovery()

	X, Xerr = xgbutil.Dial("")
	if Xerr != nil {
		panic(Xerr)
	}

	active, _ := ewmh.ActiveWindowGet(X)
	icons, _ := ewmh.WmIconGet(X, active)

	var width, height int = 300, 300

	work := xgraphics.FindBestIcon(width, height, icons)
	if work != nil {
		fmt.Printf("Working with icon (%d, %d)\n", work.Width, work.Height)
	} else {
		fmt.Println("No good icon... :-(")
		return
	}

	eimg, emask := xgraphics.EwmhIconToImage(work)

	img := xgraphics.Scale(eimg, int(width), int(height))
	mask := xgraphics.Scale(emask, int(width), int(height))

	dest := xgraphics.BlendBg(img, mask, 100, color.RGBA{0, 0, 255, 255})

	// Let's try to write some text...
	// xgraphics.DrawText(dest, 50, 50, color.RGBA{255, 255, 255, 255}, 20,
	// fontFile, "Hello, world!")

	// tw, th, err := xgraphics.TextExtents(fontFile, 11, "Hiya")
	// fmt.Println(tw, th, err)

	win := xgraphics.CreateImageWindow(X, dest, 3940, 0)
	X.Conn().MapWindow(win)

	// time.Sleep(20 * time.Second)
	select {}
}
Exemple #2
0
func main() {
	defer Recovery()

	X, Xerr = xgbutil.Dial("")
	if Xerr != nil {
		panic(Xerr)
	}

	simg, err := xgraphics.LoadPngFromFile("openbox.png")
	if err != nil {
		fmt.Println(err)
	}

	img := image.NewRGBA(image.Rect(0, 0, 50, 101))
	graphics.Scale(img, simg)

	dest := xgraphics.BlendBg(img, nil, 100, color.RGBA{255, 255, 255, 255})

	win := xgraphics.CreateImageWindow(X, dest, 3940, 400)
	X.Conn().MapWindow(win)

	time.Sleep(20 * time.Second)
}