The canvas package includes definitions of all of the basic drawing objects that Fyne understands. Each of these types defines a number of fields that represent the configuration, such as color, size, and visibility. These are the objects that a Fyne driver will iterate over, drawing each to create the rendered user interface:
Circle |
This is a circle, or ellipse, defined by the bounding top-left to bottom-right rectangle. It could be created with NewCircle() or &Circle{}. It isn't commonly used in most applications. |
Image |
An image may be a vector or bitmap-based image loaded from a file (with NewImageFromFile()) or embedded resource, or it may be an image generated dynamically to fill available space (using NewRaster() and a func(w, h int) *image.Image callback). |
Line |
This is a simple line that draws from one position to another. It isn't commonly used unless drawing diagrams. |
Rectangle |
The basic building block for widgets, a rectangle draws an area with a specified color. Create with NewRectangle() or &Rectangle{}. |
Text |
The text canvas primitive draws a single string to screen in a specified color and alignment. It does not handle any special characters or formatting. It can be created directly using &Text{} or with the helper NewText() function. |
The preceding list makes up the primitive drawing elements of the Fyne canvas. Next, we look at how layouts can be used to position them within a container.