avyos.dev/pkg/graphics
package graphics
Package Overview
No package-level documentation is provided.
| Export Group | Count |
|---|---|
| Constants | 6 |
| Variables | 8 |
| Functions | 3 |
| Types | 17 |
Constants
const (
PixelFormatBGRA = gfxcore.PixelFormatBGRA
PixelFormatRGBA = gfxcore.PixelFormatRGBA
PixelFormatRGB565 = gfxcore.PixelFormatRGB565
)const (
UIFontParagraph = "paragraph"
UIFontSubheading = "subheading"
UIFontHeading = "heading"
UIFontTitle = "title"
)const (
EventNone = gfxinput.EventNone
EventMouseMove = gfxinput.EventMouseMove
EventMouseButtonPress = gfxinput.EventMouseButtonPress
EventMouseButtonRelease = gfxinput.EventMouseButtonRelease
EventKeyPress = gfxinput.EventKeyPress
EventKeyRelease = gfxinput.EventKeyRelease
EventFocusIn = gfxinput.EventFocusIn
EventFocusOut = gfxinput.EventFocusOut
EventQuit = gfxinput.EventQuit
EventResize = gfxinput.EventResize
EventShortcut = gfxinput.EventShortcut
)const (
MouseButtonNone = gfxinput.MouseButtonNone
MouseButtonLeft = gfxinput.MouseButtonLeft
MouseButtonMiddle = gfxinput.MouseButtonMiddle
MouseButtonRight = gfxinput.MouseButtonRight
MouseButtonWheelUp = gfxinput.MouseButtonWheelUp
MouseButtonWheelDown = gfxinput.MouseButtonWheelDown
MouseButtonWheelLeft = gfxinput.MouseButtonWheelLeft
MouseButtonWheelRight = gfxinput.MouseButtonWheelRight
)const (
KeyNone = gfxinput.KeyNone
KeyEscape = gfxinput.KeyEscape
KeyBackspace = gfxinput.KeyBackspace
KeyTab = gfxinput.KeyTab
KeyEnter = gfxinput.KeyEnter
KeySpace = gfxinput.KeySpace
KeyLeft = gfxinput.KeyLeft
KeyRight = gfxinput.KeyRight
KeyUp = gfxinput.KeyUp
KeyDown = gfxinput.KeyDown
KeyHome = gfxinput.KeyHome
KeyEnd = gfxinput.KeyEnd
KeyPageUp = gfxinput.KeyPageUp
KeyPageDown = gfxinput.KeyPageDown
KeyInsert = gfxinput.KeyInsert
KeyDelete = gfxinput.KeyDelete
KeyF1 = gfxinput.KeyF1
KeyF2 = gfxinput.KeyF2
KeyF3 = gfxinput.KeyF3
KeyF4 = gfxinput.KeyF4
KeyF5 = gfxinput.KeyF5
KeyF6 = gfxinput.KeyF6
KeyF7 = gfxinput.KeyF7
KeyF8 = gfxinput.KeyF8
KeyF9 = gfxinput.KeyF9
KeyF10 = gfxinput.KeyF10
KeyF11 = gfxinput.KeyF11
KeyF12 = gfxinput.KeyF12
KeyLeftShift = gfxinput.KeyLeftShift
KeyRightShift = gfxinput.KeyRightShift
KeyLeftCtrl = gfxinput.KeyLeftCtrl
KeyRightCtrl = gfxinput.KeyRightCtrl
KeyLeftAlt = gfxinput.KeyLeftAlt
KeyRightAlt = gfxinput.KeyRightAlt
KeyCapsLock = gfxinput.KeyCapsLock
KeyNumLock = gfxinput.KeyNumLock
KeyScrollLock = gfxinput.KeyScrollLock
)const (
ModShift = gfxinput.ModShift
ModCtrl = gfxinput.ModCtrl
ModAlt = gfxinput.ModAlt
ModCapsLock = gfxinput.ModCapsLock
)Variables
var (
ColorBlack = gfxcore.ColorBlack
ColorWhite = gfxcore.ColorWhite
ColorRed = gfxcore.ColorRed
ColorGreen = gfxcore.ColorGreen
ColorBlue = gfxcore.ColorBlue
ColorGray = gfxcore.ColorGray
ColorLightGray = gfxcore.ColorLightGray
ColorDarkGray = gfxcore.ColorDarkGray
ColorTransparent = gfxcore.ColorTransparent
NewColor = gfxcore.NewColor
NewColorRGB = gfxcore.NewColorRGB
NewColorHex = gfxcore.NewColorHex
NewRect = gfxcore.NewRect
NewBuffer = gfxcore.NewBuffer
)var AvyosDark = gfxtheme.AvyosDarkvar AvyosLight = gfxtheme.AvyosLightvar BitmapFont = &Font{
Width: 8,
Height: 16,
FirstRun: 32,
LastRun: 126,
Glyphs: defaultGlyphs,
}BitmapFont is the built-in 8x16 bitmap font.
var DefaultFont = BitmapFontDefaultFont is the active font used by graphics and UI.
var DefaultTheme = gfxtheme.AvyosLightvar MayurDark = AvyosDarkvar MayurLight = AvyosLightBackwards-compatible aliases.
Functions
func ResolveIconPath(name string, size int) stringResolveIconPath returns the best icon file path for name+size. Falls back to help.{svg,png} if the requested icon is missing.
func SetUIFont(role string, font *Font)SetUIFont sets a font for a logical UI text role.
func SetUIFonts(fonts map[string]*Font)SetUIFonts sets multiple UI role fonts at once.
Types
Backend
type Backend = gfxinput.BackendBaseWidget
type BaseWidget struct {
// contains filtered or unexported fields
}BaseWidget provides common functionality for widgets.
Functions
func NewBaseWidget() BaseWidgetNewBaseWidget creates a new base widget.
Methods
func (w *BaseWidget) Bounds() RectBounds returns the widget's bounds.
func (w *BaseWidget) IsDirty() boolIsDirty returns true if the widget needs to be redrawn.
func (w *BaseWidget) IsFocused() boolIsFocused returns true if the widget has focus.
func (w *BaseWidget) IsVisible() boolIsVisible returns true if the widget is visible.
func (w *BaseWidget) MarkClean()MarkClean marks the widget as not needing a redraw.
func (w *BaseWidget) MarkDirty()MarkDirty marks the widget as needing a redraw.
func (w *BaseWidget) MinSize() PointMinSize returns the minimum size the widget needs.
func (w *BaseWidget) SelfDirty() boolSelfDirty returns true if the widget itself needs a redraw. Containers can use this to distinguish their own dirty state from children.
func (w *BaseWidget) SetBounds(r Rect)SetBounds sets the widget's bounds.
func (w *BaseWidget) SetFocused(focused bool)SetFocused sets the focus state of the widget.
func (w *BaseWidget) SetMinSize(size Point)SetMinSize sets the minimum size for the widget.
func (w *BaseWidget) SetVisible(visible bool)SetVisible sets the visibility of the widget.
Buffer
type Buffer = gfxcore.BufferFunctions
func DecodeImageToBuffer(path string, reqSize int) (*Buffer, error)DecodeImageToBuffer decodes raster formats directly and rasterizes SVG files. reqSize is used for SVG rasterization. If <= 0, a size is inferred from SVG metadata.
func LoadIcon(name string, size int) (*Buffer, error)LoadIcon loads an icon by name and size as a graphics.Buffer.
Color
type Color = gfxcore.ColorEvent
type Event = gfxinput.EventEventType
type EventType = gfxinput.EventTypeFont
type Font struct {
Width int
Height int
Glyphs map[rune][]byte
FirstRun rune
LastRun rune
// contains filtered or unexported fields
}Font represents either a bitmap font or a vector TTF-backed font.
Functions
func LoadTTFFont(ttf []byte, opts *gfxfont.Options) (*Font, error)LoadTTFFont creates a graphics.Font from raw TTF bytes.
func LoadTTFFontFile(path string, opts *gfxfont.Options) (*Font, error)LoadTTFFontFile creates a graphics.Font from a TTF file path.
func NewDefaultTTFFont(opts *gfxfont.Options) (*Font, error)NewDefaultTTFFont creates a graphics.Font using gofont/goregular.
func NewTTFFont(face *gfxfont.Font) *FontNewTTFFont wraps a shaped TTF face for the graphics renderer.
func UIFont(role string) *FontUIFont returns the font for a UI role, falling back to the default font.
Methods
func (f *Font) Close() errorClose releases font resources when supported by the backing renderer.
func (f *Font) DrawGlyph(buf *Buffer, r rune, x, y int, fg, bg Color)DrawGlyph draws a single character glyph to a buffer.
func (f *Font) DrawText(buf *Buffer, text string, x, y int, fg, bg Color)DrawText draws text to a buffer at the given position.
func (f *Font) TextHeight(text string) intTextHeight returns the height of text in pixels.
func (f *Font) TextWidth(text string) intTextWidth returns the width of text in pixels.
InputHandler
type InputHandler = gfxinput.InputHandlerKey
type Key = gfxinput.KeyModifiers
type Modifiers = gfxinput.ModifiersMouseButton
type MouseButton = gfxinput.MouseButtonPixelFormat
type PixelFormat = gfxcore.PixelFormatPoint
type Point = gfxcore.PointRect
type Rect = gfxcore.RectTextAlign
type TextAlign intTextAlign represents text alignment.
Constants
const (
AlignLeft TextAlign = iota
AlignCenter
AlignRight
)Theme
type Theme = gfxtheme.ThemeWidget
type Widget interface {
Draw(buf *Buffer)
Bounds() Rect
SetBounds(r Rect)
MinSize() Point
HandleEvent(ev Event) bool
SetFocused(focused bool)
IsFocused() bool
IsDirty() bool
MarkClean()
SetVisible(visible bool)
IsVisible() bool
}Widget is the interface that all widgets must implement.