code: func paintGradient(X *xgbutil.XUtil, wid xproto.Window, width, height int,
  	start, end color.RGBA) {
  
  	ximg := xgraphics.New(X, image.Rect(0, 0, width, height))
  
  	// Now calculate the increment step between each RGB channel in
  	// the start and end colors.
  	rinc := (0xff * (int(end.R) - int(start.R))) / width
  	ginc := (0xff * (int(end.G) - int(start.G))) / width
  	binc := (0xff * (int(end.B) - int(start.B))) / width
  
  	// Now apply the increment to each "column" in the image.
  	// Using 'ForExp' allows us to bypass the creation of a color.BGRA value
  	// for each pixel in the image.
  	ximg.ForExp(func(x, y int) (uint8, uint8, uint8, uint8) {
  		return uint8(int(start.B) + (binc*x)/0xff),
  			uint8(int(start.G) + (ginc*x)/0xff),
  			uint8(int(start.R) + (rinc*x)/0xff),
  			0xff
  	})
  
  	// Set the surface to paint on for ximg.
  	// (This simply sets the background pixmap of the window to the pixmap
  	// used by ximg.)
  	ximg.XSurfaceSet(wid)
  
  	// XDraw will draw the contents of ximg to its corresponding pixmap.
  	ximg.XDraw()
  
  	// XPaint will "clear" the window provided so that it shows the updated
  	// pixmap.
  	ximg.XPaint(wid)
  
  	// Since we will not reuse ximg, we must destroy its pixmap.
  	ximg.Destroy()
  }
docs: // paintGradient creates a new xgraphics.Image value and draws a gradient
  // starting at color 'start' and ending at color 'end'.
  //
  // Since xgraphics.Image values use pixmaps and pixmaps cannot be resized,
  // a new pixmap must be allocated for each resize event.