util

package
v0.0.0-...-2adf51d Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2024 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Width4K  = 3840            // 4K resolution
	Height4K = 2160            // 4K resolution
	ToRad    = math.Pi / 180.0 // Degrees to Radians
)
View Source
const (
	TestCardBasePriority   = 1100 // TestCards background
	TestCardLowerPriority  = 1125 // TestCards mid-ground
	TestCardUpperPriority  = 1175 // TestCards mid-ground
	TestCardTopPriority    = 1199 // TestCards foreground
	DialBackgroundPriority = 2000 // Clock dial background
	ClockPriority          = 2040 // Countdown Clock
	DialForegroundPriority = 2050 // Clock dial foreground
	TitlePriority          = 2100 // Title
	BoxPriority            = 3000 // Box and derivatives if not implicitly defined
)

Renderer priorities

Variables

This section is empty.

Functions

func DrawColourBars

func DrawColourBars(gc *draw2dimg.GraphicContext, bounds Rectangle, cols ...color.Color) (float64, float64)

func DrawColourBarsVertical

func DrawColourBarsVertical(gc *draw2dimg.GraphicContext, bounds Rectangle, cols ...color.Color) (float64, float64)

func DrawStringCenter

func DrawStringCenter(gc *draw2dimg.GraphicContext, x, y float64, s string, a ...interface{}) float64

func DrawStringLeft

func DrawStringLeft(gc *draw2dimg.GraphicContext, x, y float64, s string, a ...interface{}) float64

func DrawStringRight

func DrawStringRight(gc *draw2dimg.GraphicContext, x, y float64, s string, a ...interface{}) float64

func FitString

func FitString(l, t, r, b, sl, st, sr, sb float64) (float64, float64, float64, float64)

func FloatToA

func FloatToA(v float64) string

func Limit

func Limit(d, a, b int) int

Limit limits d so it lies within a and b inclusively.

func LimitU16

func LimitU16(d int) uint16

LimitU16 limits d within 0...65535

func LimitU32

func LimitU32(d int) uint32

LimitU32 is identical to LimitU16 but used as image.RGBA uses uint32 with uint16 limits

func LimitU8

func LimitU8(d int) uint8

LimitU8 limits d within 0...255

func Max

func Max(a, b int) int

func MaxSlice

func MaxSlice(a []uint32) uint32

MaxSlice returns the max values for a slice

func MaxU32

func MaxU32(a, b uint32) uint32

func MaxU8

func MaxU8(a, b uint8) uint8

func Min

func Min(a, b int) int

func MinMax

func MinMax(a []uint32) (uint32, uint32)

MinMax returns the min and max values for a slice

func MinU32

func MinU32(a, b uint32) uint32

func MinU8

func MinU8(a, b uint8) uint8

func Within

func Within(frame, start, end int) bool

Within returns true if frame is within start...end inclusively

Types

type Alignment

type Alignment uint8
const (
	LeftAlignment Alignment = iota
	CenterAlignment
	RightAlignment
)

func (Alignment) Fill

func (a Alignment) Fill(gc *draw2dimg.GraphicContext, bounds image.Rectangle, lineSpacing float64, format string, args ...interface{}) float64

Fill fills the provided string based on this Alignment. If the string contains "\n" then it will be split and rendered as multiple lines.

gc GraphicContext to draw to bounds image.Rectangle of the area to contain the string lineSpacing space to add between lines format,args passed to fmt.Sprintf() before rendering

func (Alignment) FillStroke

func (a Alignment) FillStroke(gc *draw2dimg.GraphicContext, bounds image.Rectangle, lineSpacing float64, format string, args ...interface{}) float64

FillStroke fills then strokes the string based on this Alignment. If the string contains "\n" then it will be split and rendered as multiple lines.

gc GraphicContext to draw to bounds image.Rectangle of the area to contain the string lineSpacing space to add between lines format,args passed to fmt.Sprintf() before rendering

func (Alignment) Metrics

func (a Alignment) Metrics(gc *draw2dimg.GraphicContext, bounds image.Rectangle, lineSpacing float64, format string, args ...interface{}) *AlignmentMetrics

func (Alignment) Stroke

func (a Alignment) Stroke(gc *draw2dimg.GraphicContext, bounds image.Rectangle, lineSpacing float64, format string, args ...interface{}) float64

Stroke the string based on this Alignment. If the string contains "\n" then it will be split and rendered as multiple lines.

gc GraphicContext to draw to bounds image.Rectangle of the area to contain the string lineSpacing space to add between lines format,args passed to fmt.Sprintf() before rendering

type AlignmentMetrics

type AlignmentMetrics struct {
	Bounds        image.Rectangle // Bounds of container
	ContentBounds image.Rectangle // Bounds of string within container
	MaxLineHeight float64         // Max line height over all lines
	MaxLineWidth  float64         // Max width of all lines
	BaseLines     []float64       // baseline for each line
	Widths        []float64       // Width of each line
	Lines         []string        // Line strings
	// contains filtered or unexported fields
}

func (*AlignmentMetrics) Fill

Fill fills the string defined in this AlignmentMetrics into the supplied GraphicContext

func (*AlignmentMetrics) FillStroke

func (m *AlignmentMetrics) FillStroke(gc *draw2dimg.GraphicContext) float64

FillStroke first fills then strokes the string defined in this AlignmentMetrics into the supplied GraphicContext

func (*AlignmentMetrics) Merge

func (m *AlignmentMetrics) Merge(b *AlignmentMetrics)

Merge ensures that the line heights of both sets of metrics are the same. This is useful for when two sets need to line up with each other

func (*AlignmentMetrics) Stroke

Stroke the string defined in this AlignmentMetrics into the supplied GraphicContext

type Rectangle

type Rectangle struct {
	X1, Y1, X2, Y2 float64
}

func GetStringBounds

func GetStringBounds(gc *draw2dimg.GraphicContext, s string) Rectangle

func Rect

func Rect(x1, y1, x2, y2 float64) Rectangle

func RectFromRect

func RectFromRect(rect image.Rectangle) Rectangle

func StringSize

func StringSize(gc *draw2dimg.GraphicContext, s string, a ...interface{}) Rectangle

func (Rectangle) Add

func (r Rectangle) Add(b Rectangle) Rectangle

Add returns a Rectangle that contains both rectangles

func (Rectangle) AddPath

func (r Rectangle) AddPath(ctx draw2d.GraphicContext)

func (Rectangle) Expand

func (r Rectangle) Expand(l, t, right, b float64) Rectangle

func (Rectangle) Height

func (r Rectangle) Height() float64

func (Rectangle) IsZero

func (r Rectangle) IsZero() bool

func (Rectangle) Rect

func (r Rectangle) Rect() image.Rectangle

func (Rectangle) Reduce

func (r Rectangle) Reduce(l, t, right, b float64) Rectangle

func (Rectangle) String

func (r Rectangle) String() string

func (Rectangle) Width

func (r Rectangle) Width() float64

Directories

Path Synopsis
goexr
exr
Package exr contains an implementation of an OpenEXR image decoder.
Package exr contains an implementation of an OpenEXR image decoder.
Package units defines units of length such as inches or pixels.
Package units defines units of length such as inches or pixels.

Jump to

Keyboard shortcuts

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