Author
Travis Kirton


Start and End Points

Each gradient has two points between which the gradient will draw. By default these values are:

start = Point(0, 0)
end = Point(0, 1)

These two points tell the gradient to draw from top to bottom (i.e. the y value changes from 0 to 1).

You can change these points by specifying new variables, like this:

gradient.startPoint = Point(0, 1)
gradient.endPoint = Point(0, 0)

Example

var f = canvas.frame
f.width /= 2

let g1 = Gradient(frame: f)
g1.startPoint = Point(0, 0)
g1.endPoint = Point(1, 1)
canvas.add(g1)

f.origin.x += canvas.center.x
let g2 = Gradient(frame: f)
g2.startPoint = Point(1, 0)
g2.endPoint = Point(0, 1)
canvas.add(g2)