Upgrade to v2.7 Fyne API v2.7
package fyne Animation Animation AnimationCurve AnimationCurve App App AppMetadata AppMetadata BuildType BuildType Canvas Canvas CanvasObject CanvasObject Clipboard Clipboard CloudProvider CloudProvider CloudProviderPreferences CloudProviderPreferences CloudProviderStorage CloudProviderStorage Container Container Delta Delta Device Device DeviceOrientation DeviceOrientation Disableable Disableable DoubleTappable DoubleTappable DragEvent DragEvent Draggable Draggable Driver Driver Focusable Focusable HardwareKey HardwareKey KeyboardShortcut KeyboardShortcut KeyEvent KeyEvent KeyModifier KeyModifier KeyName KeyName Layout Layout LegacyTheme LegacyTheme Lifecycle Lifecycle ListableURI ListableURI Locale Locale MainMenu MainMenu Menu Menu MenuItem MenuItem Notification Notification OverlayStack OverlayStack PointEvent PointEvent Position Position Preferences Preferences Resource Resource Scrollable Scrollable ScrollDirection ScrollDirection ScrollEvent ScrollEvent SecondaryTappable SecondaryTappable Settings Settings Shortcut Shortcut Shortcutable Shortcutable ShortcutCopy ShortcutCopy ShortcutCut ShortcutCut ShortcutHandler ShortcutHandler ShortcutPaste ShortcutPaste ShortcutRedo ShortcutRedo ShortcutSelectAll ShortcutSelectAll ShortcutUndo ShortcutUndo Size Size StaticResource StaticResource Storage Storage StringValidator StringValidator Tabbable Tabbable Tappable Tappable TextAlign TextAlign TextStyle TextStyle TextTruncation TextTruncation TextWrap TextWrap Theme Theme ThemeColorName ThemeColorName ThemedResource ThemedResource ThemeIconName ThemeIconName ThemeSizeName ThemeSizeName ThemeVariant ThemeVariant URI URI URIReadCloser URIReadCloser URIWithIcon URIWithIcon URIWriteCloser URIWriteCloser Validatable Validatable Vector2 Vector2 Widget Widget WidgetRenderer WidgetRenderer Window Window
app canvas container data/binding data/validation dialog driver driver/desktop driver/embedded driver/mobile driver/software lang layout storage storage/repository test theme widget

Fyne API "fyne.Position"

fyne.Position


import "fyne.io/fyne/v2"

Usage

type Position

type Position struct {
	X float32 // The position from the parent's left edge
	Y float32 // The position from the parent's top edge
}

Position describes a generic X, Y coordinate relative to a parent [Canvas] or [CanvasObject].

func NewPos

func NewPos(x float32, y float32) Position

NewPos returns a newly allocated [Position] representing the specified coordinates.

func NewSquareOffsetPos

func NewSquareOffsetPos(length float32) Position

NewSquareOffsetPos returns a newly allocated [Position] with the same x and y position.

Since: 2.4

func (Position) Add

func (p Position) Add(v Vector2) Position

Add returns a new [Position] that is the result of offsetting the current position by p2 X and Y.

func (Position) AddXY

func (p Position) AddXY(x, y float32) Position

AddXY returns a new [Position] by adding x and y to the current one.

func (Position) Components

func (p Position) Components() (float32, float32)

Components returns the X and Y elements of p.

func (Position) IsZero

func (p Position) IsZero() bool

IsZero returns whether the Position is at the zero-point.

func (Position) Subtract

func (p Position) Subtract(v Vector2) Position

Subtract returns a new [Position] that is the result of offsetting the current position by p2 -X and -Y.

func (Position) SubtractXY

func (p Position) SubtractXY(x, y float32) Position

SubtractXY returns a new [Position] by subtracting x and y from the current one.