本文整理匯總了Golang中github.com/BurntSushi/xgbutil/xgraphics.Image.XExpPaint方法的典型用法代碼示例。如果您正苦於以下問題:Golang Image.XExpPaint方法的具體用法?Golang Image.XExpPaint怎麽用?Golang Image.XExpPaint使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/BurntSushi/xgbutil/xgraphics.Image
的用法示例。
在下文中一共展示了Image.XExpPaint方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: paint
// paint uses the xgbutil/xgraphics package to copy the area corresponding
// to ximg in its pixmap to the window. It will also issue a clear request
// before hand to try and avoid artifacts.
func (w *Window) paint(ximg *xgraphics.Image) {
// If the image is bigger than the canvas, this is always (0, 0).
// If the image is the same size, then it is also (0, 0).
// If a dimension of the image is smaller than the canvas, then:
// x = (canvas_width - image_width) / 2 and
// y = (canvas_height - image_height) / 2
xmargin, ymargin := 0, 0
if ximg.Bounds().Dx() < w.Geom.Width() {
xmargin = (w.Geom.Width() - ximg.Bounds().Dx()) / 2
}
if ximg.Bounds().Dy() < w.Geom.Height() {
ymargin = (w.Geom.Height() - ximg.Bounds().Dy()) / 2
}
ximg.XExpPaint(w.Id, xmargin, ymargin)
}
示例2: paint
// paint uses the xgbutil/xgraphics package to copy the area corresponding
// to ximg in its pixmap to the window. It will also issue a clear request
// before hand to try and avoid artifacts.
func (w *window) paint(ximg *xgraphics.Image) {
dst := vpCenter(ximg, w.Geom.Width(), w.Geom.Height())
// UUU Commenting this out avoids flickering, and I see no artifacts!
// w.ClearAll()
ximg.XExpPaint(w.Id, dst.X, dst.Y)
}
示例3: makeWindow
func makeWindow(ximage *xgraphics.Image) (*xwindow.Window, *bool) {
w, h := ximage.Rect.Dx(), ximage.Rect.Dy()
window, err := xwindow.Generate(ximage.X)
if err != nil {
xgbutil.Logger.Printf("Could not generate new window id: %s", err)
return nil, nil
}
window.Create(ximage.X.RootWin(), 0, 0, w, h, xproto.CwBackPixel, 0x00000000)
window.Listen(xproto.EventMaskExposure,
xproto.EventMaskKeyPress,
xproto.EventMaskStructureNotify,
xproto.EventMaskVisibilityChange)
window.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()
xevent.Quit(w.X)
})
err = icccm.WmStateSet(ximage.X, window.Id, &icccm.WmState{
State: icccm.StateNormal,
})
if err != nil {
xgbutil.Logger.Printf("Could not set WM_STATE: %s", err)
}
err = ewmh.WmNameSet(ximage.X, window.Id, "Computer System Monitor")
if err != nil {
xgbutil.Logger.Printf("Could not set _NET_WM_NAME: %s", err)
}
err = keybind.KeyPressFun(
func(X *xgbutil.XUtil, ev xevent.KeyPressEvent) {
err := ewmh.WmStateReq(ximage.X, window.Id, ewmh.StateToggle,
"_NET_WM_STATE_FULLSCREEN")
if err != nil {
log.Fatal(err)
}
}).Connect(ximage.X, window.Id, "f", false)
if err != nil {
log.Fatal(err)
}
xevent.ExposeFun(
func(xu *xgbutil.XUtil, event xevent.ExposeEvent) {
ximage.XExpPaint(window.Id, 0, 0)
}).Connect(ximage.X, window.Id)
obscured := false
xevent.VisibilityNotifyFun(
func(xu *xgbutil.XUtil, event xevent.VisibilityNotifyEvent) {
obscured = event.State == xproto.VisibilityFullyObscured
}).Connect(ximage.X, window.Id)
window.Map()
return window, &obscured
}