本文整理汇总了Golang中github.com/BurntSushi/xgbutil/xgraphics.Image.XDraw方法的典型用法代码示例。如果您正苦于以下问题:Golang Image.XDraw方法的具体用法?Golang Image.XDraw怎么用?Golang Image.XDraw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/BurntSushi/xgbutil/xgraphics.Image
的用法示例。
在下文中一共展示了Image.XDraw方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: clearCanvas
// clearCanvas erases all your pencil marks.
func clearCanvas(canvas *xgraphics.Image, win *xwindow.Window) {
log.Println("Clearing canvas...")
canvas.For(func(x, y int) xgraphics.BGRA {
return bg
})
canvas.XDraw()
canvas.XPaint(win.Id)
}
示例2: showImage
// This is a slightly modified version of xgraphics.XShowExtra that does
// not set any resize constraints on the window (so that it can go
// fullscreen).
func showImage(im *xgraphics.Image, name string, quit bool) *xwindow.Window {
if len(name) == 0 {
name = "xgbutil Image Window"
}
w, h := im.Rect.Dx(), im.Rect.Dy()
win, err := xwindow.Generate(im.X)
if err != nil {
xgbutil.Logger.Printf("Could not generate new window id: %s", err)
return nil
}
// Create a very simple window with dimensions equal to the image.
win.Create(im.X.RootWin(), 0, 0, w, h, 0)
// Make this window close gracefully.
win.WMGracefulClose(func(w *xwindow.Window) {
xevent.Detach(w.X, w.Id)
keybind.Detach(w.X, w.Id)
mousebind.Detach(w.X, w.Id)
w.Destroy()
if quit {
xevent.Quit(w.X)
}
})
// Set WM_STATE so it is interpreted as a top-level window.
err = icccm.WmStateSet(im.X, win.Id, &icccm.WmState{
State: icccm.StateNormal,
})
if err != nil { // not a fatal error
xgbutil.Logger.Printf("Could not set WM_STATE: %s", err)
}
// Set _NET_WM_NAME so it looks nice.
err = ewmh.WmNameSet(im.X, win.Id, name)
if err != nil { // not a fatal error
xgbutil.Logger.Printf("Could not set _NET_WM_NAME: %s", err)
}
// Paint our image before mapping.
im.XSurfaceSet(win.Id)
im.XDraw()
im.XPaint(win.Id)
// Now we can map, since we've set all our properties.
// (The initial map is when the window manager starts managing.)
win.Map()
return win
}
示例3: SetRoot
// SetRoot sets the given background as the root window background.
func SetRoot(X *xgbutil.XUtil, bg *xgraphics.Image) error {
root := X.RootWin()
if err := bg.XSurfaceSet(root); err != nil {
return err
}
bg.XDraw()
bg.XPaint(root)
// FIXME: This doesn't set the pixmap persistently. As soon as the program
// exits, the pixmap is destroyed. Find a way to make it persistent.
xprop.ChangeProp32(X, root, "_XROOTPMAP_ID", "PIXMAP", uint(bg.Pixmap))
xprop.ChangeProp32(X, root, "ESETROOT_PMAP_ID", "PIXMAP", uint(bg.Pixmap))
return nil
}
示例4: Create
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
}
}
示例5: SetImageToBg
// 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
}