You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: gradient.go
    path of file: ./repos/fyne/canvas
    
    the code of the file until where you have to start completion: package canvas

import (
	"image"
	"image/color"
	"math"

	"fyne.io/fyne/v2"
)

// LinearGradient defines a Gradient travelling straight at a given angle.
// The only supported values for the angle are `0.0` (vertical) and `90.0` (horizontal), currently.
type LinearGradient struct {
	baseObject

	StartColor color.Color // The beginning color of the gradient
	EndColor   color.Color // The end color of the gradient
	Angle      float64     // The angle of the gradient (0/180 for vertical; 90/270 for horizontal)
}

// Generate calculates an image of the gradient with the
    
func (g *LinearGradient) Generate(iw, ih int) image.Image {
	w, h := float64(iw), float64(ih)
	var generator func(x, y float64) float64
	switch g.Angle {
	case 90: // horizontal flipped
		generator = func(x, _ float64) float64 {
			return (w - x) / w
		}
	case 270: // horizontal
		generator = func(x, _ float64) float64 {
			return x / w
		}
	case 45: // diagonal negative flipped
		generator = func(x, y float64) float64 {
			return math.Abs((w - x + y) / (w + h)) // ((w+h)-(x+h-y)) / (w+h)
		}
	case 225: // diagonal negative
		generator = func(x, y float64) float64 {
			return math.Abs((x + h - y) / (w + h))
		}
	case 135: // diagonal positive flipped
		generator = func(x, y float64) float64 {
			return math.Abs((w + h - (x + y)) / (w + h))
		}
	case 315: // diagonal positive
		generator = func(x, y float64) float64 {
			return math.Abs((x + y) / (w + h))
		}
	case 180: // vertical flipped
		generator = func(_, y float64) float64 {
			return (h - y) / h
		}
	default: // vertical
		generator = func(_, y float64) float64 {
			return y / h
		}
	}
	return computeGradient(generator, iw, ih, g.StartColor, g.EndColor)
}