painter

package
v2.7.3 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: BSD-3-Clause Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultTabWidth is the default width in spaces
	DefaultTabWidth = 4
)

Variables

This section is empty.

Functions

func ClearFontCache

func ClearFontCache()

ClearFontCache is used to remove cached fonts in the case that we wish to re-load Font faces

func DrawArc added in v2.7.0

func DrawArc(arc *canvas.Arc, vectorPad float32, scale func(float32) float32) *image.RGBA

DrawArc rasterizes the given arc object into an image. The scale function is used to understand how many pixels are required per unit of size. The arc is drawn from StartAngle to EndAngle (in degrees). 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

func DrawCircle

func DrawCircle(circle *canvas.Circle, vectorPad float32, scale func(float32) float32) *image.RGBA

DrawCircle rasterizes the given circle object into an image. The bounds of the output image will be increased by vectorPad to allow for stroke overflow at the edges. The scale function is used to understand how many pixels are required per unit of size.

func DrawLine

func DrawLine(line *canvas.Line, vectorPad float32, scale func(float32) float32) *image.RGBA

DrawLine rasterizes the given line object into an image. The bounds of the output image will be increased by vectorPad to allow for stroke overflow at the edges. The scale function is used to understand how many pixels are required per unit of size.

func DrawPolygon added in v2.7.0

func DrawPolygon(polygon *canvas.Polygon, vectorPad float32, scale func(float32) float32) *image.RGBA

DrawPolygon rasterizes the given regular polygon object into an image. The bounds of the output image will be increased by vectorPad to allow for stroke overflow at the edges. The scale function is used to understand how many pixels are required per unit of size.

func DrawRectangle

func DrawRectangle(rect *canvas.Rectangle, rWidth, rHeight, vectorPad float32, scale func(float32) float32) *image.RGBA

DrawRectangle rasterizes the given rectangle object with stroke border into an image. The bounds of the output image will be increased by vectorPad to allow for stroke overflow at the edges. The scale function is used to understand how many pixels are required per unit of size.

func DrawString added in v2.2.0

func DrawString(dst draw.Image, s string, color color.Color, f shaping.Fontmap, fontSize, scale float32, style fyne.TextStyle)

DrawString draws a string into an image.

func GetCornerRadius added in v2.7.0

func GetCornerRadius(perCornerRadius, baseCornerRadius float32) float32

GetCornerRadius returns the effective corner radius for a rectangle or square corner. If the specific corner radius (perCornerRadius) is zero, it falls back to the baseCornerRadius. Otherwise, it uses the specific corner radius provided.

This allows for per-corner customization while maintaining a default overall radius.

func GetMaximumCornerRadius added in v2.7.0

func GetMaximumCornerRadius(radius, adjacentWidthRadius, adjacentHeightRadius float32, size fyne.Size) float32

GetMaximumCornerRadius returns the maximum possible corner radius for an individual corner, considering the specified corner radius, the radii of adjacent corners, and the maximum radii allowed for the width and height of the shape. Corner radius may utilize unused capacity from adjacent corners with radius smaller than maximum value so this corner can grow up to double the maximum radius of the smaller dimension (width or height) without causing overlaps.

This is typically used for drawing circular corners in rectangles or squares with different corner radii.

func GetMaximumRadius added in v2.7.0

func GetMaximumRadius(size fyne.Size) float32

GetMaximumRadius returns the maximum possible corner radius that fits within the given size. It calculates half of the smaller dimension (width or height) of the provided fyne.Size.

This is typically used for drawing circular corners in rectangles, circles or squares with the same radius for all corners.

func GetMaximumRadiusArc added in v2.7.0

func GetMaximumRadiusArc(outerRadius, innerRadius, sweepAngle float32) float32

GetMaximumRadiusArc returns the maximum possible corner radius for an arc segment based on the outer radius, inner radius, and sweep angle in degrees. It calculates half of the smaller dimension (thickness or effective length) of the provided arc parameters

func MeasureString added in v2.1.0

func MeasureString(f shaping.Fontmap, s string, textSize float32, style fyne.TextStyle) (size fyne.Size, advance float32)

MeasureString returns how far dot would advance by drawing s with f. Tabs are translated into a dot location change.

func NormalizeArcAngles added in v2.7.0

func NormalizeArcAngles(startAngle, endAngle float32) (float32, float32)

NormalizeArcAngles adjusts the given start and end angles for arc drawing. It converts the angles from the Unit circle coordinate system (where 0 degrees is along the positive X-axis) to the coordinate system used by the painter, where 0 degrees is at the top (12 o'clock position). The function also reverses the direction: positive is clockwise, negative is counter-clockwise

func PaintImage

func PaintImage(img *canvas.Image, c fyne.Canvas, width, height int) image.Image

PaintImage renders a given fyne Image to a Go standard image If a fyne.Canvas is given and the image’s fill mode is “fill original” the image’s min size has to fit its original size. If it doesn’t, PaintImage does not paint the image but adjusts its min size. The image will then be painted on the next frame because of the min size change.

func RenderedTextSize

func RenderedTextSize(text string, fontSize float32, style fyne.TextStyle, source fyne.Resource) (size fyne.Size, baseline float32)

RenderedTextSize looks up how big a string would be if drawn on screen. It also returns the distance from top to the text baseline.

func VectorPad

func VectorPad(obj fyne.CanvasObject) float32

VectorPad returns the number of additional points that should be added around a texture. This is to accommodate overflow caused by stroke and line endings etc. THe result is in fyne.Size type coordinates and should be scaled for output.

Types

type FontCacheItem added in v2.4.0

type FontCacheItem struct {
	Fonts shaping.Fontmap
}

func CachedFontFace

func CachedFontFace(style fyne.TextStyle, source fyne.Resource, o fyne.CanvasObject) *FontCacheItem

CachedFontFace returns a Font face held in memory. These are loaded from the current theme.

Directories

Path Synopsis
Package gl provides a full Fyne render implementation using system OpenGL libraries.
Package gl provides a full Fyne render implementation using system OpenGL libraries.

Jump to

Keyboard shortcuts

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