The basic shapes are on the
Image companion object. This includes:
Image.emptycreates the empty Image that takes up no space and renders nothing. Useful for that sweet monoid identity and for the base case in recursions.
Image.square(sideLength)creates a square with the given side length.
Image.rectangle(width, height)creates a rectangle with the given width and height.
Image.circle(diameter)creates a circle with the given diameter. Specified in terms of diameter rather than radius so that
Image.circle(100)take up the same space.
Image.triangle(width, height)creates an isoceles triangle with the given width and height.
Some more complex shapes are also available on the
Image companion object:
Image.regularPolygon(sides, radius, angle)creates a regular polygon with the given number of sides and radius. The
anglespecifies the rotation of the polygon relative to the x-axis.
Image.star(points, outerRadius, innerRadius, angle)creates a star with the given number of points. The points extend as far as
outerRadiusand go in to
anglespecifies the rotation of the star relative to the x-axis.
Image.rightArrow(width, height)creates an arrow points to the right with the given width and height.
Image.roundedRectangle(width, height, radius)creates a rectangle of the given width and height, with rounded corners with size given by
Paths allow construction of custom shapes. They are described in their own section. There are three methods on the
Image companion object that deal with paths:
Imagerepresenting an open path (a path that does not end where it begins).
Imagerepresenting a closed path (a path that ends where it begins; a straight line will be inserted if to make this the case if needed.)
Imageby interpolating a smooth curve between the points using the Catmull-Rom algorithm.