Documentation ¶
Index ¶
- Constants
- Variables
- func AddCU(a int32, b int32) int32
- func EasingInOut(easeIn func(float64) float64) func(float64) float64
- func EasingQuadraticIn(point float64) float64
- func InferScale(dpiSource Window) float64
- func Max(a int32, b int32) int32
- func Min(a int32, b int32) int32
- func ModifyScaleBinInt(scale float64) float64
- func Scale(scale float64, target int32) int32
- type Alignment1i
- type Alignment2i
- type Area1i
- func (a Area1i) Align(content int32, x Alignment1i) Area1i
- func (a Area1i) Contains(i int32) bool
- func (a Area1i) Contract(n Area1i) Area1i
- func (a Area1i) Empty() bool
- func (a Area1i) Expand(n Area1i) Area1i
- func (a Area1i) Intersect(b Area1i) Area1i
- func (a Area1i) Normalized() Area1i
- func (a Area1i) Translate(i int32) Area1i
- func (a Area1i) Union(b Area1i) Area1i
- type Area1iGrid3
- type Area2i
- func (a Area2i) Align(content Vec2i, align Alignment2i) Area2i
- func (a Area2i) Contains(v Vec2i) bool
- func (a Area2i) Contract(b Area2i) Area2i
- func (a Area2i) Empty() bool
- func (a Area2i) Expand(b Area2i) Area2i
- func (a Area2i) Intersect(b Area2i) Area2i
- func (a Area2i) Normalized() Area2i
- func (a Area2i) Pos() Vec2i
- func (a Area2i) Size() Vec2i
- func (a Area2i) Translate(v Vec2i) Area2i
- func (a Area2i) Union(b Area2i) Area2i
- type Area2iGrid3x3
- type Backend
- type DrawMode
- type DrawRectCommand
- type KeyEvent
- type MouseButton
- type MouseEvent
- type MouseEventID
- type NormalEvent
- type NormalEventRoute
- type Renderer
- type TextInput
- type Texture
- type Vec2i
- type Window
- type WindowReceiver
Constants ¶
const DrawModeAdd = 2
DrawModeAdd is an "additive" blend mode. `vec4(dst.rgb + src.rgb, dst.a)`
const DrawModeModulate = 3
DrawModeModulate is a "modulate" blend mode. `vec4(dst.rgb * src.rgb, dst.a)`
const DrawModeNoBlending = 1
DrawModeNoBlending disables blending. `src`
const DrawModeNormal = 0
DrawModeNormal is a normal blended draw mode; typically "what you want". `vec4(mix(dst.rgb, src.rgb, src.a), src.a + (dstA * (1 - src.a)))`
const SizeUnlimited int32 = 0x7FFFFFFF
SizeUnlimited is equal to the maximum value an int32 can have, represents an infinite value. Note that 0x80000000 is reserved; -0x7FFFFFFF is considered the definitive 'negative unlimited' value for simplicity's sake.
Variables ¶
var ExitFlag bool = false
ExitFlag when set to true, exits the application.
var TargetFrameTime float64 = 0.05 // 20FPS
TargetFrameTime controls the framerate of the application.
Functions ¶
func EasingInOut ¶
EasingInOut currys a function. Given an ease-in function, returns an ease in-out function.
func EasingQuadraticIn ¶
EasingQuadraticIn is a quadratic ease-in function, which in practice means it just squares the input value.
func InferScale ¶
InferScale infers a 'reasonable scale' for a provided window.
func ModifyScaleBinInt ¶
ModifyScaleBinInt "snaps" the scale to the nearest power-of-two division (if < 1) or the nearest integer (if >= 1)
Types ¶
type Alignment1i ¶
type Alignment1i int8
Alignment1i specifies an alignment preference along an axis.
const AlignEnd Alignment1i = 1
AlignEnd aligns the element at the end (right/bottom).
const AlignMiddle Alignment1i = 0
AlignMiddle aligns the element at the centre.
const AlignStart Alignment1i = -1
AlignStart aligns the element at the start (left/top).
type Alignment2i ¶
type Alignment2i struct { X Alignment1i Y Alignment1i }
Alignment2i contains two Alignment1is (one for each axis).
type Area1i ¶
Area1i is a 1-dimensional axis-aligned area, which is a useful primitive for N-dimensional areas. Please note that Area1i, and by extension Area2i, may malfunction if given infinite values.
func Area1iMargin ¶
Area1iMargin is a quick idiom for a margin of a given size.
func Area1iOfSize ¶
Area1iOfSize returns an Area1i of the given size (covering range inclusive 0 to exclusive size)
func ScaleMargin1 ¶
ScaleMargin1 scales a margin.
func UnionArea1i ¶
UnionArea1i gets an area containing all areas in the given slice
func (Area1i) Align ¶
func (a Area1i) Align(content int32, x Alignment1i) Area1i
Align aligns an area within another.
func (Area1i) Expand ¶
Expand expands an area by a margin, expressed as the area around as if this had zero size.
func (Area1i) Normalized ¶
Normalized replaces empty areas with zeroed areas.
type Area1iGrid3 ¶
Area1iGrid3 is an Area1i split into a left area, the original 'inner' area, and the right area.
func SplitArea1iGrid3 ¶
func SplitArea1iGrid3(outer Area1i, inner Area1i) Area1iGrid3
SplitArea1iGrid3 splits an Area1i into 3 sections using the bounds of an inner Area1i.
func (Area1iGrid3) AsMargin ¶
func (a Area1iGrid3) AsMargin() Area1i
AsMargin returns a margin around the centre Area1i for Expand.
type Area2i ¶
Area2i is the basic rectangle type. Please note that Area2i may malfunction if given infinite values.
func Area2iFromVecs ¶
Area2iFromVecs returns an Area2i made from a position/size vector pair.
func Area2iMargin ¶
Area2iMargin is a quick idiom for a margin of a given size.
func Area2iOfSize ¶
Area2iOfSize returns an Area2i of the given size.
func ScaleMargin2 ¶
ScaleMargin2 scales a margin.
func UnionArea2i ¶
UnionArea2i gets an area containing all areas in the given slice
func (Area2i) Align ¶
func (a Area2i) Align(content Vec2i, align Alignment2i) Area2i
Align aligns an area within another.
func (Area2i) Expand ¶
Expand expands an area by a margin, expressed as the area around as if this had zero size.
func (Area2i) Normalized ¶
Normalized replaces empty areas with zeroed areas.
type Area2iGrid3x3 ¶
type Area2iGrid3x3 struct { A Area2i B Area2i C Area2i D Area2i E Area2i F Area2i G Area2i H Area2i I Area2i }
Area2iGrid3x3 is Area1iGrid3 in two dimensions.
func SplitArea2iGrid3x3 ¶
func SplitArea2iGrid3x3(outer Area2i, inner Area2i) Area2iGrid3x3
SplitArea2iGrid3x3 splits an Area2i into 9 sections using the bounds of an inner Area2i.
func (Area2iGrid3x3) AsMargin ¶
func (a Area2iGrid3x3) AsMargin() Area2i
AsMargin returns a margin around the centre Area2i for Expand.
type Backend ¶
type Backend interface { // Begins the frame loop. Stops when ExitFlag is set to true. Run(ticker func(frameTime float64)) error CreateWindow(name string, size Vec2i, vsync bool, receiver WindowReceiver) (Window, error) CreateTexture(size Vec2i, pixels []uint32) Texture }
Backend is the set of "entrypoint" functions to the core API.
var GlobalBackend Backend
GlobalBackend is the global instance of Backend.
type DrawMode ¶
type DrawMode uint8
DrawMode represents some form of drawing mode for the primitive. (Documentation for these should include a GLSLish equal for those versed in graphics, ideally translated from the SDL2 documentation.)
type DrawRectCommand ¶
type DrawRectCommand struct { // Where to draw Target Area2i // Texture Tex Texture // Area within texture to get pixels from. TexSprite Area2i // Colour [modulation if Texture is given] Colour uint32 // Blending Mode/etc. Mode DrawMode }
DrawRectCommand represents a rectangle-based drawing command.
type KeyEvent ¶
KeyEvent represents a key changing state. It uses the same constants as SDL2 because I never planned for key input to be in here, but then someone said "what about a search box". Nevermind that this opens a massive can of worms...
func (KeyEvent) FyVOffset ¶
func (ke KeyEvent) FyVOffset(amount Vec2i) NormalEvent
FyVOffset implements NormalEvent.FyVOffset
func (KeyEvent) FyVRoute ¶
func (ke KeyEvent) FyVRoute() NormalEventRoute
FyVRoute implements NormalEvent.FyVRoute
type MouseButton ¶
type MouseButton int8
MouseButton describes a mouse button.
const MouseButtonLeft MouseButton = 0
MouseButtonLeft is the left mouse button.
const MouseButtonLength MouseButton = 9
MouseButtonLength is not a real button. You may need to use (int8)(0) in for loops.
const MouseButtonMiddle MouseButton = 1
MouseButtonMiddle is the middle mouse button (Do be warned: Laptop users do not get this in any 'easy to understand' form.)
const MouseButtonNone MouseButton = -1
MouseButtonNone indicates that no button was involved. Only appears for MouseEventMove
const MouseButtonRight MouseButton = 2
MouseButtonRight is the right mouse button
const MouseButtonScrollDown MouseButton = 6
MouseButtonScrollDown is a virtual scroll
const MouseButtonScrollLeft MouseButton = 7
MouseButtonScrollLeft is a virtual scroll
const MouseButtonScrollRight MouseButton = 8
MouseButtonScrollRight is a virtual scroll
const MouseButtonScrollUp MouseButton = 5
MouseButtonScrollUp is a virtual scroll
const MouseButtonX1 MouseButton = 3
MouseButtonX1 is a fancy auxiliary mouse button that not all people have
const MouseButtonX2 MouseButton = 4
MouseButtonX2 is a fancy auxiliary mouse button that not all people have
type MouseEvent ¶
type MouseEvent struct { // Where the mouse is *relative to the receiving element.* Pos Vec2i // Indicates the sub-type of the event. ID MouseEventID // Meaningless for MOUSEEVENT_MOVE. See MOUSEBUTTON_* Button MouseButton }
MouseEvent is a mouse event.
func (MouseEvent) Offset ¶
func (ev MouseEvent) Offset(offset Vec2i) MouseEvent
Offset offsets the mouse event by a given amount.
type MouseEventID ¶
type MouseEventID uint8
MouseEventID describes a type of MouseEvent.
const MouseEventDown MouseEventID = 1
MouseEventDown indicates that the event is because a mouse button was pressed
const MouseEventMove MouseEventID = 0
MouseEventMove indicates that the event is because the mouse was moved.
const MouseEventUp MouseEventID = 2
MouseEventUp indicates that the event is because a mouse button was released
type NormalEvent ¶
type NormalEvent interface { // Indicates how to route the event. FyVRoute() NormalEventRoute // Offset the event by some amount. Apply the same way as MouseEvent. FyVOffset(amount Vec2i) NormalEvent }
NormalEvent is the base of standard, non-special event types
type NormalEventRoute ¶
type NormalEventRoute uint8
NormalEventRoute represents a target for events.
const ( // NormalEventRouteStop Do not forward. NormalEventRouteStop NormalEventRoute = iota // NormalEventRouteFocus Routes to the focused element. NormalEventRouteFocus // NormalEventRouteBroadcast Broadcast to every element. NormalEventRouteBroadcast // NormalEventRouteStructuralBroadcast Broadcast to every element, even if an event-blocking firewall is active. NormalEventRouteStructuralBroadcast )
type Renderer ¶
type Renderer interface { // Draws a DrawRectCommand. DrawRect(DrawRectCommand) // Translates the renderer's target. Use with defer to undo later. Translate(vec Vec2i) // Returns the renderer's translation. Translation() Vec2i // Sets the clip area, relative to the current translation. SetClip(clip Area2i) // Gets the clip area, relative to the current translation. Clip() Area2i // Gets the size of the drawing area. Size() Vec2i // Clears & resets clip/translate/etc. You should do this at the start of frame. Reset(colour uint32) // Calls drawer() while rendering to a texture. All other operations occur within this texture for that duration. Can be stacked; the latest RenderToTexture applies. // 'reserved' does nothing but must be left false. // The resulting texture from this renderer may only be used on this renderer. RenderToTexture(size Vec2i, drawer func(), reserved bool) Texture }
Renderer is an abstract rendering interface.
type TextInput ¶
type TextInput interface { // Called when the text input is made active. FyTOpen() // Area gets the area of the TextInput. FyTArea() Area2i // Sets the candidate buffer. FyTEditing(text string, start int, length int) // Writes into the editing text buffer and clears the candidate buffer. FyTInput(text string) // Called when the text input is changed to any other input. FyTClose() }
TextInput represents a text input.
type Texture ¶
type Texture interface {
Size() Vec2i
}
Texture interface. This is automatically deleted on finalization.
type Vec2i ¶
type Vec2i struct {
X, Y int32
}
Vec2i is the basic 2-dimensional vector type.
func (Vec2i) ConditionalTranspose ¶
ConditionalTranspose conditionally swaps X/Y, which is useful when the coordinate system is variable.
func (Vec2i) Ge ¶
Ge checks if an area of size A could hold an area of size B (with or without spare room).
type Window ¶
type Window interface { Renderer Name() string SetName(name string) Present() Destroy() // Gets the DPI of the window. This can change. Oh well. GetLocalDPI() float64 // Sets the size of the window (if possible) SetSize(size Vec2i) // Gets the text input, or nil for no input (useful to check when unfocusing) TextInput() TextInput // Sets the text input, or nil for no input SetTextInput(input TextInput) }
Window type. This type MAY be user-implemented with the understanding that no Core/CoreExt functions accept Window or Renderer (hence there are no potential issues), and that this is still intended as a Core/CoreExt type so doesn't get the name-prefixing.
type WindowReceiver ¶
type WindowReceiver interface { FyRStart(w Window) FyRTick(time float64) FyRNormalEvent(n NormalEvent) FyRMouseEvent(m MouseEvent) // Note: The window is destroyed after this completes. FyRClose() }
WindowReceiver receives window events.