Documentation ¶
Overview ¶
Package canvas contains all of the primitive CanvasObjects that make up a Fyne GUI
Index ¶
- func Refresh(obj fyne.CanvasObject)
- type Circle
- type Image
- func (i *Image) Alpha() float64
- func (r *Image) Hide()
- func (r *Image) MinSize() fyne.Size
- func (r *Image) Move(pos fyne.Position)
- func (r *Image) Position() fyne.Position
- func (r *Image) Resize(size fyne.Size)
- func (r *Image) SetMinSize(size fyne.Size)
- func (r *Image) Show()
- func (r *Image) Size() fyne.Size
- func (r *Image) Visible() bool
- type ImageFill
- type Line
- type Raster
- func (r *Raster) Alpha() float64
- func (r *Raster) Hide()
- func (r *Raster) MinSize() fyne.Size
- func (r *Raster) Move(pos fyne.Position)
- func (r *Raster) Position() fyne.Position
- func (r *Raster) Resize(size fyne.Size)
- func (r *Raster) SetMinSize(size fyne.Size)
- func (r *Raster) Show()
- func (r *Raster) Size() fyne.Size
- func (r *Raster) Visible() bool
- type Rectangle
- func (r *Rectangle) Hide()
- func (r *Rectangle) MinSize() fyne.Size
- func (r *Rectangle) Move(pos fyne.Position)
- func (r *Rectangle) Position() fyne.Position
- func (r *Rectangle) Resize(size fyne.Size)
- func (r *Rectangle) SetMinSize(size fyne.Size)
- func (r *Rectangle) Show()
- func (r *Rectangle) Size() fyne.Size
- func (r *Rectangle) Visible() bool
- type Text
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Refresh ¶
func Refresh(obj fyne.CanvasObject)
Refresh instructs the containing canvas to refresh the specified obj.
Types ¶
type Circle ¶
type Circle struct { Position1 fyne.Position // The current top-left position of the Circle Position2 fyne.Position // The current bottomright position of the Circle Hidden bool // Is this circle currently hidden FillColor color.Color // The circle fill colour StrokeColor color.Color // The circle stroke colour StrokeWidth float32 // The stroke width of the circle }
Circle describes a coloured circle primitive in a Fyne canvas
func (*Circle) MinSize ¶
MinSize for a Circle simply returns Size{1, 1} as there is no explicit content
func (*Circle) Position ¶
Position gets the current top-left position of this circle object, relative to it's parent / canvas
type Image ¶
type Image struct { // one of the following sources will provide our image data File string // Load the image from a file Resource fyne.Resource // Load the image from an in-memory resource Image image.Image // Specify a loaded image to use in this canvas object Translucency float64 // Set a translucency value > 0.0 to fade the image FillMode ImageFill // Specify how the image should scale to fill or fit // contains filtered or unexported fields }
Image describes a drawable image area that can render in a Fyne canvas The image may be a vector or a bitmap representation and it will fill the area. The fill mode can be changed by setting FillMode to a different ImageFill.
func NewImageFromFile ¶
NewImageFromFile creates a new image from a local file. Images returned from this method will scale to fit the canvas object. The method for scaling can be set using the Fill field.
func NewImageFromImage ¶
NewImageFromImage returns a new Image instance that is rendered from the Go image.Image passed in. Images returned from this method will scale to fit the canvas object. The method for scaling can be set using the Fill field.
func NewImageFromResource ¶
NewImageFromResource creates a new image by loading the specified resource. Images returned from this method will scale to fit the canvas object. The method for scaling can be set using the Fill field.
func (*Image) Alpha ¶
Alpha is a convenience function that returns the alpha value for an image based on it's Translucency value. The result is 1.0 - Translucency.
func (*Image) Position ¶
CurrentPosition gets the current position of this rectangle object, relative to it's parent / canvas
func (*Image) SetMinSize ¶
SetMinSize specifies the smallest size this object should be
type ImageFill ¶
type ImageFill int
ImageFill defines the different type of ways an image can stretch to fill it's space.
const ( // ImageFillStretch will scale the image to match the Size() values. // This is the default and does not maintain aspect ratio. ImageFillStretch ImageFill = iota // ImageFillContain makes the image fit within the object Size(), // centrally and maintaining aspect ratio. // There may be transparent sections top and bottom or left and right. ImageFillContain //(Fit) // ImageFillOriginal ensures that the container grows to the pixel dimensions // required to fit the original image. The aspect of the image will be maintained so, // as with ImageFillContain there may be transparent areas around the image. // Note that the minSize may be smaller than the image dimensions if scale > 1. ImageFillOriginal )
type Line ¶
type Line struct { Position1 fyne.Position // The current top-left position of the Line Position2 fyne.Position // The current bottomright position of the Line Hidden bool // Is this Line currently hidden StrokeColor color.Color // The line stroke colour StrokeWidth float32 // The stroke width of the line }
Line describes a coloured line primitive in a Fyne canvas. Lines are special as they can have a negative width or height to indicate an inverse slope (i.e. slope up vs down).
func (*Line) Position ¶
Position gets the current top-left position of this line object, relative to it's parent / canvas
type Raster ¶
type Raster struct { Generator func(w, h int) image.Image // Render the raster image from code Translucency float64 // Set a translucency value > 0.0 to fade the raster // contains filtered or unexported fields }
Raster describes a raster image area that can render in a Fyne canvas
func NewRaster ¶
NewRaster returns a new Image instance that is rendered dynamically using the specified generate function. Images returned from this method should draw dynamically to fill the width and height parameters passed to pixelColor.
func NewRasterFromImage ¶
NewRasterFromImage returns a new Raster instance that is rendered from the Go image.Image passed in. Rasters returned from this method will map pixel for pixel to the screen starting img.Bounds().Min pixels from the top left of the canvas object. Truncates rather than scales the image. If smaller than the target space, the image will be padded with zero-pixels to the target size.
func NewRasterWithPixels ¶
NewRasterWithPixels returns a new Image instance that is rendered dynamically by iterating over the specified pixelColor function for each x, y pixel. Images returned from this method should draw dynamically to fill the width and height parameters passed to pixelColor.
func (*Raster) Alpha ¶
Alpha is a convenience function that returns the alpha value for a raster based on it's Translucency value. The result is 1.0 - Translucency.
func (*Raster) Position ¶
CurrentPosition gets the current position of this rectangle object, relative to it's parent / canvas
func (*Raster) SetMinSize ¶
SetMinSize specifies the smallest size this object should be
type Rectangle ¶
type Rectangle struct { FillColor color.Color // The rectangle fill colour StrokeColor color.Color // The rectangle stroke colour StrokeWidth float32 // The stroke width of the rectangle // contains filtered or unexported fields }
Rectangle describes a coloured rectangle primitive in a Fyne canvas
func NewRectangle ¶
NewRectangle returns a new Rectangle instance
func (*Rectangle) Move ¶
Move the rectangle object to a new position, relative to it's parent / canvas
func (*Rectangle) Position ¶
CurrentPosition gets the current position of this rectangle object, relative to it's parent / canvas
func (*Rectangle) SetMinSize ¶
SetMinSize specifies the smallest size this object should be
type Text ¶
type Text struct { Alignment fyne.TextAlign // The alignment of the text content Color color.Color // The main text draw colour Text string // The string content of this Text TextSize int // Size of the text - if the Canvas scale is 1.0 this will be equivalent to point size TextStyle fyne.TextStyle // The style of the text content // contains filtered or unexported fields }
Text describes a text primitive in a Fyne canvas. A text object can have a style set which will apply to the whole string. No formatting or text parsing will be performed
func (*Text) MinSize ¶
MinSize returns the minimum size of this text objet based on it's font size and content. This is normally determined by the render implementation.
func (*Text) Position ¶
CurrentPosition gets the current position of this rectangle object, relative to it's parent / canvas
func (*Text) SetMinSize ¶
SetMinSize specifies the smallest size this object should be