Documentation
¶
Index ¶
- Constants
- Variables
- func Clamp[T constraints.Ordered](x, lower, upper T) T
- func Cross(v1, v2 Vec) float64
- func Dist(v1, v2 Vec) float64
- func Dot(v1, v2 Vec) float64
- func DrawLine(v1, v2 Vec, buf *FrameBuffer)
- func IsColliding(s1, s2 Shape) bool
- func RGB(r, g, b uint8) color.RGBA
- func RGBA8(c color.Color) (r, g, b, a uint8)
- func Theta(v1, v2 Vec) float64
- func UNUSED(...any)
- type Alignment
- type BlendFunc
- type Button
- func (b *Button) Disable() *Button
- func (b *Button) Draw(buf *FrameBuffer)
- func (b *Button) Enable() *Button
- func (b *Button) IsHovering() bool
- func (b *Button) Move(mov Vec)
- func (b *Button) SetCallback(trigger ButtonTrigger, callback func()) *Button
- func (b *Button) SetLabelAlignment(align Alignment) *Button
- func (b *Button) SetLabelColour(c color.Color) *Button
- func (b *Button) SetLabelDPI(dpi float64) *Button
- func (b *Button) SetLabelFont(path string) error
- func (b *Button) SetLabelOffset(offset Vec) *Button
- func (b *Button) SetLabelPos(pos Vec) *Button
- func (b *Button) SetLabelSize(size float64) *Button
- func (b *Button) SetLabelSpacing(spacing float64) *Button
- func (b *Button) SetLabelText(s string) *Button
- func (b *Button) UnsetCallback(trigger ButtonTrigger) *Button
- func (b *Button) Update(win *Window)
- type ButtonBehaviour
- type ButtonTrigger
- type Circle
- func (c *Circle) Draw(buf *FrameBuffer)
- func (c *Circle) DrawCircleSegment(limitDir Vec, buf *FrameBuffer)
- func (c *Circle) EdgePoint(theta float64) Vec
- func (c *Circle) GetPos() Vec
- func (c *Circle) GetStyle() Style
- func (c *Circle) Height() float64
- func (c *Circle) IsWithin(pos Vec) bool
- func (c *Circle) Move(px Vec)
- func (c *Circle) SetDiameter(px float64) *Circle
- func (c *Circle) SetPos(pos Vec)
- func (c *Circle) SetStyle(style Style) *Circle
- func (c *Circle) String() string
- func (c *Circle) Width() float64
- type CurvedRect
- func (r *CurvedRect) Draw(buf *FrameBuffer)
- func (r *CurvedRect) GetPos() Vec
- func (r *CurvedRect) GetStyle() Style
- func (r *CurvedRect) Height() float64
- func (r *CurvedRect) IsWithin(pos Vec) bool
- func (r *CurvedRect) Move(px Vec)
- func (r *CurvedRect) SetHeight(px float64) *CurvedRect
- func (r *CurvedRect) SetPos(pos Vec)
- func (r *CurvedRect) SetStyle(style Style) *CurvedRect
- func (r *CurvedRect) SetWidth(px float64) *CurvedRect
- func (r *CurvedRect) String() string
- func (r *CurvedRect) Width() float64
- type Drawable
- type FrameBuffer
- func (f *FrameBuffer) Bytes() []byte
- func (f *FrameBuffer) Clear()
- func (f *FrameBuffer) Fill(c color.Color)
- func (f *FrameBuffer) GetPixel(x, y int) Pixel
- func (f *FrameBuffer) Height() int
- func (f *FrameBuffer) SetPixel(x, y int, p Pixel)
- func (f *FrameBuffer) SetPixelFunc(x, y int, p Pixel, fn BlendFunc)
- func (f *FrameBuffer) Width() int
- func (f *FrameBuffer) WithinFrame(point Vec, padding float64) bool
- type KeybindMode
- type MouseScrollCallback
- type MouseState
- type Pixel
- type Polygon
- type Rect
- func (r *Rect) Draw(buf *FrameBuffer)
- func (r *Rect) GetPos() Vec
- func (r *Rect) GetStyle() Style
- func (r *Rect) Height() float64
- func (r *Rect) IsWithin(pos Vec) bool
- func (r *Rect) Move(px Vec)
- func (r *Rect) SetHeight(px float64) *Rect
- func (r *Rect) SetPos(pos Vec)
- func (r *Rect) SetStyle(style Style) *Rect
- func (r *Rect) SetWidth(px float64) *Rect
- func (r *Rect) String() string
- func (r *Rect) Width() float64
- type Shape
- type Style
- type Text
- func (t *Text) Alignment() Alignment
- func (t *Text) Colour() color.Color
- func (t *Text) DPI() float64
- func (t *Text) Draw(buf *FrameBuffer)
- func (t *Text) Move(mov Vec)
- func (t *Text) Offset() Vec
- func (t *Text) Pos() Vec
- func (t *Text) SetAlignment(align Alignment) *Text
- func (t *Text) SetColour(c color.Color) *Text
- func (t *Text) SetDPI(dpi float64) *Text
- func (t *Text) SetFont(path string) error
- func (t *Text) SetOffset(offset Vec) *Text
- func (t *Text) SetPos(pos Vec) *Text
- func (t *Text) SetSize(size float64) *Text
- func (t *Text) SetSpacing(spacing float64) *Text
- func (t *Text) SetText(txt string) *Text
- func (t *Text) Size() float64
- func (t *Text) Spacing() float64
- func (t *Text) Text() string
- type TextBox
- func (t *TextBox) Draw(buf *FrameBuffer)
- func (t *TextBox) IsEditing() bool
- func (t *TextBox) Move(mov Vec)
- func (t *TextBox) SetCallback(callback func()) *TextBox
- func (t *TextBox) SetDeselectedCB(fn func()) *TextBox
- func (t *TextBox) SetEditing(editMode bool) *TextBox
- func (t *TextBox) SetModifiedCB(fn func()) *TextBox
- func (t *TextBox) SetPos(pos Vec) *TextBox
- func (t *TextBox) SetSelectedCB(fn func()) *TextBox
- func (t *TextBox) SetText(s string) *TextBox
- func (t *TextBox) SetTextAlignment(align Alignment) *TextBox
- func (t *TextBox) SetTextColour(c color.Color) *TextBox
- func (t *TextBox) SetTextDPI(dpi float64) *TextBox
- func (t *TextBox) SetTextFont(path string) error
- func (t *TextBox) SetTextOffset(offset Vec) *TextBox
- func (t *TextBox) SetTextSize(size float64) *TextBox
- func (t *TextBox) SetTextSpacing(spacing float64) *TextBox
- func (t *TextBox) Update(win *Window)
- type Triangle
- type Vec
- type Window
- func (w *Window) Destroy()
- func (w *Window) Draw(s Drawable)
- func (w *Window) DropKeybinds()
- func (w *Window) GetConfig() WindowCfg
- func (w *Window) Height() int
- func (w *Window) IsRunning() bool
- func (w *Window) KeyIsPressed(key sdl.Keycode) bool
- func (w *Window) MouseButtonState() MouseState
- func (w *Window) MouseLocation() Vec
- func (w *Window) Quit()
- func (w *Window) RegisterKeybind(key sdl.Keycode, mode KeybindMode, callback func())
- func (w *Window) SetBackground(c color.Color)
- func (w *Window) SetMouseScrollCallback(cb MouseScrollCallback)
- func (w *Window) SetTitle(title string)
- func (w *Window) UnregisterKeybind(key sdl.Keycode, mode KeybindMode)
- func (w *Window) Update()
- func (w *Window) Width() int
- type WindowCfg
Constants ¶
const ( KeyModeNone = sdl.KMOD_NONE // 0 (no modifier is applicable) KeyModeLShift = sdl.KMOD_LSHIFT // the left Shift key is down KeyModeRShift = sdl.KMOD_RSHIFT // the right Shift key is down KeyModeLCtrl = sdl.KMOD_LCTRL // the left Ctrl (Control) key is down KeyModeRCtrl = sdl.KMOD_RCTRL // the right Ctrl (Control) key is down KeyModeLAlt = sdl.KMOD_LALT // the left Alt key is down KeyModeRAlt = sdl.KMOD_RALT // the right Alt key is down KeyModeLGui = sdl.KMOD_LGUI // the left GUI key (often the Windows key) is down KeyModeRGui = sdl.KMOD_RGUI // the right GUI key (often the Windows key) is down KeyModeNum = sdl.KMOD_NUM // the Num Lock key (may be located on an extended keypad) is down KeyModeCaps = sdl.KMOD_CAPS // the Caps Lock key is down KeyModeMode = sdl.KMOD_MODE // the AltGr key is down KeyModeCtrl = sdl.KMOD_CTRL // (KMOD_LCTRL|KMOD_RCTRL) KeyModeShift = sdl.KMOD_SHIFT // (KMOD_LSHIFT|KMOD_RSHIFT) KeyModeAlt = sdl.KMOD_ALT // (KMOD_LALT|KMOD_RALT) KeyModeGui = sdl.KMOD_GUI // (KMOD_LGUI|KMOD_RGUI) KeyModeReserved = sdl.KMOD_RESERVED // reserved for future use KeyUnknown = sdl.K_UNKNOWN // "" (no name, empty string) KeyReturn = sdl.K_RETURN // "Return" (the Enter key (main keyboard)) KeyEscape = sdl.K_ESCAPE // "Escape" (the Esc key) KeyBackspace = sdl.K_BACKSPACE // "Backspace" KeyTab = sdl.K_TAB // "Tab" (the Tab key) KeySpace = sdl.K_SPACE // "Space" (the Space Bar key(s)) KeyExclaim = sdl.K_EXCLAIM // "!" KeyQuotedBL = sdl.K_QUOTEDBL // """ KeyHash = sdl.K_HASH // "#" KeyPercent = sdl.K_PERCENT // "%" KeyDollar = sdl.K_DOLLAR // "$" KeyAmpersand = sdl.K_AMPERSAND // "&" KeyQuote = sdl.K_QUOTE // "'" KeyLeftparen = sdl.K_LEFTPAREN // "(" KeyRightparen = sdl.K_RIGHTPAREN // ")" KeyAsterisk = sdl.K_ASTERISK // "*" KeyPlus = sdl.K_PLUS // "+" KeyComma = sdl.K_COMMA // "," KeyMinus = sdl.K_MINUS // "-" KeyPeriod = sdl.K_PERIOD // "." KeySlash = sdl.K_SLASH // "/" Key0 = sdl.K_0 // "0" Key1 = sdl.K_1 // "1" Key2 = sdl.K_2 // "2" Key3 = sdl.K_3 // "3" Key4 = sdl.K_4 // "4" Key5 = sdl.K_5 // "5" Key6 = sdl.K_6 // "6" Key7 = sdl.K_7 // "7" Key8 = sdl.K_8 // "8" Key9 = sdl.K_9 // "9" KeyColon = sdl.K_COLON // ":" KeySemicolon = sdl.K_SEMICOLON // ";" KeyLess = sdl.K_LESS // "<" KeyEquals = sdl.K_EQUALS // "=" KeyGreater = sdl.K_GREATER // ">" KeyQuestion = sdl.K_QUESTION // "?" KeyAt = sdl.K_AT // "@" KeyLeftBracket = sdl.K_LEFTBRACKET // "[" KeyBackslash = sdl.K_BACKSLASH // "\" KeyRightBracket = sdl.K_RIGHTBRACKET // "]" KeyCaret = sdl.K_CARET // "^" KeyUnderscore = sdl.K_UNDERSCORE // "_" KeyBackquote = sdl.K_BACKQUOTE // "`" KeyA = sdl.K_a // "A" KeyB = sdl.K_b // "B" KeyC = sdl.K_c // "C" KeyD = sdl.K_d // "D" KeyE = sdl.K_e // "E" KeyF = sdl.K_f // "F" KeyG = sdl.K_g // "G" KeyH = sdl.K_h // "H" KeyI = sdl.K_i // "I" KeyJ = sdl.K_j // "J" KeyK = sdl.K_k // "K" KeyL = sdl.K_l // "L" KeyM = sdl.K_m // "M" KeyN = sdl.K_n // "N" KeyO = sdl.K_o // "O" KeyP = sdl.K_p // "P" KeyQ = sdl.K_q // "Q" KeyR = sdl.K_r // "R" KeyS = sdl.K_s // "S" KeyT = sdl.K_t // "T" KeyU = sdl.K_u // "U" KeyV = sdl.K_v // "V" KeyW = sdl.K_w // "W" KeyX = sdl.K_x // "X" KeyY = sdl.K_y // "Y" KeyZ = sdl.K_z // "Z" KeyCapslock = sdl.K_CAPSLOCK // "CapsLock" KeyF1 = sdl.K_F1 // "F1" KeyF2 = sdl.K_F2 // "F2" KeyF3 = sdl.K_F3 // "F3" KeyF4 = sdl.K_F4 // "F4" KeyF5 = sdl.K_F5 // "F5" KeyF6 = sdl.K_F6 // "F6" KeyF7 = sdl.K_F7 // "F7" KeyF8 = sdl.K_F8 // "F8" KeyF9 = sdl.K_F9 // "F9" KeyF10 = sdl.K_F10 // "F10" KeyF11 = sdl.K_F11 // "F11" KeyF12 = sdl.K_F12 // "F12" KeyPrintscreen = sdl.K_PRINTSCREEN // "PrintScreen" KeyScrolllock = sdl.K_SCROLLLOCK // "ScrollLock" KeyPause = sdl.K_PAUSE // "Pause" (the Pause / Break key) KeyInsert = sdl.K_INSERT // "Insert" (insert on PC, help on some Mac keyboards (but does send code 73, not 117)) KeyHome = sdl.K_HOME // "Home" KeyPageup = sdl.K_PAGEUP // "PageUp" KeyDelete = sdl.K_DELETE // "Delete" KeyEnd = sdl.K_END // "End" KeyPagedown = sdl.K_PAGEDOWN // "PageDown" KeyRight = sdl.K_RIGHT // "Right" (the Right arrow key (navigation keypad)) KeyLeft = sdl.K_LEFT // "Left" (the Left arrow key (navigation keypad)) KeyDown = sdl.K_DOWN // "Down" (the Down arrow key (navigation keypad)) KeyUp = sdl.K_UP // "Up" (the Up arrow key (navigation keypad)) KeyNumlockclear = sdl.K_NUMLOCKCLEAR // "Numlock" (the Num Lock key (PC) / the Clear key (Mac)) KeyKPDivide = sdl.K_KP_DIVIDE // "Keypad /" (the / key (numeric keypad)) KeyKPMultiply = sdl.K_KP_MULTIPLY // "Keypad *" (the * key (numeric keypad)) KeyKPMinus = sdl.K_KP_MINUS // "Keypad -" (the - key (numeric keypad)) KeyKPPlus = sdl.K_KP_PLUS // "Keypad +" (the + key (numeric keypad)) KeyKPEnter = sdl.K_KP_ENTER // "Keypad Enter" (the Enter key (numeric keypad)) KeyKP1 = sdl.K_KP_1 // "Keypad 1" (the 1 key (numeric keypad)) KeyKP2 = sdl.K_KP_2 // "Keypad 2" (the 2 key (numeric keypad)) KeyKP3 = sdl.K_KP_3 // "Keypad 3" (the 3 key (numeric keypad)) KeyKP4 = sdl.K_KP_4 // "Keypad 4" (the 4 key (numeric keypad)) KeyKP5 = sdl.K_KP_5 // "Keypad 5" (the 5 key (numeric keypad)) KeyKP6 = sdl.K_KP_6 // "Keypad 6" (the 6 key (numeric keypad)) KeyKP7 = sdl.K_KP_7 // "Keypad 7" (the 7 key (numeric keypad)) KeyKP8 = sdl.K_KP_8 // "Keypad 8" (the 8 key (numeric keypad)) KeyKP9 = sdl.K_KP_9 // "Keypad 9" (the 9 key (numeric keypad)) KeyKP0 = sdl.K_KP_0 // "Keypad 0" (the 0 key (numeric keypad)) KeyKPPeriod = sdl.K_KP_PERIOD // "Keypad ." (the . key (numeric keypad)) KeyApplication = sdl.K_APPLICATION // "Application" (the Application / Compose / Context Menu (Windows) key) KeyPower = sdl.K_POWER // "Power" (The USB document says this is a status flag, not a physical key - but some Mac keyboards do have a power key) KeyKPEquals = sdl.K_KP_EQUALS // "Keypad =" (the = key (numeric keypad)) KeyF13 = sdl.K_F13 // "F13" KeyF14 = sdl.K_F14 // "F14" KeyF15 = sdl.K_F15 // "F15" KeyF16 = sdl.K_F16 // "F16" KeyF17 = sdl.K_F17 // "F17" KeyF18 = sdl.K_F18 // "F18" KeyF19 = sdl.K_F19 // "F19" KeyF20 = sdl.K_F20 // "F20" KeyF21 = sdl.K_F21 // "F21" KeyF22 = sdl.K_F22 // "F22" KeyF23 = sdl.K_F23 // "F23" KeyF24 = sdl.K_F24 // "F24" KeyExecute = sdl.K_EXECUTE // "Execute" KeyHelp = sdl.K_HELP // "Help" KeyMenu = sdl.K_MENU // "Menu" KeySelect = sdl.K_SELECT // "Select" KeyStop = sdl.K_STOP // "Stop" KeyAgain = sdl.K_AGAIN // "Again" (the Again key (Redo)) KeyUndo = sdl.K_UNDO // "Undo" KeyCut = sdl.K_CUT // "Cut" KeyCopy = sdl.K_COPY // "Copy" KeyPaste = sdl.K_PASTE // "Paste" KeyFind = sdl.K_FIND // "Find" KeyMute = sdl.K_MUTE // "Mute" KeyVolumeUp = sdl.K_VOLUMEUP // "VolumeUp" KeyVolumeDown = sdl.K_VOLUMEDOWN // "VolumeDown" KeyKPComma = sdl.K_KP_COMMA // "Keypad ," (the Comma key (numeric keypad)) KeyKPEqualsAS400 = sdl.K_KP_EQUALSAS400 // "Keypad = (AS400)" (the Equals AS400 key (numeric keypad)) KeyAltErase = sdl.K_ALTERASE // "AltErase" (Erase-Eaze) KeySysReq = sdl.K_SYSREQ // "SysReq" (the SysReq key) KeyCancel = sdl.K_CANCEL // "Cancel" KeyClear = sdl.K_CLEAR // "Clear" KeyPrior = sdl.K_PRIOR // "Prior" KeyReturn2 = sdl.K_RETURN2 // "Return" KeySeparator = sdl.K_SEPARATOR // "Separator" KeyOut = sdl.K_OUT // "Out" KeyOper = sdl.K_OPER // "Oper" KeyClearAgain = sdl.K_CLEARAGAIN // "Clear / Again" KeyCrSel = sdl.K_CRSEL // "CrSel" KeyExSel = sdl.K_EXSEL // "ExSel" KeyKP00 = sdl.K_KP_00 // "Keypad 00" (the 00 key (numeric keypad)) KeyKP000 = sdl.K_KP_000 // "Keypad 000" (the 000 key (numeric keypad)) KeyThousandsSeparator = sdl.K_THOUSANDSSEPARATOR // "ThousandsSeparator" (the Thousands Separator key) KeyDecimalSeparator = sdl.K_DECIMALSEPARATOR // "DecimalSeparator" (the Decimal Separator key) KeyCurrencyUnit = sdl.K_CURRENCYUNIT // "CurrencyUnit" (the Currency Unit key) KeyCurrencySubUnit = sdl.K_CURRENCYSUBUNIT // "CurrencySubUnit" (the Currency Subunit key) KeyKPLeftParen = sdl.K_KP_LEFTPAREN // "Keypad (" (the Left Parenthesis key (numeric keypad)) KeyKPRightParen = sdl.K_KP_RIGHTPAREN // "Keypad )" (the Right Parenthesis key (numeric keypad)) KeyKPLeftBrace = sdl.K_KP_LEFTBRACE // "Keypad {" (the Left Brace key (numeric keypad)) KeyKPRightBrace = sdl.K_KP_RIGHTBRACE // "Keypad }" (the Right Brace key (numeric keypad)) KeyKPTab = sdl.K_KP_TAB // "Keypad Tab" (the Tab key (numeric keypad)) KeyKPBackspace = sdl.K_KP_BACKSPACE // "Keypad Backspace" (the Backspace key (numeric keypad)) KeyKPA = sdl.K_KP_A // "Keypad A" (the A key (numeric keypad)) KeyKPB = sdl.K_KP_B // "Keypad B" (the B key (numeric keypad)) KeyKPC = sdl.K_KP_C // "Keypad C" (the C key (numeric keypad)) KeyKPD = sdl.K_KP_D // "Keypad D" (the D key (numeric keypad)) KeyKPE = sdl.K_KP_E // "Keypad E" (the E key (numeric keypad)) KeyKPF = sdl.K_KP_F // "Keypad F" (the F key (numeric keypad)) KeyKPXor = sdl.K_KP_XOR // "Keypad XOR" (the XOR key (numeric keypad)) KeyKPPower = sdl.K_KP_POWER // "Keypad ^" (the Power key (numeric keypad)) KeyKPPercent = sdl.K_KP_PERCENT // "Keypad %" (the Percent key (numeric keypad)) KeyKPLess = sdl.K_KP_LESS // "Keypad <" (the Less key (numeric keypad)) KeyKPGreater = sdl.K_KP_GREATER // "Keypad >" (the Greater key (numeric keypad)) KeyKPAmpersand = sdl.K_KP_AMPERSAND // "Keypad &" (the & key (numeric keypad)) KeyKPDblAmpersand = sdl.K_KP_DBLAMPERSAND // "Keypad &&" (the && key (numeric keypad)) KeyKPVerticalBar = sdl.K_KP_VERTICALBAR // "Keypad |" (the | key (numeric keypad)) KeyKPDblVerticalBar = sdl.K_KP_DBLVERTICALBAR // "Keypad ||" (the || key (numeric keypad)) KeyKPColon = sdl.K_KP_COLON // "Keypad :" (the : key (numeric keypad)) KeyKPHash = sdl.K_KP_HASH // "Keypad #" (the # key (numeric keypad)) KeyKPSpace = sdl.K_KP_SPACE // "Keypad Space" (the Space key (numeric keypad)) KeyKPAt = sdl.K_KP_AT // "Keypad @" (the @ key (numeric keypad)) KeyKPExclam = sdl.K_KP_EXCLAM // "Keypad !" (the ! key (numeric keypad)) KeyKPMemStore = sdl.K_KP_MEMSTORE // "Keypad MemStore" (the Mem Store key (numeric keypad)) KeyKPMemRecall = sdl.K_KP_MEMRECALL // "Keypad MemRecall" (the Mem Recall key (numeric keypad)) KeyKPMemClear = sdl.K_KP_MEMCLEAR // "Keypad MemClear" (the Mem Clear key (numeric keypad)) KeyKPMemAdd = sdl.K_KP_MEMADD // "Keypad MemAdd" (the Mem Add key (numeric keypad)) KeyKPMemSubtract = sdl.K_KP_MEMSUBTRACT // "Keypad MemSubtract" (the Mem Subtract key (numeric keypad)) KeyKPMemMultiply = sdl.K_KP_MEMMULTIPLY // "Keypad MemMultiply" (the Mem Multiply key (numeric keypad)) KeyKPMemDivide = sdl.K_KP_MEMDIVIDE // "Keypad MemDivide" (the Mem Divide key (numeric keypad)) KeyKPPlusMinus = sdl.K_KP_PLUSMINUS // "Keypad +/-" (the +/- key (numeric keypad)) KeyKPClear = sdl.K_KP_CLEAR // "Keypad Clear" (the Clear key (numeric keypad)) KeyKPClearEntry = sdl.K_KP_CLEARENTRY // "Keypad ClearEntry" (the Clear Entry key (numeric keypad)) KeyKPBinary = sdl.K_KP_BINARY // "Keypad Binary" (the Binary key (numeric keypad)) KeyKPOctal = sdl.K_KP_OCTAL // "Keypad Octal" (the Octal key (numeric keypad)) KeyKPDecimal = sdl.K_KP_DECIMAL // "Keypad Decimal" (the Decimal key (numeric keypad)) KeyKPHexadecimal = sdl.K_KP_HEXADECIMAL // "Keypad Hexadecimal" (the Hexadecimal key (numeric keypad)) KeyLCtrl = sdl.K_LCTRL // "Left Ctrl" KeyLShift = sdl.K_LSHIFT // "Left Shift" KeyLAlt = sdl.K_LALT // "Left Alt" (alt, option) KeyLGui = sdl.K_LGUI // "Left GUI" (windows, command (apple), meta) KeyRCtrl = sdl.K_RCTRL // "Right Ctrl" KeyRShift = sdl.K_RSHIFT // "Right Shift" KeyRAlt = sdl.K_RALT // "Right Alt" (alt, option) KeyRGui = sdl.K_RGUI // "Right GUI" (windows, command (apple), meta) KeyMode = sdl.K_MODE // "ModeSwitch" KeyAudioNext = sdl.K_AUDIONEXT // "AudioNext" (the Next Track media key) KeyAudioPrev = sdl.K_AUDIOPREV // "AudioPrev" (the Previous Track media key) KeyAudioStop = sdl.K_AUDIOSTOP // "AudioStop" (the Stop media key) KeyAudioPlay = sdl.K_AUDIOPLAY // "AudioPlay" (the Play media key) KeyAudioMute = sdl.K_AUDIOMUTE // "AudioMute" (the Mute volume key) KeyMediaSelect = sdl.K_MEDIASELECT // "MediaSelect" (the Media Select key) KeyWWW = sdl.K_WWW // "WWW" (the WWW/World Wide Web key) KeyMail = sdl.K_MAIL // "Mail" (the Mail/eMail key) KeyCalculator = sdl.K_CALCULATOR // "Calculator" (the Calculator key) KeyComputer = sdl.K_COMPUTER // "Computer" (the My Computer key) KeyACSearch = sdl.K_AC_SEARCH // "AC Search" (the Search key (application control keypad)) KeyACHome = sdl.K_AC_HOME // "AC Home" (the Home key (application control keypad)) KeyACBack = sdl.K_AC_BACK // "AC Back" (the Back key (application control keypad)) KeyACForward = sdl.K_AC_FORWARD // "AC Forward" (the Forward key (application control keypad)) KeyACStop = sdl.K_AC_STOP // "AC Stop" (the Stop key (application control keypad)) KeyACRefresh = sdl.K_AC_REFRESH // "AC Refresh" (the Refresh key (application control keypad)) KeyACBookmarks = sdl.K_AC_BOOKMARKS // "AC Bookmarks" (the Bookmarks key (application control keypad)) KeyBrightnessDown = sdl.K_BRIGHTNESSDOWN // "BrightnessDown" (the Brightness Down key) KeyBrightnessUp = sdl.K_BRIGHTNESSUP // "BrightnessUp" (the Brightness Up key) KeyDisplaySwitch = sdl.K_DISPLAYSWITCH // "DisplaySwitch" (display mirroring/dual display switch, video mode switch) KeyKbdIllumtoggle = sdl.K_KBDILLUMTOGGLE // "KBDIllumToggle" (the Keyboard Illumination Toggle key) KeyKbdIllumdown = sdl.K_KBDILLUMDOWN // "KBDIllumDown" (the Keyboard Illumination Down key) KeyKbdIllumup = sdl.K_KBDILLUMUP // "KBDIllumUp" (the Keyboard Illumination Up key) KeyEject = sdl.K_EJECT // "Eject" (the Eject key) KeySleep = sdl.K_SLEEP // "Sleep" (the Sleep key) )
Variables ¶
var ( Upwards = Vec{0, -1} Downwards = Vec{0, 1} Leftwards = Vec{-1, 0} Rightwards = Vec{1, 0} )
var ( Black = color.RGBA{0, 0, 0, 255} White = color.RGBA{255, 255, 255, 255} Red = color.RGBA{255, 0, 0, 255} Lime = color.RGBA{0, 255, 0, 255} Blue = color.RGBA{0, 0, 255, 255} Yellow = color.RGBA{255, 255, 0, 255} Cyan = color.RGBA{0, 255, 255, 255} Magenta = color.RGBA{255, 0, 255, 255} Silver = color.RGBA{192, 192, 192, 255} Grey = color.RGBA{128, 128, 128, 255} Maroon = color.RGBA{128, 0, 0, 255} Olive = color.RGBA{128, 128, 0, 255} Green = color.RGBA{0, 128, 0, 255} Purple = color.RGBA{128, 0, 128, 255} Teal = color.RGBA{0, 128, 128, 255} )
Common colour set.
var ( DarkRed = color.RGBA{139, 0, 0, 255} Brown = color.RGBA{165, 42, 42, 255} Firebrick = color.RGBA{178, 34, 34, 255} Crimson = color.RGBA{220, 20, 60, 255} Tomato = color.RGBA{255, 99, 71, 255} Coral = color.RGBA{255, 127, 80, 255} IndianRed = color.RGBA{205, 92, 92, 255} LightCoral = color.RGBA{240, 128, 128, 255} DarkSalmon = color.RGBA{233, 150, 122, 255} Salmon = color.RGBA{250, 128, 114, 255} LightSalmon = color.RGBA{255, 160, 122, 255} OrangeRed = color.RGBA{255, 69, 0, 255} DarkOrange = color.RGBA{255, 140, 0, 255} Orange = color.RGBA{255, 165, 0, 255} Gold = color.RGBA{255, 215, 0, 255} DarkGoldenRod = color.RGBA{184, 134, 11, 255} GoldenRod = color.RGBA{218, 165, 32, 255} PaleGoldenRod = color.RGBA{238, 232, 170, 255} DarkKhaki = color.RGBA{189, 183, 107, 255} Khaki = color.RGBA{240, 230, 140, 255} YellowGreen = color.RGBA{154, 205, 50, 255} DarkOliveGreen = color.RGBA{85, 107, 47, 255} OliveDrab = color.RGBA{107, 142, 35, 255} LawnGreen = color.RGBA{124, 252, 0, 255} Chartreuse = color.RGBA{127, 255, 0, 255} GreenYellow = color.RGBA{173, 255, 47, 255} DarkGreen = color.RGBA{0, 100, 0, 255} ForestGreen = color.RGBA{34, 139, 34, 255} LimeGreen = color.RGBA{50, 205, 50, 255} LightGreen = color.RGBA{144, 238, 144, 255} PaleGreen = color.RGBA{152, 251, 152, 255} DarkSeaGreen = color.RGBA{143, 188, 143, 255} MediumSpringGreen = color.RGBA{0, 250, 154, 255} SpringGreen = color.RGBA{0, 255, 127, 255} SeaGreen = color.RGBA{46, 139, 87, 255} MediumAquaMarine = color.RGBA{102, 205, 170, 255} MediumSeaGreen = color.RGBA{60, 179, 113, 255} LightSeaGreen = color.RGBA{32, 178, 170, 255} DarkSlateGrey = color.RGBA{47, 79, 79, 255} DarkCyan = color.RGBA{0, 139, 139, 255} Aqua = color.RGBA{0, 255, 255, 255} LightCyan = color.RGBA{224, 255, 255, 255} DarkTurquoise = color.RGBA{0, 206, 209, 255} Turquoise = color.RGBA{64, 224, 208, 255} MediumTurquoise = color.RGBA{72, 209, 204, 255} PaleTurquoise = color.RGBA{175, 238, 238, 255} AquaMarine = color.RGBA{127, 255, 212, 255} PowderBlue = color.RGBA{176, 224, 230, 255} CadetBlue = color.RGBA{95, 158, 160, 255} SteelBlue = color.RGBA{70, 130, 180, 255} CornBlowerBlue = color.RGBA{100, 149, 237, 255} DeepSkyBlue = color.RGBA{0, 191, 255, 255} DodgerBlue = color.RGBA{30, 144, 255, 255} LightBlue = color.RGBA{173, 216, 230, 255} SkyBlue = color.RGBA{135, 206, 235, 255} LighSkyBlue = color.RGBA{135, 206, 250, 255} MidnightBlue = color.RGBA{25, 25, 112, 255} DarkBlue = color.RGBA{0, 0, 139, 255} MediumBlue = color.RGBA{0, 0, 205, 255} RoyalBlue = color.RGBA{65, 105, 225, 255} BlueViolet = color.RGBA{138, 43, 226, 255} Indigo = color.RGBA{75, 0, 130, 255} DarkSlateBlue = color.RGBA{72, 61, 139, 255} SlateBlue = color.RGBA{106, 90, 205, 255} MediumSlateBlue = color.RGBA{123, 104, 238, 255} MediumPurple = color.RGBA{147, 112, 219, 255} DarkMagenta = color.RGBA{139, 0, 139, 255} DarkViolet = color.RGBA{148, 0, 211, 255} DarkOrchid = color.RGBA{153, 50, 204, 255} MediumOrchid = color.RGBA{186, 85, 211, 255} Thistle = color.RGBA{216, 191, 216, 255} Plum = color.RGBA{221, 160, 221, 255} Violet = color.RGBA{238, 130, 238, 255} Orchid = color.RGBA{218, 112, 214, 255} MediumVioletRed = color.RGBA{199, 21, 133, 255} PaleVioletRed = color.RGBA{219, 112, 147, 255} DeepPink = color.RGBA{255, 20, 147, 255} HotPink = color.RGBA{255, 105, 180, 255} LightPink = color.RGBA{255, 182, 193, 255} Pink = color.RGBA{255, 192, 203, 255} AntiqueWhite = color.RGBA{250, 235, 215, 255} Beige = color.RGBA{245, 245, 220, 255} Bisque = color.RGBA{255, 228, 196, 255} BlanchedAlmond = color.RGBA{255, 235, 205, 255} Wheat = color.RGBA{245, 222, 179, 255} CornSilk = color.RGBA{255, 248, 220, 255} LemonChiffon = color.RGBA{255, 250, 205, 255} LightGoldenRodYellow = color.RGBA{250, 250, 210, 255} LightYellow = color.RGBA{255, 255, 224, 255} SaddleBrown = color.RGBA{139, 69, 19, 255} Sienna = color.RGBA{160, 82, 45, 255} Chocolate = color.RGBA{210, 105, 30, 255} Peru = color.RGBA{205, 133, 63, 255} SandyBrown = color.RGBA{244, 164, 96, 255} BurlyWood = color.RGBA{222, 184, 135, 255} Tan = color.RGBA{210, 180, 140, 255} RosyBrown = color.RGBA{188, 143, 143, 255} Moccasin = color.RGBA{255, 228, 181, 255} PeachPuff = color.RGBA{255, 218, 185, 255} MistyRose = color.RGBA{255, 228, 225, 255} LavenderBlush = color.RGBA{255, 240, 245, 255} Linen = color.RGBA{250, 240, 230, 255} OldLace = color.RGBA{253, 245, 230, 255} PapayaWhip = color.RGBA{255, 239, 213, 255} SeaShell = color.RGBA{255, 245, 238, 255} MintCream = color.RGBA{245, 255, 250, 255} SlateGrey = color.RGBA{112, 128, 144, 255} LightSlateGrey = color.RGBA{119, 136, 153, 255} LightSteelBlue = color.RGBA{176, 196, 222, 255} Lavender = color.RGBA{230, 230, 250, 255} FloralWhite = color.RGBA{255, 250, 240, 255} AliceBlue = color.RGBA{240, 248, 255, 255} GhostWhite = color.RGBA{248, 248, 255, 255} Honeydew = color.RGBA{240, 255, 240, 255} Ivory = color.RGBA{255, 255, 240, 255} Azure = color.RGBA{240, 255, 255, 255} Snow = color.RGBA{255, 250, 250, 255} DimGrey = color.RGBA{105, 105, 105, 255} DarkGrey = color.RGBA{169, 169, 169, 255} LightGrey = color.RGBA{211, 211, 211, 255} Gainsboro = color.RGBA{220, 220, 220, 255} WhiteSmoke = color.RGBA{245, 245, 245, 255} )
Extra colours for if you're feeling artistic.
var DefaultStyle = Style{ Colour: color.RGBA{0xff, 0xff, 0xff, 0xff}, Thickness: 0, Bloom: 0, }
DefaultStyle is the default style for new shapes.
Functions ¶
func Clamp ¶
func Clamp[T constraints.Ordered](x, lower, upper T) T
Clamp constraints a variable between lower and upper bounds.
func Dist ¶
Dist returns the distance between two vectors, assuming they both originate from the same point.
func DrawLine ¶
func DrawLine(v1, v2 Vec, buf *FrameBuffer)
DrawLine draws a single pixel line using Bresenham's line drawing algorithm.
func IsColliding ¶
IsColliding returns true if two shapes are colliding.
Types ¶
type Alignment ¶
type Alignment int
Alignment is used to specify alignment relative to the position coordinate.
type Button ¶
type Button struct { Shape hoverable // the base shape the button is built on Label *Text // the text to display on the button (if any) Callbacks map[ButtonTrigger]func() // mapping of triggers to callback functions IsEnabled bool // stops callbacks from executing if false // contains filtered or unexported fields }
Button can be build on top of shapes to create pressable buttons.
func NewButton ¶
NewButton constructs a new button from any shape that satisfies the buttonable interface.
func (*Button) Draw ¶
func (b *Button) Draw(buf *FrameBuffer)
Draw draws the button onto the frame buffer.
func (*Button) IsHovering ¶
IsHovering returns whether the cursor is hovering over the button.
func (*Button) SetCallback ¶
func (b *Button) SetCallback(trigger ButtonTrigger, callback func()) *Button
SetCallback configures a callback function to execute if the conditions described by the trigger are met.
func (*Button) SetLabelAlignment ¶
SetLabelAlignment sets the alignment of the text label relative to the centre of the shape.
func (*Button) SetLabelColour ¶
SetLabelColour sets the label text colour.
func (*Button) SetLabelDPI ¶
SetLabelDPI sets the DPI of the label font.
func (*Button) SetLabelFont ¶
SetLabelFont sets the path of the .ttf file that is used to generate the label.
func (*Button) SetLabelOffset ¶
SetLabelOffset manually sets the label's offset, providing the text is in AlignCustom mode.
func (*Button) SetLabelPos ¶
SetLabelPos sets the label's position on the screen.
func (*Button) SetLabelSize ¶
SetLabelSize sets the size of the label font.
func (*Button) SetLabelSpacing ¶
SetLabelSpacing sets the line spacing of the label.
func (*Button) SetLabelText ¶
SetLabelText sets the text label to the given string.
func (*Button) UnsetCallback ¶
func (b *Button) UnsetCallback(trigger ButtonTrigger) *Button
UnsetCallback removes a callback for a specified trigger. If no callback is configured, nothing will happen.
type ButtonBehaviour ¶
type ButtonBehaviour int
ButtonBehaviour represents how a button responds to being pressed.
const ( OnAll ButtonBehaviour = iota // execute behaviour every time Update() is called OnPress // execute behaviour on press OnRelease // execute behaviour on release OnPressAndRelease // execute behaviour on press and release OnHold // execute behaviour as long as button is held down )
type ButtonTrigger ¶
type ButtonTrigger struct { // State is the state of the mouse buttons in a given moment. State MouseState // Behaviour describes at what point of the mouse click to execute the callback on. Behaviour ButtonBehaviour }
ButtonTrigger is a trigger for executing a button callback function.
type Circle ¶
Cicle is a circle shape, aligned to the centre of the circle.
func (*Circle) Draw ¶
func (c *Circle) Draw(buf *FrameBuffer)
Draw draws the circle onto the provided frame buffer.
func (*Circle) DrawCircleSegment ¶
func (c *Circle) DrawCircleSegment(limitDir Vec, buf *FrameBuffer)
DrawCircleSegment draws only a segment of the circle to the frame buffer, limited by the provided vector.
func (*Circle) EdgePoint ¶
EdgePoint generates a point the point on the circle's perimeter that is theta radians clockwise from the circle's direction.
func (*Circle) SetDiameter ¶
SetDiameter sets the diameter of the circle, in pixels.
type CurvedRect ¶
CurvedRect is a rectangle with rounded corners, aligned to the top-left.
func NewCurvedRect ¶
func NewCurvedRect(width, height, radius float64, pos Vec) *CurvedRect
NewCurvedRect constructs a new curved rectangle.
func (*CurvedRect) Draw ¶
func (r *CurvedRect) Draw(buf *FrameBuffer)
Draw draws the curved rectangle onto the provided frame buffer.
func (*CurvedRect) GetPos ¶
func (r *CurvedRect) GetPos() Vec
GetPos returns the position of the curved rectangle.
func (*CurvedRect) GetStyle ¶
func (r *CurvedRect) GetStyle() Style
GetStyle returns's the curved rectangle's style.
func (*CurvedRect) Height ¶
func (r *CurvedRect) Height() float64
Height returns the pixel height of the curved rectangle.
func (*CurvedRect) IsWithin ¶
func (r *CurvedRect) IsWithin(pos Vec) bool
IsWithin returns whether a position lies within the curved rectangle's perimeter.
func (*CurvedRect) Move ¶
func (r *CurvedRect) Move(px Vec)
Move moves the curved rectangle by the given vector.
func (*CurvedRect) SetHeight ¶
func (r *CurvedRect) SetHeight(px float64) *CurvedRect
SetHeight sets the height of the curved rectangle.
func (*CurvedRect) SetPos ¶
func (r *CurvedRect) SetPos(pos Vec)
SetPos sets the position of the curved rectangle.
func (*CurvedRect) SetStyle ¶
func (r *CurvedRect) SetStyle(style Style) *CurvedRect
SetStyle sets the style of the curved rectangle.
func (*CurvedRect) SetWidth ¶
func (r *CurvedRect) SetWidth(px float64) *CurvedRect
SetWidth sets the width of the curved rectangle.
func (*CurvedRect) String ¶
func (r *CurvedRect) String() string
String returns the type of shape as a string.
func (*CurvedRect) Width ¶
func (r *CurvedRect) Width() float64
Width returns the pixel width of the curved rectangle.
type Drawable ¶
type Drawable interface { // Draw draws to a frame buffer. Draw(*FrameBuffer) }
Drawable is an interface for things that can be drawn onto a frame buffer.
type FrameBuffer ¶
type FrameBuffer [][]Pixel
FrameBuffer is a 2D slice of pixels which represents a screen.
func NewFrameBuffer ¶
func NewFrameBuffer(width, height int) *FrameBuffer
NewFrameBuffer constructs a new frame buffer with a particular width and height.
func (*FrameBuffer) Bytes ¶
func (f *FrameBuffer) Bytes() []byte
Bytes returns the frame buffer as a one-dimensional slice of bytes.
func (*FrameBuffer) Clear ¶
func (f *FrameBuffer) Clear()
Clear sets every pixel in the frame buffer to zero.
func (*FrameBuffer) Fill ¶
func (f *FrameBuffer) Fill(c color.Color)
Fill sets every pixel in the frame buffer to the provided colour.
func (*FrameBuffer) GetPixel ¶
func (f *FrameBuffer) GetPixel(x, y int) Pixel
GetPixel returns a copy of the pixel at the specified coordinates.
func (*FrameBuffer) Height ¶
func (f *FrameBuffer) Height() int
Height returns the height of the frame buffer.
func (*FrameBuffer) SetPixel ¶
func (f *FrameBuffer) SetPixel(x, y int, p Pixel)
SetPixel sets a pixel in the frame buffer. If the requested pixel is out of bounds, nothing happens. The default alpha blending technique is used. To use other blending methods, see SetPixelFunc.
func (*FrameBuffer) SetPixelFunc ¶
func (f *FrameBuffer) SetPixelFunc(x, y int, p Pixel, fn BlendFunc)
SetPixelFunc sets a pixe in the frame buffer using the specified blend function.
func (*FrameBuffer) Width ¶
func (f *FrameBuffer) Width() int
Width returns the width of the frame buffer.
func (*FrameBuffer) WithinFrame ¶
func (f *FrameBuffer) WithinFrame(point Vec, padding float64) bool
WithinFrame returns true if the given point lies within the boundary of the frame buffer, taking the padding value into account.
type KeybindMode ¶
type KeybindMode int
KeybindMode describes how a callback is executed after a bound key is pressed.
const ( Instantaneous KeybindMode = iota // callback executed continuously while is pressed KeyPress // callback executed on press KeyRelease // callback executed on release )
type MouseScrollCallback ¶
type MouseScrollCallback func(movement Vec)
MouseScrollCallback is executed when the user scrolls the mouse wheel in any direction.
Positive X movement means scrolling to the right. Positive Y movement means scrolling up.
type MouseState ¶
type MouseState int
MouseState represents the state of the mouse buttons.
const ( NoClick MouseState = 0 LeftClick MouseState = 1 RightClick MouseState = 4 LeftAndRightClick MouseState = 5 )
func (MouseState) String ¶
func (m MouseState) String() string
String returns the mouse state as a string.
type Pixel ¶
type Pixel [pxLen]uint8
Pixel represents a pixel, with bytes [red, green, blue, alpha].
func AdditiveBlend ¶
AdditiveBlend blends a source pixel with a destination pixel by adding the values of each channel.
func AlphaBlend ¶
AlphaBlend blends a source pixel over a destination pixel using the Porter-Duff source-over operator. This results in the source pixel having a greater impact on the resulting colour.
type Polygon ¶
type Polygon struct {
// contains filtered or unexported fields
}
Polygon is a 2D shape with 3 or more sides.
func NewPolygon ¶
NewPolygon constructs a polygon from the specified vertices. The order of the vertices dictates the edges of the polygon. The final vertex is always linked to the first.
func (*Polygon) Draw ¶
func (p *Polygon) Draw(buf *FrameBuffer)
Draw draws the polygon onto the provided frame buffer.
type Rect ¶
Rect is a rectangle shape, aligned to the top-left corner.
func (*Rect) Draw ¶
func (r *Rect) Draw(buf *FrameBuffer)
Draw draws the rectangle onto the provided frame buffer.
type Shape ¶
type Shape interface { Drawable // Width returns the width of the shape in pixels. Width() float64 // Height returns the height of she shape in pixels. Height() float64 // GetPos returns the position of the shape. GetPos() Vec // SetPos sets the position of the shape. SetPos(Vec) // GetStyle returns the shape's style. GetStyle() Style // Move moves the shape by a pixel vector. Move(Vec) // String returns the name of the shape. String() string }
Shape is an interface for shapes.
type Style ¶
type Style struct { Colour color.Color Thickness float64 // leave 0 for solid Bloom int // bloom reach, in pixels }
Style contains style information for a shape.
func RandomStyle ¶
func RandomStyle() Style
RandomStyle generates a style of random colour and thickness 0.
type Text ¶
type Text struct {
// contains filtered or unexported fields
}
Text is a customisable block of text.
func NewText ¶
NewText constructs a new text object with default parameters. The default font size is 20.
func (*Text) Draw ¶
func (t *Text) Draw(buf *FrameBuffer)
Draw draws the text onto the provided frame buffer.
func (*Text) SetAlignment ¶
SetText sets the text alignment.
func (*Text) SetOffset ¶
SetOffset sets the text's offset. Note: this overwrites existing alignment settings.
func (*Text) SetSpacing ¶
SetSpacing sets the line spacing.
type TextBox ¶
type TextBox struct { Shape hoverable // the base shape the text box is built on Text *Text // the text in the text box // contains filtered or unexported fields }
TextBox is a shape that can be typed in.
func NewTextBox ¶
NewTextBox constructs a new text box from a hoverable shape.
func (*TextBox) Draw ¶
func (t *TextBox) Draw(buf *FrameBuffer)
Draw draws the text box onto the frame buffer.
func (*TextBox) SetCallback ¶
SetCallback configures a callback function to execute every time the text in the text box is updated by the user.
func (*TextBox) SetDeselectedCB ¶
SetDeselectedCB sets the callback function which is triggered when the text box is deselected.
func (*TextBox) SetEditing ¶
SetEditing sets whether the text box is in edit mode or not.
func (*TextBox) SetModifiedCB ¶
SetModifiedCB sets the callback function which is triggered when the text is modified.
func (*TextBox) SetSelectedCB ¶
SetSelectedCB sets the callback function which is triggered when the text box is selected.
func (*TextBox) SetTextAlignment ¶
SetTextAlignment sets the alignment of the text relative to the text box.
func (*TextBox) SetTextColour ¶
SetTextColour sets the text colour.
func (*TextBox) SetTextDPI ¶
SetTextDPI sets the DPI of the text font.
func (*TextBox) SetTextFont ¶
SetTextFont sets the path fo the .ttf file that is used to generate the text.
func (*TextBox) SetTextOffset ¶
SetTextOffset manually sets the text's offset, providing the text is in AlignCustom mode.
func (*TextBox) SetTextSize ¶
SetTextSize sets the size of the text font.
func (*TextBox) SetTextSpacing ¶
SetTextSpacing sets the line spacing of the text.
type Triangle ¶
type Triangle struct {
// contains filtered or unexported fields
}
Triangle is triangle shape, defined by the position of its vertices.
func NewTriangle ¶
NewTriangle constructs a new triangle from the provided vertices.
func (*Triangle) Draw ¶
func (t *Triangle) Draw(buf *FrameBuffer)
Draw rasterises and draws the triangle onto the provided frame buffer.
type Vec ¶
type Vec struct{ X, Y float64 }
Vec is a Cartesian vector.
func GenerateCatmullRomSpline ¶
GenerateCatmullRomSpline generates a series of points on a Catmull-Rom spline that passes through the given points.
func (Vec) IsScrollDown ¶
IsScrollDown returns true if the mouse scroll vector is downwards.
func (Vec) IsScrollLeft ¶
IsScrollLeft returns true if the mouse scroll vector is leftwards.
func (Vec) IsScrollRight ¶
IsScrollRight returns true if the mouse scroll vector is rightwards.
func (Vec) IsScrollUp ¶
IsScrollUp returns true if the mouse scroll vector is upwards.
type Window ¶
type Window struct { Framebuffer *FrameBuffer // contains filtered or unexported fields }
Window represents an OS Window.
func NewWindow ¶
NewWindow constructs a new window according to the provided configuration.
Call Destroy to deallocate the window.
func (*Window) Destroy ¶
func (w *Window) Destroy()
Destroy deallocates the window's resources. Call it at the end of your application.
func (*Window) DropKeybinds ¶
func (w *Window) DropKeybinds()
DropKeybinds unregisters all keybinds.
func (*Window) KeyIsPressed ¶
KeyIsPressed returns whether a given key is currently pressed.
func (*Window) MouseButtonState ¶
func (w *Window) MouseButtonState() MouseState
MouseButtonState returns the current state of the mouse buttons.
func (*Window) MouseLocation ¶
MouseLocation returns the location of the mouse cursor, relative to the origin of the window.
func (*Window) RegisterKeybind ¶
func (w *Window) RegisterKeybind(key sdl.Keycode, mode KeybindMode, callback func())
RegisterKeybind sets a callback function which is executed when a key is pressed. The callback can be executed always while the key is pressed, on press, or on release.
func (*Window) SetBackground ¶
SetBackground sets the background to a uniform colour.
func (*Window) SetMouseScrollCallback ¶
func (w *Window) SetMouseScrollCallback(cb MouseScrollCallback)
SetMouseScrollCallback sets a callback to be executed on mouse scroll events.
func (*Window) UnregisterKeybind ¶
func (w *Window) UnregisterKeybind(key sdl.Keycode, mode KeybindMode)
RegisterKeybind removes a keybind for a specific key mode combination.
type WindowCfg ¶
type WindowCfg struct { // Title is the title of the window. Title string // Width, Height specifies the dimensions of the window, in pixels. Width, Height int // Icon is the image used for the window icon. Default if nil. Icon *os.File // Resizable can be set to true to allow the window to be resizable. Resizable bool }
WindowCfg contains adjustable configuration for a window.