Documentation ¶
Overview ¶
Package canvas contains all of the primitive CanvasObjects that make up a Fyne GUI
The types implemented in this package are used as building blocks in order to build higher order functionality. These types are designed to be non-interactive, by design. If additional functonality is required, it's usually a sign that this type should be used as part of a custom Widget.
Index ¶
- func Refresh(obj fyne.CanvasObject)
- type Circle
- func (l *Circle) Hide()
- func (l *Circle) MinSize() fyne.Size
- func (l *Circle) Move(pos fyne.Position)
- func (l *Circle) Position() fyne.Position
- func (l *Circle) Refresh()
- func (l *Circle) Resize(size fyne.Size)
- func (l *Circle) Show()
- func (l *Circle) Size() fyne.Size
- func (l *Circle) Visible() bool
- 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 (i *Image) Refresh()
- func (i *Image) Resize(s 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 ImageScale
- type Line
- type LinearGradient
- func (g *LinearGradient) Generate(iw, ih int) image.Image
- func (r *LinearGradient) Hide()
- func (r *LinearGradient) MinSize() fyne.Size
- func (r *LinearGradient) Move(pos fyne.Position)
- func (r *LinearGradient) Position() fyne.Position
- func (g *LinearGradient) Refresh()
- func (r *LinearGradient) Resize(size fyne.Size)
- func (r *LinearGradient) SetMinSize(size fyne.Size)
- func (r *LinearGradient) Show()
- func (r *LinearGradient) Size() fyne.Size
- func (r *LinearGradient) Visible() bool
- type RadialGradient
- func (g *RadialGradient) Generate(iw, ih int) image.Image
- func (r *RadialGradient) Hide()
- func (r *RadialGradient) MinSize() fyne.Size
- func (r *RadialGradient) Move(pos fyne.Position)
- func (r *RadialGradient) Position() fyne.Position
- func (g *RadialGradient) Refresh()
- func (r *RadialGradient) Resize(size fyne.Size)
- func (r *RadialGradient) SetMinSize(size fyne.Size)
- func (r *RadialGradient) Show()
- func (r *RadialGradient) Size() fyne.Size
- func (r *RadialGradient) Visible() bool
- 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) Refresh()
- func (r *Raster) Resize(s 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) Refresh()
- func (r *Rectangle) Resize(s 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
- func (r *Text) Hide()
- func (t *Text) MinSize() fyne.Size
- func (r *Text) Move(pos fyne.Position)
- func (r *Text) Position() fyne.Position
- func (t *Text) Refresh()
- func (r *Text) Resize(size fyne.Size)
- func (t *Text) SetMinSize(size fyne.Size)
- func (r *Text) Show()
- func (r *Text) Size() fyne.Size
- func (r *Text) Visible() bool
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 color StrokeColor color.Color // The circle stroke color StrokeWidth float32 // The stroke width of the circle }
Circle describes a colored 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 its parent / canvas
func (*Circle) Refresh ¶ added in v1.2.0
func (l *Circle) Refresh()
Refresh causes this object to be redrawn in it's current state
func (*Circle) Resize ¶
Resize sets a new bottom-right position for the circle object If it has a stroke width this will cause it to Refresh.
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 expand to fill or fit the available space ScaleMode ImageScale // Specify the type of scaling interpolation applied to the image // 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 its Translucency value. The result is 1.0 - Translucency.
func (*Image) Position ¶
CurrentPosition gets the current position of this rectangle object, relative to its parent / canvas
func (*Image) Refresh ¶ added in v1.2.0
func (i *Image) Refresh()
Refresh causes this object to be redrawn in it's current state
func (*Image) Resize ¶
Resize on an image will usually scale the content or reposition it according to FillMode.. If the content of the File or Resource is an SVG file, however, this will cause a Refresh.
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 its 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 ImageScale ¶ added in v1.3.0
type ImageScale int32
ImageScale defines the different scaling filters used to scaling images
const ( // ImageScaleSmooth will scale the image using ApproxBiLinear filter (or GL equivalent) ImageScaleSmooth ImageScale = 0 // ImageScalePixels will scale the image using NearestNeighbor filter (or GL equivalent) ImageScalePixels ImageScale = 1 )
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 color StrokeWidth float32 // The stroke width of the line }
Line describes a colored 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 its parent / canvas
func (*Line) Refresh ¶ added in v1.2.0
func (l *Line) Refresh()
Refresh causes this object to be redrawn in it's current state
func (*Line) Resize ¶
Resize sets a new bottom-right position for the line object and it will then be refreshed.
type LinearGradient ¶ added in v1.1.0
type LinearGradient struct { 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) // contains filtered or unexported fields }
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.
func NewHorizontalGradient ¶ added in v1.1.0
func NewHorizontalGradient(start, end color.Color) *LinearGradient
NewHorizontalGradient creates a new horizontally travelling linear gradient. The start color will be at the left of the gradient and the end color will be at the right.
func NewLinearGradient ¶ added in v1.2.0
func NewLinearGradient(start, end color.Color, angle float64) *LinearGradient
NewLinearGradient creates a linear gradient at a the specified angle. The angle parameter is the degree angle along which the gradient is calculated. A NewHorizontalGradient uses 270 degrees and NewVerticalGradient is 0 degrees.
func NewVerticalGradient ¶ added in v1.1.0
func NewVerticalGradient(start color.Color, end color.Color) *LinearGradient
NewVerticalGradient creates a new vertically travelling linear gradient. The start color will be at the top of the gradient and the end color will be at the bottom.
func (*LinearGradient) Generate ¶ added in v1.1.0
func (g *LinearGradient) Generate(iw, ih int) image.Image
Generate calculates an image of the gradient with the specified width and height.
func (*LinearGradient) Hide ¶ added in v1.1.0
func (r *LinearGradient) Hide()
Hide will set this object to not be visible
func (*LinearGradient) MinSize ¶ added in v1.1.0
MinSize returns the specified minimum size, if set, or {1, 1} otherwise
func (*LinearGradient) Move ¶ added in v1.1.0
Move the rectangle object to a new position, relative to its parent / canvas
func (*LinearGradient) Position ¶ added in v1.1.0
CurrentPosition gets the current position of this rectangle object, relative to its parent / canvas
func (*LinearGradient) Refresh ¶ added in v1.2.0
func (g *LinearGradient) Refresh()
Refresh causes this object to be redrawn in it's current state
func (*LinearGradient) SetMinSize ¶ added in v1.1.0
SetMinSize specifies the smallest size this object should be
func (*LinearGradient) Show ¶ added in v1.1.0
func (r *LinearGradient) Show()
Show will set this object to be visible
type RadialGradient ¶ added in v1.1.0
type RadialGradient struct { StartColor color.Color // The beginning color of the gradient EndColor color.Color // The end color of the gradient // The offset of the center for generation of the gradient. // This is not a DP measure but relates to the width/height. // A value of 0.5 would move the center by the half width/height. CenterOffsetX, CenterOffsetY float64 // contains filtered or unexported fields }
RadialGradient defines a Gradient travelling radially from a center point outward.
func NewRadialGradient ¶ added in v1.1.0
func NewRadialGradient(start, end color.Color) *RadialGradient
NewRadialGradient creates a new radial gradient.
func (*RadialGradient) Generate ¶ added in v1.1.0
func (g *RadialGradient) Generate(iw, ih int) image.Image
Generate calculates an image of the gradient with the specified width and height.
func (*RadialGradient) Hide ¶ added in v1.1.0
func (r *RadialGradient) Hide()
Hide will set this object to not be visible
func (*RadialGradient) MinSize ¶ added in v1.1.0
MinSize returns the specified minimum size, if set, or {1, 1} otherwise
func (*RadialGradient) Move ¶ added in v1.1.0
Move the rectangle object to a new position, relative to its parent / canvas
func (*RadialGradient) Position ¶ added in v1.1.0
CurrentPosition gets the current position of this rectangle object, relative to its parent / canvas
func (*RadialGradient) Refresh ¶ added in v1.2.0
func (g *RadialGradient) Refresh()
Refresh causes this object to be redrawn in it's current state
func (*RadialGradient) SetMinSize ¶ added in v1.1.0
SetMinSize specifies the smallest size this object should be
func (*RadialGradient) Show ¶ added in v1.1.0
func (r *RadialGradient) Show()
Show will set this object to be visible
type Raster ¶
type Raster struct { // Render the raster image from code Generator func(w, h int) image.Image // Set a translucency value > 0.0 to fade the raster Translucency float64 // Specify the type of scaling interpolation applied to the raster if it is not full-size // Since: 1.4.1 ScaleMode ImageScale // 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 its Translucency value. The result is 1.0 - Translucency.
func (*Raster) Position ¶
CurrentPosition gets the current position of this rectangle object, relative to its parent / canvas
func (*Raster) Refresh ¶ added in v1.2.0
func (r *Raster) Refresh()
Refresh causes this object to be redrawn in it's current state
func (*Raster) Resize ¶
Resize on a raster image causes the new size to be set and then calls Refresh. This causes the underlying data to be recalculated and a new output to be drawn.
func (*Raster) SetMinSize ¶
SetMinSize specifies the smallest size this object should be
type Rectangle ¶
type Rectangle struct { FillColor color.Color // The rectangle fill color StrokeColor color.Color // The rectangle stroke color StrokeWidth float32 // The stroke width of the rectangle // contains filtered or unexported fields }
Rectangle describes a colored 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 its parent / canvas
func (*Rectangle) Position ¶
CurrentPosition gets the current position of this rectangle object, relative to its parent / canvas
func (*Rectangle) Refresh ¶ added in v1.2.0
func (r *Rectangle) Refresh()
Refresh causes this object to be redrawn in it's current state
func (*Rectangle) Resize ¶
Resize on a rectangle updates the new size of this object. If it has a stroke width this will cause it to Refresh.
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 color 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 object based on its 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 its parent / canvas
func (*Text) Refresh ¶ added in v1.2.0
func (t *Text) Refresh()
Refresh causes this object to be redrawn in it's current state
func (*Text) SetMinSize ¶
SetMinSize has no effect as the smallest size this canvas object can be is based on its font size and content.