code: func drawGopher(canvas *xgraphics.Image, gopher image.Image,
  	win *xwindow.Window, x, y int) {
  
  	// Find the rectangle of the canvas where we're going to draw the gopher.
  	gopherRect := midRect(x, y, gopherWidth, gopherHeight, width, height)
  
  	// If the rectangle contains no pixels, don't draw anything.
  	if gopherRect.Empty() {
  		return
  	}
  
  	// Output a little message.
  	log.Printf("Drawing gopher at (%d, %d)", x, y)
  
  	// Get a subimage of the gopher that's in sync with gopherRect.
  	gopherPt := image.Pt(gopher.Bounds().Min.X, gopher.Bounds().Min.Y)
  	if gopherRect.Min.X == 0 {
  		gopherPt.X = gopherWidth - gopherRect.Dx()
  	}
  	if gopherRect.Min.Y == 0 {
  		gopherPt.Y = gopherHeight - gopherRect.Dy()
  	}
  
  	// Create the canvas subimage.
  	subCanvas := canvas.SubImage(gopherRect).(*xgraphics.Image)
  
  	// Blend the gopher image into the sub-canvas.
  	// This does alpha blending.
  	xgraphics.Blend(subCanvas, gopher, gopherPt)
  
  	// Now draw the changes to the pixmap.
  	subCanvas.XDraw()
  
  	// And paint them to the window.
  	subCanvas.XPaint(win.Id)
  }
docs: // drawGopher draws the gopher image to the canvas.