zoomimage

package
v0.0.0-...-0e08d8a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 21, 2026 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ImCenter

func ImCenter(im image.Image) (int, int)

helper function to get the center of an image

func PositionDelta

func PositionDelta(a, b fyne.Position) (float32, float32)

Calculate a-b and return the components

Types

type ImageElement

type ImageElement struct {
	image.Image //we will wrap an image
}

func NewImageElement

func NewImageElement(im image.Image) *ImageElement

func (*ImageElement) Contains

func (ie *ImageElement) Contains(x, y int) bool

Add Contains so we implement ZIElement

func (*ImageElement) Fixed

func (_ *ImageElement) Fixed() bool

func (*ImageElement) RegisterParent

func (_ *ImageElement) RegisterParent(_ *ZoomImage)

type ScaleElement

type ScaleElement struct {
	Center [2]int //center of the rectangle
	Size   [2]int //x and y size
	Color  color.Color
	Parent *ZoomImage
}

type for rendering a scalebar

func NewScaleElement

func NewScaleElement(length int, imsize [2]int, color color.Color) *ScaleElement

make a new ScaleElement

func (*ScaleElement) At

func (re *ScaleElement) At(x, y int) color.Color

func (*ScaleElement) Contains

func (re *ScaleElement) Contains(x, y int) bool

func (*ScaleElement) ContainsScalebar

func (re *ScaleElement) ContainsScalebar(x, y int) bool

separating this out so it can be called on a 'orphan' scaleelement

func (*ScaleElement) Fixed

func (re *ScaleElement) Fixed() bool

func (*ScaleElement) RegisterParent

func (se *ScaleElement) RegisterParent(zi *ZoomImage)

type SelectionBox

type SelectionBox struct {
	P     [2]fyne.Position
	Lines [4]*canvas.Line
}

A SelectionBox is four [fyne.canvas.Line]s The lines will form the box starting at the top left and going counterclockwise. P[0] is the top

func NewSelectionBox

func NewSelectionBox(color color.Color, strokewidth float32) *SelectionBox

Make a new SelectionBox

func (*SelectionBox) Refresh

func (sb *SelectionBox) Refresh()

func (*SelectionBox) SetEnd

func (sb *SelectionBox) SetEnd(p fyne.Position)

Set the end position of a SelectionBox

func (*SelectionBox) SetStart

func (sb *SelectionBox) SetStart(p fyne.Position)

Set the start position of a SelectionBox

func (*SelectionBox) SetVisible

func (sb *SelectionBox) SetVisible(vis bool)

Change the visibility of a SelectionBox

type ZIElement

type ZIElement interface {
	Contains(x, y int) bool //does this element contain this pixel
	At(x, y int) color.Color
	Fixed() bool               //should this element be fixed to the window
	RegisterParent(*ZoomImage) //This will be called when this element is added to a ZoomWindow
}

interface for elements that we can overlay in a zoomimage

type ZoomImage

type ZoomImage struct {
	*canvas.Raster
	Selection *SelectionBox
	Status    *ZoomStatus
	Elements  *[]ZIElement

	ImSize [2]int //need to know the size of the image
	Canvas fyne.Canvas
	BaseIm *ImageElement
	// contains filtered or unexported fields
}

ZoomImage will embed a canvas.Raster to render and will keep track of its zoom and pan status

func NewZoomImage

func NewZoomImage(im image.Image, ourcanvas fyne.Canvas, selectioncolor color.Color, selectionstroke float32) *ZoomImage

func (*ZoomImage) AddElement

func (zi *ZoomImage) AddElement(e ZIElement)

add a ZIElement to a ZoomImage

func (*ZoomImage) AddScalebar

func (zi *ZoomImage) AddScalebar(length int, color color.Color)

add a scalebar to a ZoomImage

func (*ZoomImage) CreateRenderer

func (zi *ZoomImage) CreateRenderer() fyne.WidgetRenderer

func (*ZoomImage) CurrentSelection

func (zi *ZoomImage) CurrentSelection() [2][2]int

Get the current selection in terms of indices into the image we are viewing This will return a 2d array where a[0] is the start and end indices in the x direction and a[1] is the start and end indices in the y direction

func (*ZoomImage) MouseDown

func (zi *ZoomImage) MouseDown(me *desktop.MouseEvent)

func (*ZoomImage) MouseIn

func (zi *ZoomImage) MouseIn(_ *desktop.MouseEvent)

func (*ZoomImage) MouseMoved

func (zi *ZoomImage) MouseMoved(me *desktop.MouseEvent)

func (*ZoomImage) MouseOut

func (zi *ZoomImage) MouseOut()

func (*ZoomImage) MouseUp

func (zi *ZoomImage) MouseUp(_ *desktop.MouseEvent)

func (*ZoomImage) RefreshRaster

func (zi *ZoomImage) RefreshRaster()

update the raster generate func (to account for new ZIElements)

type ZoomStatus

type ZoomStatus struct {
	Zoom int
	//float so we don't get truncation error when working with [fyne.Position]
	PanX, PanY float32
}

We want zoomposition to be its own object so we can share it with our render function

func NewZoomStatus

func NewZoomStatus() *ZoomStatus

func (*ZoomStatus) SetPan

func (zs *ZoomStatus) SetPan(x, y float32)

func (*ZoomStatus) SetZoom

func (zs *ZoomStatus) SetZoom(z int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL