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 functionality is required, it's usually a sign that this type should be used as part of a custom widget.
Index ¶
- Constants
- func NewColorRGBAAnimation(start, stop color.Color, d time.Duration, fn func(color.Color)) *fyne.Animation
- func NewPositionAnimation(start, stop fyne.Position, d time.Duration, fn func(fyne.Position)) *fyne.Animation
- func NewShaderAnimation(s *Shader) *fyne.Animation
- func NewSizeAnimation(start, stop fyne.Size, d time.Duration, fn func(fyne.Size)) *fyne.Animation
- func RecolorSVG(svgContent []byte, color color.Color) ([]byte, error)
- func Refresh(obj fyne.CanvasObject)
- type ArbitraryPolygon
- func (p *ArbitraryPolygon) Hide()
- func (o *ArbitraryPolygon) MinSize() fyne.Size
- func (p *ArbitraryPolygon) Move(pos fyne.Position)
- func (o *ArbitraryPolygon) Position() fyne.Position
- func (p *ArbitraryPolygon) Refresh()
- func (p *ArbitraryPolygon) Resize(s fyne.Size)
- func (o *ArbitraryPolygon) SetMinSize(size fyne.Size)
- func (o *ArbitraryPolygon) Show()
- func (o *ArbitraryPolygon) Size() fyne.Size
- func (o *ArbitraryPolygon) Visible() bool
- type Arc
- func (a *Arc) Hide()
- func (o *Arc) MinSize() fyne.Size
- func (a *Arc) Move(pos fyne.Position)
- func (o *Arc) Position() fyne.Position
- func (a *Arc) Refresh()
- func (a *Arc) Resize(s fyne.Size)
- func (o *Arc) SetMinSize(size fyne.Size)
- func (o *Arc) Show()
- func (o *Arc) Size() fyne.Size
- func (o *Arc) Visible() bool
- type BezierCurve
- func NewCubicBezierCurve(startPoint, controlPoint1, controlPoint2, endPoint fyne.Position, ...) *BezierCurve
- func NewLinearBezierCurve(startPoint, endPoint fyne.Position, color color.Color) *BezierCurve
- func NewQuadraticBezierCurve(startPoint, controlPoint, endPoint fyne.Position, color color.Color) *BezierCurve
- func (r *BezierCurve) Hide()
- func (o *BezierCurve) MinSize() fyne.Size
- func (r *BezierCurve) Move(pos fyne.Position)
- func (o *BezierCurve) Position() fyne.Position
- func (r *BezierCurve) Refresh()
- func (r *BezierCurve) Resize(s fyne.Size)
- func (o *BezierCurve) SetMinSize(size fyne.Size)
- func (o *BezierCurve) Show()
- func (o *BezierCurve) Size() fyne.Size
- func (o *BezierCurve) Visible() bool
- type Blur
- func (b *Blur) Hide()
- func (o *Blur) MinSize() fyne.Size
- func (b *Blur) Move(pos fyne.Position)
- func (o *Blur) Position() fyne.Position
- func (b *Blur) Refresh()
- func (b *Blur) Resize(s fyne.Size)
- func (o *Blur) SetMinSize(size fyne.Size)
- func (o *Blur) Show()
- func (o *Blur) Size() fyne.Size
- func (o *Blur) Visible() bool
- type Circle
- func (c *Circle) Hide()
- func (c *Circle) MinSize() fyne.Size
- func (c *Circle) Move(pos fyne.Position)
- func (c *Circle) Position() fyne.Position
- func (c *Circle) Refresh()
- func (c *Circle) Resize(size fyne.Size)
- func (c *Circle) Show()
- func (c *Circle) Size() fyne.Size
- func (c *Circle) Visible() bool
- type Ellipse
- func (e *Ellipse) Hide()
- func (o *Ellipse) MinSize() fyne.Size
- func (e *Ellipse) Move(pos fyne.Position)
- func (o *Ellipse) Position() fyne.Position
- func (e *Ellipse) Refresh()
- func (e *Ellipse) Resize(s fyne.Size)
- func (o *Ellipse) SetMinSize(size fyne.Size)
- func (o *Ellipse) Show()
- func (o *Ellipse) Size() fyne.Size
- func (o *Ellipse) Visible() bool
- type Image
- func (i *Image) Alpha() float64
- func (i *Image) Aspect() float32
- func (i *Image) Hide()
- func (i *Image) MinSize() fyne.Size
- func (i *Image) Move(pos fyne.Position)
- func (o *Image) Position() fyne.Position
- func (i *Image) Refresh()
- func (i *Image) Resize(s fyne.Size)
- func (o *Image) SetMinSize(size fyne.Size)
- func (o *Image) Show()
- func (o *Image) Size() fyne.Size
- func (o *Image) Visible() bool
- type ImageFill
- type ImageScale
- type Line
- type LinearGradient
- func (g *LinearGradient) Generate(iw, ih int) image.Image
- func (g *LinearGradient) Hide()
- func (o *LinearGradient) MinSize() fyne.Size
- func (g *LinearGradient) Move(pos fyne.Position)
- func (o *LinearGradient) Position() fyne.Position
- func (g *LinearGradient) Refresh()
- func (g *LinearGradient) Resize(size fyne.Size)
- func (o *LinearGradient) SetMinSize(size fyne.Size)
- func (o *LinearGradient) Show()
- func (o *LinearGradient) Size() fyne.Size
- func (o *LinearGradient) Visible() bool
- type Polygon
- type RadialGradient
- func (g *RadialGradient) Generate(iw, ih int) image.Image
- func (g *RadialGradient) Hide()
- func (o *RadialGradient) MinSize() fyne.Size
- func (g *RadialGradient) Move(pos fyne.Position)
- func (o *RadialGradient) Position() fyne.Position
- func (g *RadialGradient) Refresh()
- func (g *RadialGradient) Resize(size fyne.Size)
- func (o *RadialGradient) SetMinSize(size fyne.Size)
- func (o *RadialGradient) Show()
- func (o *RadialGradient) Size() fyne.Size
- func (o *RadialGradient) Visible() bool
- type Raster
- func (r *Raster) Alpha() float64
- func (r *Raster) Hide()
- func (o *Raster) MinSize() fyne.Size
- func (r *Raster) Move(pos fyne.Position)
- func (o *Raster) Position() fyne.Position
- func (r *Raster) Refresh()
- func (r *Raster) Resize(s fyne.Size)
- func (o *Raster) SetMinSize(size fyne.Size)
- func (o *Raster) Show()
- func (o *Raster) Size() fyne.Size
- func (o *Raster) Visible() bool
- type Rectangle
- func (r *Rectangle) Hide()
- func (o *Rectangle) MinSize() fyne.Size
- func (r *Rectangle) Move(pos fyne.Position)
- func (o *Rectangle) Position() fyne.Position
- func (r *Rectangle) Refresh()
- func (r *Rectangle) Resize(s fyne.Size)
- func (o *Rectangle) SetMinSize(size fyne.Size)
- func (o *Rectangle) Show()
- func (o *Rectangle) Size() fyne.Size
- func (o *Rectangle) Visible() bool
- type RegularPolygon
- func (r *RegularPolygon) Hide()
- func (o *RegularPolygon) MinSize() fyne.Size
- func (r *RegularPolygon) Move(pos fyne.Position)
- func (o *RegularPolygon) Position() fyne.Position
- func (r *RegularPolygon) Refresh()
- func (r *RegularPolygon) Resize(s fyne.Size)
- func (o *RegularPolygon) SetMinSize(size fyne.Size)
- func (o *RegularPolygon) Show()
- func (o *RegularPolygon) Size() fyne.Size
- func (o *RegularPolygon) Visible() bool
- type Shader
- func (s *Shader) Hide()
- func (o *Shader) MinSize() fyne.Size
- func (s *Shader) Move(pos fyne.Position)
- func (o *Shader) Position() fyne.Position
- func (s *Shader) Refresh()
- func (s *Shader) Resize(size fyne.Size)
- func (o *Shader) SetMinSize(size fyne.Size)
- func (o *Shader) Show()
- func (o *Shader) Size() fyne.Size
- func (o *Shader) Visible() bool
- type Shadow
- type ShadowVariant
- type Text
- func (t *Text) Hide()
- func (t *Text) MinSize() fyne.Size
- func (t *Text) Move(pos fyne.Position)
- func (o *Text) Position() fyne.Position
- func (t *Text) Refresh()
- func (t *Text) Resize(s fyne.Size)
- func (t *Text) SetMinSize(fyne.Size)
- func (o *Text) Show()
- func (o *Text) Size() fyne.Size
- func (o *Text) Visible() bool
Constants ¶
const ( // DurationStandard is the time a standard interface animation will run. // // Since: 2.0 DurationStandard = time.Millisecond * 300 // DurationShort is the time a subtle or small transition should use. // // Since: 2.0 DurationShort = time.Millisecond * 150 )
const ( // RadiusMaximum can be applied to a canvas corner radius to achieve fully rounded corners. // This constant represents the maximum possible corner radius, resulting in a circular appearance. // Since: 2.7 RadiusMaximum float32 = math.MaxFloat32 )
Variables ¶
This section is empty.
Functions ¶
func NewColorRGBAAnimation ¶
func NewColorRGBAAnimation(start, stop color.Color, d time.Duration, fn func(color.Color)) *fyne.Animation
NewColorRGBAAnimation sets up a new animation that will transition from the start to stop Color over the specified Duration. The colour transition will move linearly through the RGB colour space. The content of fn should apply the color values to an object and refresh it. You should call Start() on the returned animation to start it.
Since: 2.0
func NewPositionAnimation ¶
func NewPositionAnimation(start, stop fyne.Position, d time.Duration, fn func(fyne.Position)) *fyne.Animation
NewPositionAnimation sets up a new animation that will transition from the start to stop Position over the specified Duration. The content of fn should apply the position value to an object for the change to be visible. You should call Start() on the returned animation to start it.
Since: 2.0
func NewShaderAnimation ¶ added in v2.8.0
NewShaderAnimation sets up a new animation that continuously redraws the given shader, advancing its "time" uniform each frame so the fragment shader can produce motion. You should call Start() on the returned animation to begin and Stop() to freeze the shader at its current frame. Stopping and starting the same animation again resumes from where it left off, without counting the paused time.
Since: 2.8
func NewSizeAnimation ¶
NewSizeAnimation sets up a new animation that will transition from the start to stop Size over the specified Duration. The content of fn should apply the size value to an object for the change to be visible. You should call Start() on the returned animation to start it.
Since: 2.0
func RecolorSVG ¶ added in v2.6.0
RecolorSVG takes a []byte containing SVG content, and returns new SVG content, re-colorized to be monochrome with the given color. The content can be assigned to a new fyne.StaticResource with an appropriate name to be used in a widget.Button, canvas.Image, etc.
If an error occurs, the returned content will be the original un-modified content, and a non-nil error is returned.
Since: 2.6
func Refresh ¶
func Refresh(obj fyne.CanvasObject)
Refresh instructs the containing canvas to refresh the specified obj.
Types ¶
type ArbitraryPolygon ¶ added in v2.8.0
type ArbitraryPolygon struct {
Points []fyne.Position // Vertices in coordinates relative to the object. If NormalizedPoints is true, these are (0.0 to 1.0), otherwise absolute
NormalizedPoints bool // True if Points are specified in normalized coordinates (0.0 to 1.0) relative to the object's size
CornerRadii []float32 // Per-corner rounding radius, must match len(Points), missing entries default to 0
FillColor color.Color // The polygon fill color
StrokeColor color.Color // The polygon stroke color
StrokeWidth float32 // The stroke width of the polygon
// contains filtered or unexported fields
}
ArbitraryPolygon describes a colored arbitrary polygon primitive in a Fyne canvas. The polygon is defined by a list of vertex positions in clockwise order, relative to the object (top-left is (0,0), bottom-right is (width,height)). Each corner can have an individually specified rounding radius. The implementation is limited to 16 vertices.
Since: 2.8
func NewArbitraryPolygon ¶ added in v2.8.0
func NewArbitraryPolygon(points []fyne.Position, fill color.Color) *ArbitraryPolygon
NewArbitraryPolygon returns a new ArbitraryPolygon instance
func (*ArbitraryPolygon) Hide ¶ added in v2.8.0
func (p *ArbitraryPolygon) Hide()
Hide will set this arbitrary polygon to not be visible
func (*ArbitraryPolygon) MinSize ¶ added in v2.8.0
MinSize returns the specified minimum size, if set, or {1, 1} otherwise.
func (*ArbitraryPolygon) Move ¶ added in v2.8.0
func (p *ArbitraryPolygon) Move(pos fyne.Position)
Move the arbitrary polygon to a new position, relative to its parent / canvas
func (*ArbitraryPolygon) Position ¶ added in v2.8.0
Position gets the current position of this canvas object, relative to its parent.
func (*ArbitraryPolygon) Refresh ¶ added in v2.8.0
func (p *ArbitraryPolygon) Refresh()
Refresh causes this arbitrary polygon to be redrawn with its configured state.
func (*ArbitraryPolygon) Resize ¶ added in v2.8.0
func (p *ArbitraryPolygon) Resize(s fyne.Size)
Resize on an arbitrary polygon updates the new size of this object.
func (*ArbitraryPolygon) SetMinSize ¶ added in v2.8.0
SetMinSize specifies the smallest size this object should be.
func (*ArbitraryPolygon) Show ¶ added in v2.8.0
func (o *ArbitraryPolygon) Show()
Show will set this object to be visible.
type Arc ¶ added in v2.7.0
type Arc struct {
FillColor color.Color // The arc fill colour
StartAngle float32 // Start angle in degrees
EndAngle float32 // End angle in degrees
CornerRadius float32 // Radius used to round the corners
StrokeColor color.Color // The arc stroke color
StrokeWidth float32 // The stroke width of the arc
CutoutRatio float32 // Controls what portion of the inner should be cut out. A value of 0.0 results in a pie slice, while 1.0 results in a stroke.
// contains filtered or unexported fields
}
Arc represents a filled arc or annular sector primitive that can be drawn on a Fyne canvas. It allows for the creation of circular, ring-shaped or pie-shaped segment, with configurable cutout ratio as well as customizable start and end angles to define the arc's length as the absolute difference between the two angles. The arc is always centered on its position. The arc is drawn from StartAngle to EndAngle (in degrees, positive is clockwise, negative is counter-clockwise). 0°/360 is top, 90° is right, 180° is bottom, 270° is left 0°/-360 is top, -90° is left, -180° is bottom, -270° is right
Since: 2.7
func NewArc ¶ added in v2.7.0
NewArc returns a new Arc instance with the specified start and end angles (in degrees), fill color and cutout ratio.
func NewDoughnutArc ¶ added in v2.7.0
NewDoughnutArc returns a new doughnut-shaped Arc instance with the specified start and end angles (in degrees), fill color and cutout ratio set to 0.5.
func NewPieArc ¶ added in v2.7.0
NewPieArc returns a new pie-shaped Arc instance with the specified start and end angles (in degrees), fill color and cutout ratio set to 0.
func (*Arc) MinSize ¶ added in v2.7.0
MinSize returns the specified minimum size, if set, or {1, 1} otherwise.
func (*Arc) Move ¶ added in v2.7.0
Move the arc to a new position, relative to its parent / canvas. The position specifies the **center** of the arc.
func (*Arc) Position ¶ added in v2.7.0
Position gets the current position of this canvas object, relative to its parent.
func (*Arc) Refresh ¶ added in v2.7.0
func (a *Arc) Refresh()
Refresh causes this arc to be redrawn with its configured state.
func (*Arc) Resize ¶ added in v2.7.0
Resize updates the logical size of the arc. The arc is always drawn centered on its Position().
func (*Arc) SetMinSize ¶ added in v2.7.0
SetMinSize specifies the smallest size this object should be.
type BezierCurve ¶ added in v2.8.0
type BezierCurve struct {
StartPoint fyne.Position // Starting point of the bezier curve
EndPoint fyne.Position // Ending point of the bezier curve
ControlPoints []fyne.Position // Max 2 control points (0 for linear, 1 for quadratic, 2 for cubic)
StrokeColor color.Color // The bezier curve stroke color
StrokeWidth float32 // The stroke width of the bezier curve
// contains filtered or unexported fields
}
BezierCurve describes a colored bezier curve primitive in a Fyne canvas. It supports linear (0 control point), quadratic (1 control point) and cubic (2 control points) bezier curves. The curve is drawn within the object's position and size, with the start, end, and control points specified relative to the object. Top-left position is (0,0) and bottom-right is (height,width). Increasing the X coordinate moves to the right, increasing the Y coordinate moves downwards. Negative coordinates are not supported.
Since: 2.8
func NewCubicBezierCurve ¶ added in v2.8.0
func NewCubicBezierCurve(startPoint, controlPoint1, controlPoint2, endPoint fyne.Position, color color.Color) *BezierCurve
NewCubicBezierCurve creates a cubic bezier curve with 2 control points
func NewLinearBezierCurve ¶ added in v2.8.0
func NewLinearBezierCurve(startPoint, endPoint fyne.Position, color color.Color) *BezierCurve
NewLinearBezierCurve creates a linear bezier curve with 0 control points
func NewQuadraticBezierCurve ¶ added in v2.8.0
func NewQuadraticBezierCurve(startPoint, controlPoint, endPoint fyne.Position, color color.Color) *BezierCurve
NewQuadraticBezierCurve creates a quadratic bezier curve with 1 control points
func (*BezierCurve) Hide ¶ added in v2.8.0
func (r *BezierCurve) Hide()
Hide will set this bezier curve to not be visible
func (*BezierCurve) MinSize ¶ added in v2.8.0
MinSize returns the specified minimum size, if set, or {1, 1} otherwise.
func (*BezierCurve) Move ¶ added in v2.8.0
func (r *BezierCurve) Move(pos fyne.Position)
Move the bezier curve to a new position, relative to its parent / canvas
func (*BezierCurve) Position ¶ added in v2.8.0
Position gets the current position of this canvas object, relative to its parent.
func (*BezierCurve) Refresh ¶ added in v2.8.0
func (r *BezierCurve) Refresh()
Refresh causes this bezier curve to be redrawn with its configured state.
func (*BezierCurve) Resize ¶ added in v2.8.0
func (r *BezierCurve) Resize(s fyne.Size)
Resize on a bezier curve updates the new size of this object. If it has a stroke width this will cause it to Refresh.
func (*BezierCurve) SetMinSize ¶ added in v2.8.0
SetMinSize specifies the smallest size this object should be.
func (*BezierCurve) Show ¶ added in v2.8.0
func (o *BezierCurve) Show()
Show will set this object to be visible.
type Blur ¶ added in v2.8.0
type Blur struct {
// Radius refers to how far from a point should be used to calculate the blur.
// It must be greater than 0 but no more than 50.
Radius float32
// Radius used to round the corners of the blur region.
CornerRadius float32
// contains filtered or unexported fields
}
Blur creates a rectangular blur region on the output. All objects drawn under this will be blurred, any above will not be affected.
Since: 2.8
func (*Blur) MinSize ¶ added in v2.8.0
MinSize returns the specified minimum size, if set, or {1, 1} otherwise.
func (*Blur) Move ¶ added in v2.8.0
Move the blur to a new position, relative to its parent / canvas
func (*Blur) Position ¶ added in v2.8.0
Position gets the current position of this canvas object, relative to its parent.
func (*Blur) Refresh ¶ added in v2.8.0
func (b *Blur) Refresh()
Refresh causes this blur to be redrawn with its configured state.
func (*Blur) SetMinSize ¶ added in v2.8.0
SetMinSize specifies the smallest size this object should be.
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
// Support shadow configuration
//
// Since: 2.8
Shadow Shadow
}
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 ¶
func (c *Circle) Refresh()
Refresh causes this object to be redrawn with its configured 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 Ellipse ¶ added in v2.8.0
type Ellipse struct {
FillColor color.Color // The ellipse fill color
StrokeColor color.Color // The ellipse stroke color
StrokeWidth float32 // The stroke width of the ellipse
Shadow Shadow // Support shadow configuration
// contains filtered or unexported fields
}
Ellipse describes a colored ellipse primitive in a Fyne canvas with radii being half the width and height of its size.
Since: 2.8
func NewEllipse ¶ added in v2.8.0
NewEllipse returns a new Ellipse instance
func (*Ellipse) Hide ¶ added in v2.8.0
func (e *Ellipse) Hide()
Hide will set this ellipse to not be visible
func (*Ellipse) MinSize ¶ added in v2.8.0
MinSize returns the specified minimum size, if set, or {1, 1} otherwise.
func (*Ellipse) Move ¶ added in v2.8.0
Move the ellipse to a new position, relative to its parent / canvas
func (*Ellipse) Position ¶ added in v2.8.0
Position gets the current position of this canvas object, relative to its parent.
func (*Ellipse) Refresh ¶ added in v2.8.0
func (e *Ellipse) Refresh()
Refresh causes this ellipse to be redrawn with its configured state.
func (*Ellipse) Resize ¶ added in v2.8.0
Resize on a ellipse updates the new size of this object. If it has a stroke width this will cause it to Refresh.
func (*Ellipse) SetMinSize ¶ added in v2.8.0
SetMinSize specifies the smallest size this object should be.
func (*Ellipse) Show ¶ added in v2.8.0
func (o *Ellipse) Show()
Show will set this object to be visible.
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
// CornerRadius specifies a radius to apply to round corners of the image.
//
// Since: 2.7
CornerRadius float32
// 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, 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 NewImageFromReader ¶
NewImageFromReader creates a new image from a data stream. The name parameter is required to uniquely identify this image (for caching etc.). If the image in this io.Reader is an SVG, the name should end ".svg". Images returned from this method will scale to fit the canvas object. The method for scaling can be set using the Fill field.
Since: 2.0
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 NewImageFromURI ¶
NewImageFromURI creates a new image from named resource. File URIs will read the file path and other schemes will download the data into a resource. HTTP and HTTPs URIs will use the GET method by default to request the resource. Images returned from this method will scale to fit the canvas object. The method for scaling can be set using the Fill field.
Since: 2.0
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) Aspect ¶ added in v2.4.0
Aspect will return the original content aspect after it was last refreshed.
Since: 2.4
func (*Image) Move ¶
Move the image object to a new position, relative to its parent top, left corner.
func (*Image) Position ¶
Position gets the current position of this canvas object, relative to its parent.
func (*Image) Refresh ¶
func (i *Image) Refresh()
Refresh causes this image to be redrawn with its configured state.
func (*Image) Resize ¶
Resize on an image will scale the content or reposition it according to FillMode. It will normally cause a Refresh to ensure the pixels are recalculated.
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 // ImageFillCover maintains the image aspect ratio whilst filling the space. // The image content will be centered on the available space meaning that an equal amount of top and bottom // or left and right will be clipped if the output aspect ratio does not match the source image. // Since: 2.7 ImageFillCover )
type ImageScale ¶
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 = iota // ImageScalePixels will scale the image using NearestNeighbor filter (or GL equivalent) ImageScalePixels // ImageScaleFastest will scale the image using hardware GPU if available // // Since: 2.0 ImageScaleFastest )
type Line ¶
type Line struct {
Position1 fyne.Position // The current top-left position of the Line
Position2 fyne.Position // The current bottom-right 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 ¶
func (l *Line) Refresh()
Refresh causes this line to be redrawn with its configured state.
func (*Line) Resize ¶
Resize sets a new bottom-right position for the line object, then it will then be refreshed.
type LinearGradient ¶
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 ¶
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 ¶
func NewLinearGradient(start, end color.Color, angle float64) *LinearGradient
NewLinearGradient creates a linear gradient at 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 ¶
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 ¶
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 ¶
func (g *LinearGradient) Hide()
Hide will set this gradient to not be visible
func (*LinearGradient) MinSize ¶
MinSize returns the specified minimum size, if set, or {1, 1} otherwise.
func (*LinearGradient) Move ¶
func (g *LinearGradient) Move(pos fyne.Position)
Move the gradient to a new position, relative to its parent / canvas
func (*LinearGradient) Position ¶
Position gets the current position of this canvas object, relative to its parent.
func (*LinearGradient) Refresh ¶
func (g *LinearGradient) Refresh()
Refresh causes this gradient to be redrawn with its configured state.
func (*LinearGradient) Resize ¶
func (g *LinearGradient) Resize(size fyne.Size)
Resize resizes the gradient to a new size.
func (*LinearGradient) SetMinSize ¶
SetMinSize specifies the smallest size this object should be.
func (*LinearGradient) Show ¶
func (o *LinearGradient) Show()
Show will set this object to be visible.
type Polygon ¶ added in v2.7.0
type Polygon = RegularPolygon
Polygon describes a colored regular polygon primitive in a Fyne canvas. The rendered portion will be in the center of the available space. Deprecated: Use RegularPolygon instead
Since: 2.7
func NewPolygon ¶ added in v2.7.0
NewPolygon returns a new Polygon instance Deprecated: Use NewRegularPolygon instead
Since: 2.7
type RadialGradient ¶
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 ¶
func NewRadialGradient(start, end color.Color) *RadialGradient
NewRadialGradient creates a new radial gradient.
func (*RadialGradient) Generate ¶
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 ¶
func (g *RadialGradient) Hide()
Hide will set this gradient to not be visible
func (*RadialGradient) MinSize ¶
MinSize returns the specified minimum size, if set, or {1, 1} otherwise.
func (*RadialGradient) Move ¶
func (g *RadialGradient) Move(pos fyne.Position)
Move the gradient to a new position, relative to its parent / canvas
func (*RadialGradient) Position ¶
Position gets the current position of this canvas object, relative to its parent.
func (*RadialGradient) Refresh ¶
func (g *RadialGradient) Refresh()
Refresh causes this gradient to be redrawn with its configured state.
func (*RadialGradient) Resize ¶
func (g *RadialGradient) Resize(size fyne.Size)
Resize resizes the gradient to a new size.
func (*RadialGradient) SetMinSize ¶
SetMinSize specifies the smallest size this object should be.
func (*RadialGradient) Show ¶
func (o *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 ¶
Position gets the current position of this canvas object, relative to its parent.
func (*Raster) Refresh ¶
func (r *Raster) Refresh()
Refresh causes this raster to be redrawn with its configured 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
// The radius of the rectangle corners
//
// Since: 2.4
CornerRadius float32
// Enforce an aspect ratio for the rectangle, the content will be made shorter or narrower
// to meet the requested aspect, if set.
//
// Since: 2.7
Aspect float32
// The radius of the rectangle top-right corner only.
//
// Since: 2.7
TopRightCornerRadius float32
// The radius of the rectangle top-left corner only.
//
// Since: 2.7
TopLeftCornerRadius float32
// The radius of the rectangle bottom-right corner only.
//
// Since: 2.7
BottomRightCornerRadius float32
// The radius of the rectangle bottom-left corner only.
//
// Since: 2.7
BottomLeftCornerRadius float32
// Support shadow configuration
//
// Since: 2.8
Shadow Shadow
// contains filtered or unexported fields
}
Rectangle describes a colored rectangle primitive in a Fyne canvas
func NewRectangle ¶
NewRectangle returns a new Rectangle instance
func NewSquare ¶ added in v2.7.0
NewSquare returns a new Rectangle instance that has a square aspect ratio.
Since: 2.7
func (*Rectangle) MinSize ¶
MinSize returns the specified minimum size, if set, or {1, 1} otherwise.
func (*Rectangle) Position ¶
Position gets the current position of this canvas object, relative to its parent.
func (*Rectangle) Refresh ¶
func (r *Rectangle) Refresh()
Refresh causes this rectangle to be redrawn with its configured 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. If Aspect is non-zero it may cause the rectangle to be smaller than the requested size.
func (*Rectangle) SetMinSize ¶
SetMinSize specifies the smallest size this object should be.
type RegularPolygon ¶ added in v2.8.0
type RegularPolygon struct {
FillColor color.Color // The polygon fill color
StrokeColor color.Color // The polygon stroke color
StrokeWidth float32 // The stroke width of the polygon
CornerRadius float32 // The radius of the polygon corners
Angle float32 // Angle of polygon, in degrees (positive means clockwise, negative means counter-clockwise direction).
Sides uint // Amount of sides of polygon.
// contains filtered or unexported fields
}
RegularPolygon describes a colored regular polygon primitive in a Fyne canvas. The rendered portion will be in the center of the available space.
Since: 2.8
func NewRegularPolygon ¶ added in v2.8.0
func NewRegularPolygon(sides uint, color color.Color) *RegularPolygon
NewRegularPolygon returns a new RegularPolygon instance
Since: 2.8
func (*RegularPolygon) Hide ¶ added in v2.8.0
func (r *RegularPolygon) Hide()
Hide will set this polygon to not be visible
func (*RegularPolygon) MinSize ¶ added in v2.8.0
MinSize returns the specified minimum size, if set, or {1, 1} otherwise.
func (*RegularPolygon) Move ¶ added in v2.8.0
func (r *RegularPolygon) Move(pos fyne.Position)
Move the polygon to a new position, relative to its parent / canvas
func (*RegularPolygon) Position ¶ added in v2.8.0
Position gets the current position of this canvas object, relative to its parent.
func (*RegularPolygon) Refresh ¶ added in v2.8.0
func (r *RegularPolygon) Refresh()
Refresh causes this polygon to be redrawn with its configured state.
func (*RegularPolygon) Resize ¶ added in v2.8.0
func (r *RegularPolygon) Resize(s fyne.Size)
Resize on a polygon updates the new size of this object. If it has a stroke width this will cause it to Refresh.
func (*RegularPolygon) SetMinSize ¶ added in v2.8.0
SetMinSize specifies the smallest size this object should be.
func (*RegularPolygon) Show ¶ added in v2.8.0
func (o *RegularPolygon) Show()
Show will set this object to be visible.
type Shader ¶ added in v2.8.0
type Shader struct {
// Name identifies this shader. Shaders that share a Name may share a
// compiled program, so it should be unique per distinct shader source.
Name string
// Source is the GLSL fragment shader used on desktop OpenGL (core profile).
Source []byte
// SourceES is the GLSL fragment shader used on OpenGL ES, mobile and web.
SourceES []byte
// Textures supplies named images to the shader. Each entry is uploaded to
// the GPU and exposed to the fragment shader as a "uniform sampler2D <name>".
// Images are uploaded once and reused; replacing an entry with a different
// image updates the GPU copy on the next paint, so static textures cost
// nothing per frame.
Textures map[string]image.Image
// Uniforms supplies named scalar values to the shader, each exposed to the
// fragment shader as a "uniform float <name>". They are applied every paint,
// so an application can drive a shader's parameters - for example animating a
// transition - by updating an entry and calling Refresh. The "time" entry is
// supplied by NewShaderAnimation while a shader is animating; setting it
// directly lets a static shader pick an arbitrary frame.
Uniforms map[string]float32
// contains filtered or unexported fields
}
Shader describes a canvas object that is drawn using a custom GLSL fragment shader. The shader is rendered inside the object's bounds, respecting the position and size set on it just like any other canvas primitive.
The supplied fragment shader must follow the same conventions as Fyne's internal vector shaders. It is provided with the following uniforms:
uniform vec2 frame; // the size of the output frame, in pixels uniform vec4 bounds; // this object's bounds (x1, y1, x2, y2), in pixels uniform float time; // elapsed animation time in seconds (see NewShaderAnimation)
and should compute its color from gl_FragCoord, as the built-in shapes do. Any images set in Textures are additionally exposed as "uniform sampler2D" values, and any values in Uniforms as "uniform float", named by their map key.
Two source variants are held so that the object renders on both desktop OpenGL (core profile) and OpenGL ES / mobile / web targets.
Since: 2.8
func NewShader ¶ added in v2.8.0
NewShader returns a new Shader instance using the specified fragment shader sources. The name should uniquely identify the shader, source is used on desktop (OpenGL core profile) and sourceES is used on mobile and web targets.
Since: 2.8
func (*Shader) Hide ¶ added in v2.8.0
func (s *Shader) Hide()
Hide will set this shader to not be visible.
func (*Shader) MinSize ¶ added in v2.8.0
MinSize returns the specified minimum size, if set, or {1, 1} otherwise.
func (*Shader) Move ¶ added in v2.8.0
Move the shader object to a new position, relative to its parent / canvas.
func (*Shader) Position ¶ added in v2.8.0
Position gets the current position of this canvas object, relative to its parent.
func (*Shader) Refresh ¶ added in v2.8.0
func (s *Shader) Refresh()
Refresh causes this shader to be redrawn with its current state.
func (*Shader) SetMinSize ¶ added in v2.8.0
SetMinSize specifies the smallest size this object should be.
func (*Shader) Show ¶ added in v2.8.0
func (o *Shader) Show()
Show will set this object to be visible.
type Shadow ¶ added in v2.8.0
type Shadow struct {
Color color.Color // Color of the shadow.
BlurRadius float32 // A value of 0 produces no blur, while larger values produce bigger and lighter shadow.
Spread float32 // Spread of the shadow (how far out to draw before fading - negative values make it smaller).
Offset fyne.Position // Offset of the shadow relative to the content. Positive values move the shadow to the right (x) and down (y) of the element.
Variant ShadowVariant // Variation of shadow (DropShadow or BoxShadow).
}
Shadow provides base functionality for objects that can have a Shadow. Intended to be embedded in other structs to add Shadow support.
Since: 2.8
type ShadowVariant ¶ added in v2.8.0
type ShadowVariant int
ShadowVariant indicates a variation of a shadow.
Since: 2.8
const ( // DropShadow represents a shadow effect that is rendered exclusively outside the boundaries of the object, // following the object's shape and not appearing beneath its filled area. // // Since: 2.8 DropShadow ShadowVariant = iota // BoxShadow represents a shadow effect that is rendered both behind and outside the object, // appearing as a blurred rectangle that extends beneath the object's filled area as well as beyond its edges. // // Since: 2.8 BoxShadow )
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 float32 // 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
// FontSource defines a resource that can be used instead of the theme for looking up the font.
// When a font source is set the `TextStyle` may not be effective, as it will be limited to the styles
// present in the data provided.
//
// Since: 2.5
FontSource fyne.Resource
// 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 ¶
Position gets the current position of this canvas object, relative to its parent.
func (*Text) Refresh ¶
func (t *Text) Refresh()
Refresh causes this text to be redrawn with its configured state.
func (*Text) Resize ¶
Resize on a text updates the new size of this object, which may not result in a visual change, depending on alignment.
func (*Text) SetMinSize ¶
SetMinSize has no effect as the smallest size this canvas object can be is based on its font size and content.