Documentation ¶
Index ¶
- Constants
- Variables
- func GLGetTime() float64
- func GLRun(run func())
- func RangeTable(table *unicode.RangeTable) []rune
- type Anchor
- type Atlas
- func (a *Atlas) Ascent() float64
- func (a *Atlas) Contains(r rune) bool
- func (a *Atlas) Descent() float64
- func (a *Atlas) DrawRune(prevR, r rune, dot Vec) (rect, frame, bounds Rect, newDot Vec)
- func (a *Atlas) Glyph(r rune) Glyph
- func (a *Atlas) Kern(r0, r1 rune) float64
- func (a *Atlas) LineHeight() float64
- func (a *Atlas) Picture() IPicture
- type Batch
- type Button
- type CacheMode
- type Circle
- func (c Circle) Area() float64
- func (c Circle) Contains(u Vec) bool
- func (c Circle) Formula() (h, k float64)
- func (c Circle) Intersect(d Circle) Circle
- func (c Circle) IntersectLine(l Line) Vec
- func (c Circle) IntersectRect(r Rect) Vec
- func (c Circle) IntersectionPoints(l Line) []Vec
- func (c Circle) Moved(delta Vec) Circle
- func (c Circle) Norm() Circle
- func (c Circle) Resized(radiusDelta float64) Circle
- func (c Circle) String() string
- func (c Circle) Union(d Circle) Circle
- type ComposeMethod
- type ComposeTarget
- type Drawer
- type EndShape
- type GLCanvas
- func (c *GLCanvas) Bounds() Rect
- func (c *GLCanvas) Clear(color color.Color)
- func (c *GLCanvas) Color(at Vec) RGBA
- func (c *GLCanvas) Draw(t ITarget, matrix Matrix)
- func (c *GLCanvas) DrawColorMask(t ITarget, matrix Matrix, mask color.Color)
- func (c *GLCanvas) Frame() *executor.Frame
- func (c *GLCanvas) MakePicture(p IPicture) ITargetPicture
- func (c *GLCanvas) MakeTriangles(t ITriangles) ITargetTriangles
- func (c *GLCanvas) Pixels() []uint8
- func (c *GLCanvas) SetBounds(bounds Rect)
- func (c *GLCanvas) SetColorMask(col color.Color)
- func (c *GLCanvas) SetComposeMethod(cmp ComposeMethod)
- func (c *GLCanvas) SetFragmentShader(src string)
- func (c *GLCanvas) SetMatrix(m Matrix)
- func (c *GLCanvas) SetPixels(pixels []uint8)
- func (c *GLCanvas) SetSmooth(smooth bool)
- func (c *GLCanvas) SetUniform(name string, value interface{})
- func (c *GLCanvas) Smooth() bool
- func (c *GLCanvas) Texture() *executor.Texture
- type GLFrame
- type GLJoystick
- type GLMonitor
- func (m *GLMonitor) BitDepth() (red, green, blue int)
- func (m *GLMonitor) Name() string
- func (m *GLMonitor) PhysicalSize() (width, height float64)
- func (m *GLMonitor) Position() (x, y float64)
- func (m *GLMonitor) RefreshRate() (rate float64)
- func (m *GLMonitor) Size() (width, height float64)
- func (m *GLMonitor) VideoModes() (vmodes []VideoMode)
- type GLPicture
- type GLShader
- type GLTriangles
- func (gt *GLTriangles) ClipRect(i int) (rect Rect, is bool)
- func (gt *GLTriangles) Color(i int) RGBA
- func (gt *GLTriangles) Copy() ITriangles
- func (gt *GLTriangles) CopyVertices()
- func (gt *GLTriangles) Len() int
- func (gt *GLTriangles) Picture(i int) (pic Vec, intensity float64)
- func (gt *GLTriangles) Position(i int) Vec
- func (gt *GLTriangles) SetClipRect(i int, rect Rect)
- func (gt *GLTriangles) SetColor(i int, c RGBA)
- func (gt *GLTriangles) SetLen(length int)
- func (gt *GLTriangles) SetPicture(i int, pic Vec, intensity float64)
- func (gt *GLTriangles) SetPosition(i int, p Vec)
- func (gt *GLTriangles) Shader() *GLShader
- func (gt *GLTriangles) Slice(i, j int) ITriangles
- func (gt *GLTriangles) Update(t ITriangles)
- func (gt *GLTriangles) VertexSlice() *executor.VertexSlice
- type GLWindow
- func (w *GLWindow) Bounds() Rect
- func (w *GLWindow) Canvas() *GLCanvas
- func (w *GLWindow) Clear(c color.Color)
- func (w *GLWindow) Clipboard() string
- func (w *GLWindow) ClipboardText() string
- func (w *GLWindow) Closed() bool
- func (w *GLWindow) Color(at Vec) RGBA
- func (w *GLWindow) CursorVisible() bool
- func (w *GLWindow) Destroy()
- func (w *GLWindow) Focused() bool
- func (w *GLWindow) GetPos() Vec
- func (w *GLWindow) JoystickAxis(js Joystick, axis GamepadAxis) float64
- func (w *GLWindow) JoystickAxisCount(js Joystick) int
- func (w *GLWindow) JoystickButtonCount(js Joystick) int
- func (w *GLWindow) JoystickJustPressed(js Joystick, button GamepadButton) bool
- func (w *GLWindow) JoystickJustReleased(js Joystick, button GamepadButton) bool
- func (w *GLWindow) JoystickName(js Joystick) string
- func (w *GLWindow) JoystickPresent(js Joystick) bool
- func (w *GLWindow) JoystickPressed(js Joystick, button GamepadButton) bool
- func (w *GLWindow) JustPressed(button Button) bool
- func (w *GLWindow) JustReleased(button Button) bool
- func (w *GLWindow) KeysPressed() map[Button]bool
- func (w *GLWindow) MakePicture(p IPicture) ITargetPicture
- func (w *GLWindow) MakeTriangles(t ITriangles) ITargetTriangles
- func (w *GLWindow) Monitor() *GLMonitor
- func (w *GLWindow) MouseInsideWindow() bool
- func (w *GLWindow) MousePosition() Vec
- func (w *GLWindow) MousePreviousPosition() Vec
- func (w *GLWindow) MouseScroll() Vec
- func (w *GLWindow) Pressed(button Button) bool
- func (w *GLWindow) Repeated(button Button) bool
- func (w *GLWindow) SetBounds(bounds Rect)
- func (w *GLWindow) SetClipboard(str string)
- func (w *GLWindow) SetClipboardText(text string)
- func (w *GLWindow) SetClosed(closed bool)
- func (w *GLWindow) SetColorMask(c color.Color)
- func (w *GLWindow) SetComposeMethod(cmp ComposeMethod)
- func (w *GLWindow) SetCursorDisabled()
- func (w *GLWindow) SetCursorVisible(visible bool)
- func (w *GLWindow) SetMatrix(m Matrix)
- func (w *GLWindow) SetMonitor(monitor *GLMonitor)
- func (w *GLWindow) SetMousePosition(v Vec)
- func (w *GLWindow) SetPos(pos Vec)
- func (w *GLWindow) SetSmooth(smooth bool)
- func (w *GLWindow) SetTitle(title string)
- func (w *GLWindow) SetVSync(vsync bool)
- func (w *GLWindow) Show()
- func (w *GLWindow) Smooth() bool
- func (w *GLWindow) SwapBuffers()
- func (w *GLWindow) Typed() string
- func (w *GLWindow) Update()
- func (w *GLWindow) UpdateInput()
- func (w *GLWindow) UpdateInputWait(timeout time.Duration)
- func (w *GLWindow) VSync() bool
- type GamepadAxis
- type GamepadButton
- type Glyph
- type IBasicTarget
- type IMDraw
- func (imd *IMDraw) Circle(radius, thickness float64)
- func (imd *IMDraw) CircleArc(radius, low, high, thickness float64)
- func (imd *IMDraw) Clear()
- func (imd *IMDraw) Draw(t ITarget)
- func (imd *IMDraw) Ellipse(radius Vec, thickness float64)
- func (imd *IMDraw) EllipseArc(radius Vec, low, high, thickness float64)
- func (imd *IMDraw) Line(thickness float64)
- func (imd *IMDraw) MakePicture(p IPicture) ITargetPicture
- func (imd *IMDraw) MakeTriangles(t ITriangles) ITargetTriangles
- func (imd *IMDraw) Polygon(thickness float64)
- func (imd *IMDraw) Push(pts ...Vec)
- func (imd *IMDraw) Rectangle(thickness float64)
- func (imd *IMDraw) Reset()
- func (imd *IMDraw) SetColorMask(color color.Color)
- func (imd *IMDraw) SetMatrix(m Matrix)
- type IPicture
- type IPictureColor
- type ITarget
- type ITargetPicture
- type ITargetTriangles
- type ITriangles
- type ITrianglesClipped
- type ITrianglesColor
- type ITrianglesPicture
- type ITrianglesPosition
- type Joystick
- type Line
- func (l Line) Bounds() Rect
- func (l Line) Center() Vec
- func (l Line) Closest(v Vec) Vec
- func (l Line) Contains(v Vec) bool
- func (l Line) Formula() (m, b float64)
- func (l Line) Intersect(k Line) (Vec, bool)
- func (l Line) IntersectCircle(c Circle) Vec
- func (l Line) IntersectRect(r Rect) Vec
- func (l Line) Len() float64
- func (l Line) Moved(delta Vec) Line
- func (l Line) Rotated(around Vec, angle float64) Line
- func (l Line) Scaled(scale float64) Line
- func (l Line) ScaledXY(around Vec, scale float64) Line
- func (l Line) String() string
- type Matrix
- func (m Matrix) Chained(next Matrix) Matrix
- func (m Matrix) Moved(delta Vec) Matrix
- func (m Matrix) Project(u Vec) Vec
- func (m Matrix) Rotated(around Vec, angle float64) Matrix
- func (m Matrix) Scaled(around Vec, scale float64) Matrix
- func (m Matrix) ScaledXY(around Vec, scale Vec) Matrix
- func (m Matrix) String() string
- func (m Matrix) Unproject(u Vec) Vec
- type PictureRGBA
- func (s *PictureRGBA) Bounds() Rect
- func (s *PictureRGBA) Image() *image.RGBA
- func (s *PictureRGBA) Pixels() []uint8
- func (s *PictureRGBA) SetColor(x int, y int, c color.RGBA)
- func (s *PictureRGBA) SetRGBA(x int, y int, r uint8, g uint8, b uint8, a uint8)
- func (s *PictureRGBA) SetRGBASize(x int, y int, r uint8, g uint8, b uint8, a uint8, size int)
- type RGBA
- type Rect
- func (r Rect) AlignedTo(anchor Anchor) Rect
- func (r Rect) AnchorPos(anchor Anchor) Vec
- func (r Rect) Area() float64
- func (r Rect) Center() Vec
- func (r Rect) Contains(u Vec) bool
- func (r Rect) Edges() [4]Line
- func (r Rect) H() float64
- func (r Rect) Intersect(s Rect) Rect
- func (r Rect) IntersectCircle(c Circle) Vec
- func (r Rect) IntersectLine(l Line) Vec
- func (r Rect) IntersectionPoints(l Line) []Vec
- func (r Rect) Intersects(s Rect) bool
- func (r Rect) Moved(delta Vec) Rect
- func (r Rect) Norm() Rect
- func (r Rect) Resized(anchor, size Vec) Rect
- func (r Rect) ResizedMin(size Vec) Rect
- func (r Rect) Size() Vec
- func (r Rect) String() string
- func (r Rect) Union(s Rect) Rect
- func (r Rect) Vertices() [4]Vec
- func (r Rect) W() float64
- type Sprite
- type Text
- func (txt *Text) AlignedTo(anchor Anchor) *Text
- func (txt *Text) Atlas() *Atlas
- func (txt *Text) Bounds() Rect
- func (txt *Text) BoundsOf(s string) Rect
- func (txt *Text) Clear()
- func (txt *Text) Draw(t ITarget, matrix Matrix)
- func (txt *Text) DrawColorMask(t ITarget, matrix Matrix, mask color.Color)
- func (txt *Text) Write(p []byte) (n int, err error)
- func (txt *Text) WriteByte(c byte) error
- func (txt *Text) WriteRune(r rune) (n int, err error)
- func (txt *Text) WriteString(s string) (n int, err error)
- type TriangleData
- type TrianglesData
- func (td *TrianglesData) ClipRect(i int) (rect Rect, has bool)
- func (td *TrianglesData) Color(i int) RGBA
- func (td *TrianglesData) Copy() ITriangles
- func (td *TrianglesData) Len() int
- func (td *TrianglesData) Picture(i int) (pic Vec, intensity float64)
- func (td *TrianglesData) Position(i int) Vec
- func (td *TrianglesData) SetLen(len int)
- func (td *TrianglesData) Slice(i, j int) ITriangles
- func (td *TrianglesData) Update(t ITriangles)
- type Vec
- func (u Vec) Add(v Vec) Vec
- func (u Vec) Angle() float64
- func (u Vec) Cross(v Vec) float64
- func (u Vec) Dot(v Vec) float64
- func (u Vec) Eq(v Vec) bool
- func (u Vec) Floor() Vec
- func (u Vec) Len() float64
- func (u Vec) Map(f func(float64) float64) Vec
- func (u Vec) Normal() Vec
- func (u Vec) Project(v Vec) Vec
- func (u Vec) Rotated(angle float64) Vec
- func (u Vec) Scaled(c float64) Vec
- func (u Vec) ScaledXY(v Vec) Vec
- func (u Vec) String() string
- func (u Vec) Sub(v Vec) Vec
- func (u Vec) To(v Vec) Vec
- func (u Vec) Unit() Vec
- func (u Vec) XY() (x, y float64)
- type VideoMode
- type WindowConfig
Constants ¶
const ( MouseButton1 = Button(glfw.MouseButton1) MouseButton2 = Button(glfw.MouseButton2) MouseButton3 = Button(glfw.MouseButton3) MouseButton4 = Button(glfw.MouseButton4) MouseButton5 = Button(glfw.MouseButton5) MouseButton6 = Button(glfw.MouseButton6) MouseButton7 = Button(glfw.MouseButton7) MouseButton8 = Button(glfw.MouseButton8) MouseButtonLast = Button(glfw.MouseButtonLast) MouseButtonLeft = Button(glfw.MouseButtonLeft) MouseButtonRight = Button(glfw.MouseButtonRight) MouseButtonMiddle = Button(glfw.MouseButtonMiddle) )
List of all mouse buttons.
const ( KeyUnknown = Button(glfw.KeyUnknown) KeySpace = Button(glfw.KeySpace) KeyApostrophe = Button(glfw.KeyApostrophe) KeyComma = Button(glfw.KeyComma) KeyMinus = Button(glfw.KeyMinus) KeyPeriod = Button(glfw.KeyPeriod) KeySlash = Button(glfw.KeySlash) Key0 = Button(glfw.Key0) Key1 = Button(glfw.Key1) Key2 = Button(glfw.Key2) Key3 = Button(glfw.Key3) Key4 = Button(glfw.Key4) Key5 = Button(glfw.Key5) Key6 = Button(glfw.Key6) Key7 = Button(glfw.Key7) Key8 = Button(glfw.Key8) Key9 = Button(glfw.Key9) KeySemicolon = Button(glfw.KeySemicolon) KeyEqual = Button(glfw.KeyEqual) KeyA = Button(glfw.KeyA) KeyB = Button(glfw.KeyB) KeyC = Button(glfw.KeyC) KeyD = Button(glfw.KeyD) KeyE = Button(glfw.KeyE) KeyF = Button(glfw.KeyF) KeyG = Button(glfw.KeyG) KeyH = Button(glfw.KeyH) KeyI = Button(glfw.KeyI) KeyJ = Button(glfw.KeyJ) KeyK = Button(glfw.KeyK) KeyL = Button(glfw.KeyL) KeyM = Button(glfw.KeyM) KeyN = Button(glfw.KeyN) KeyO = Button(glfw.KeyO) KeyP = Button(glfw.KeyP) KeyQ = Button(glfw.KeyQ) KeyR = Button(glfw.KeyR) KeyS = Button(glfw.KeyS) KeyT = Button(glfw.KeyT) KeyU = Button(glfw.KeyU) KeyV = Button(glfw.KeyV) KeyW = Button(glfw.KeyW) KeyX = Button(glfw.KeyX) KeyY = Button(glfw.KeyY) KeyZ = Button(glfw.KeyZ) KeyLeftBracket = Button(glfw.KeyLeftBracket) KeyBackslash = Button(glfw.KeyBackslash) KeyRightBracket = Button(glfw.KeyRightBracket) KeyGraveAccent = Button(glfw.KeyGraveAccent) KeyWorld1 = Button(glfw.KeyWorld1) KeyWorld2 = Button(glfw.KeyWorld2) KeyEscape = Button(glfw.KeyEscape) KeyEnter = Button(glfw.KeyEnter) KeyTab = Button(glfw.KeyTab) KeyBackspace = Button(glfw.KeyBackspace) KeyInsert = Button(glfw.KeyInsert) KeyDelete = Button(glfw.KeyDelete) KeyRight = Button(glfw.KeyRight) KeyLeft = Button(glfw.KeyLeft) KeyDown = Button(glfw.KeyDown) KeyUp = Button(glfw.KeyUp) KeyPageUp = Button(glfw.KeyPageUp) KeyPageDown = Button(glfw.KeyPageDown) KeyHome = Button(glfw.KeyHome) KeyEnd = Button(glfw.KeyEnd) KeyCapsLock = Button(glfw.KeyCapsLock) KeyScrollLock = Button(glfw.KeyScrollLock) KeyNumLock = Button(glfw.KeyNumLock) KeyPrintScreen = Button(glfw.KeyPrintScreen) KeyPause = Button(glfw.KeyPause) KeyF1 = Button(glfw.KeyF1) KeyF2 = Button(glfw.KeyF2) KeyF3 = Button(glfw.KeyF3) KeyF4 = Button(glfw.KeyF4) KeyF5 = Button(glfw.KeyF5) KeyF6 = Button(glfw.KeyF6) KeyF7 = Button(glfw.KeyF7) KeyF8 = Button(glfw.KeyF8) KeyF9 = Button(glfw.KeyF9) KeyF10 = Button(glfw.KeyF10) KeyF11 = Button(glfw.KeyF11) KeyF12 = Button(glfw.KeyF12) KeyF13 = Button(glfw.KeyF13) KeyF14 = Button(glfw.KeyF14) KeyF15 = Button(glfw.KeyF15) KeyF16 = Button(glfw.KeyF16) KeyF17 = Button(glfw.KeyF17) KeyF18 = Button(glfw.KeyF18) KeyF19 = Button(glfw.KeyF19) KeyF20 = Button(glfw.KeyF20) KeyF21 = Button(glfw.KeyF21) KeyF22 = Button(glfw.KeyF22) KeyF23 = Button(glfw.KeyF23) KeyF24 = Button(glfw.KeyF24) KeyF25 = Button(glfw.KeyF25) KeyKP0 = Button(glfw.KeyKP0) KeyKP1 = Button(glfw.KeyKP1) KeyKP2 = Button(glfw.KeyKP2) KeyKP3 = Button(glfw.KeyKP3) KeyKP4 = Button(glfw.KeyKP4) KeyKP5 = Button(glfw.KeyKP5) KeyKP6 = Button(glfw.KeyKP6) KeyKP7 = Button(glfw.KeyKP7) KeyKP8 = Button(glfw.KeyKP8) KeyKP9 = Button(glfw.KeyKP9) KeyKPDecimal = Button(glfw.KeyKPDecimal) KeyKPDivide = Button(glfw.KeyKPDivide) KeyKPMultiply = Button(glfw.KeyKPMultiply) KeyKPSubtract = Button(glfw.KeyKPSubtract) KeyKPAdd = Button(glfw.KeyKPAdd) KeyKPEnter = Button(glfw.KeyKPEnter) KeyKPEqual = Button(glfw.KeyKPEqual) KeyLeftShift = Button(glfw.KeyLeftShift) KeyLeftControl = Button(glfw.KeyLeftControl) KeyLeftAlt = Button(glfw.KeyLeftAlt) KeyLeftSuper = Button(glfw.KeyLeftSuper) KeyRightShift = Button(glfw.KeyRightShift) KeyRightControl = Button(glfw.KeyRightControl) KeyRightAlt = Button(glfw.KeyRightAlt) KeyRightSuper = Button(glfw.KeyRightSuper) KeyMenu = Button(glfw.KeyMenu) KeyLast = Button(glfw.KeyLast) )
List of all keyboard buttons.
const ( Joystick1 = Joystick(glfw.Joystick1) Joystick2 = Joystick(glfw.Joystick2) Joystick3 = Joystick(glfw.Joystick3) Joystick4 = Joystick(glfw.Joystick4) Joystick5 = Joystick(glfw.Joystick5) Joystick6 = Joystick(glfw.Joystick6) Joystick7 = Joystick(glfw.Joystick7) Joystick8 = Joystick(glfw.Joystick8) Joystick9 = Joystick(glfw.Joystick9) Joystick10 = Joystick(glfw.Joystick10) Joystick11 = Joystick(glfw.Joystick11) Joystick12 = Joystick(glfw.Joystick12) Joystick13 = Joystick(glfw.Joystick13) Joystick14 = Joystick(glfw.Joystick14) Joystick15 = Joystick(glfw.Joystick15) Joystick16 = Joystick(glfw.Joystick16) JoystickLast = Joystick(glfw.JoystickLast) )
List all of the joysticks.
const ( AxisLeftX = GamepadAxis(glfw.AxisLeftX) AxisLeftY = GamepadAxis(glfw.AxisLeftY) AxisRightX = GamepadAxis(glfw.AxisRightX) AxisRightY = GamepadAxis(glfw.AxisRightY) AxisLeftTrigger = GamepadAxis(glfw.AxisLeftTrigger) AxisRightTrigger = GamepadAxis(glfw.AxisRightTrigger) AxisLast = GamepadAxis(glfw.AxisLast) )
Gamepad axis IDs.
const ( ButtonA = GamepadButton(glfw.ButtonA) ButtonB = GamepadButton(glfw.ButtonB) ButtonX = GamepadButton(glfw.ButtonX) ButtonY = GamepadButton(glfw.ButtonY) ButtonLeftBumper = GamepadButton(glfw.ButtonLeftBumper) ButtonRightBumper = GamepadButton(glfw.ButtonRightBumper) ButtonBack = GamepadButton(glfw.ButtonBack) ButtonStart = GamepadButton(glfw.ButtonStart) ButtonGuide = GamepadButton(glfw.ButtonGuide) ButtonLeftThumb = GamepadButton(glfw.ButtonLeftThumb) ButtonRightThumb = GamepadButton(glfw.ButtonRightThumb) ButtonDpadUp = GamepadButton(glfw.ButtonDpadUp) ButtonDpadRight = GamepadButton(glfw.ButtonDpadRight) ButtonDpadDown = GamepadButton(glfw.ButtonDpadDown) ButtonDpadLeft = GamepadButton(glfw.ButtonDpadLeft) ButtonLast = GamepadButton(glfw.ButtonLast) ButtonCross = GamepadButton(glfw.ButtonCross) ButtonCircle = GamepadButton(glfw.ButtonCircle) ButtonSquare = GamepadButton(glfw.ButtonSquare) ButtonTriangle = GamepadButton(glfw.ButtonTriangle) )
Gamepad button IDs.
Variables ¶
var ( Center = Anchor{0.5, 0.5} Top = Anchor{0.5, 0} TopRight = Anchor{0, 0} Right = Anchor{0, 0.5} BottomRight = Anchor{0, 1} Bottom = Anchor{0.5, 1} BottomLeft = Anchor{1, 1} Left = Anchor{1, 0.5} TopLeft = Anchor{1, 0} )
var ASCII []rune
ASCII is a set of all ASCII runes. These runes are codepoints from 32 to 127 inclusive.
var IM = Matrix{1, 0, 0, 1, 0, 0}
IM stands for identity matrix. Does nothing, no transformation.
var RGBAModel = color.ModelFunc(rgbaModel)
RGBAModel converts colors to RGBA format.
var ZR = Rect{Min: ZV, Max: ZV}
ZR is a zero rectangle.
var ZV = Vec{0, 0}
ZV is a zero vector.
Functions ¶
func RangeTable ¶
func RangeTable(table *unicode.RangeTable) []rune
RangeTable takes a *unicode.RangeTable and generates a set of runes contained within that RangeTable.
Types ¶
type Anchor ¶
type Anchor Vec
Anchor is a vector used to define anchors, such as `Center`, `Top`, `TopRight`, etc.
type Atlas ¶
type Atlas struct {
// contains filtered or unexported fields
}
Atlas is a set of pre-drawn glyphs of a fixed set of runes. This allows for efficient text drawing.
var Atlas7x13 *Atlas
Atlas7x13 is an Atlas using basicfont.Face7x13 with the ASCII rune set
func NewAtlas ¶
NewAtlas creates a new Atlas containing glyphs of the union of the given sets of runes (plus unicode.ReplacementChar) from the given font face.
Creating an Atlas is rather expensive, do not create a new Atlas each frame.
Do not destroy or close the font.Face after creating the Atlas. Atlas still uses it.
func (*Atlas) DrawRune ¶
DrawRune returns parameters necessary for drawing a rune glyph.
Rect is a rectangle where the glyph should be positioned. Frame is the glyph frame inside the Atlas's IPicture. NewDot is the new position of the dot.
func (*Atlas) Kern ¶
Kern returns the kerning distance between runes r0 and r1. Positive distance means that the glyphs should be further apart.
func (*Atlas) LineHeight ¶
LineHeight returns the recommended vertical distance between two lines of text.
type Batch ¶
type Batch struct {
// contains filtered or unexported fields
}
Batch is a ITarget that allows for efficient drawing of many objects with the same IPicture.
To put an object into a Batch, just draw it onto it:
object.Draw(batch)
func NewBatch ¶
func NewBatch(container ITriangles, pic IPicture) *Batch
NewBatch creates an empty Batch with the specified IPicture and container.
The container is where objects get accumulated. Batch will support precisely those ITriangles properties, that the supplied container supports. If you retain access to the container and change it, call Dirty to notify Batch about the change.
Note, that if the container does not support ITrianglesColor, color masking will not work.
func (*Batch) Dirty ¶
func (b *Batch) Dirty()
Dirty notifies Batch about an external modification of it's container. If you retain access to the Batch's container and change it, call Dirty to notify Batch about the change.
container := &pixel.TrianglesData{} batch := pixel.NewBatch(container, nil) container.SetLen(10) // container changed from outside of Batch batch.Dirty() // notify Batch about the change
func (*Batch) MakePicture ¶
func (b *Batch) MakePicture(p IPicture) ITargetPicture
MakePicture returns a specialized copy of the provided IPicture that draws onto this Batch.
func (*Batch) MakeTriangles ¶
func (b *Batch) MakeTriangles(t ITriangles) ITargetTriangles
MakeTriangles returns a specialized copy of the provided ITriangles that draws onto this Batch.
func (*Batch) SetColorMask ¶
SetColorMask sets a mask color used in the following draws onto the Batch.
type Circle ¶
func MakeCircle ¶
func (Circle) Intersect ¶
Intersect returns the maximal Circle which is covered by both `c` and `d`.
If `c` and `d` don't overlap, this function returns a zero-sized circle at the centerpoint between the two Circle's centers.
func (Circle) IntersectLine ¶
IntersectLine will return the shortest Vec such that if the Circle is moved by the Vec returned, the Line and Rect no longer intersect.
func (Circle) IntersectRect ¶
IntersectRect returns a minimal required Vector, such that moving the circle by that vector would stop the Circle and the Rect intersecting. This function returns a zero-vector if the Circle and Rect do not overlap, and if only the perimeters touch.
This function will return a non-zero vector if:
- The Rect contains the Circle, partially or fully
- The Circle contains the Rect, partially of fully
func (Circle) IntersectionPoints ¶
IntersectionPoints returns all the points where the Circle intersects with the line provided. This can be zero, one or two points, depending on the location of the shapes. The points of intersection will be returned in order of closest-to-l.A to closest-to-l.B.
type ComposeMethod ¶
type ComposeMethod int
ComposeMethod is a Porter-Duff composition method.
const ( ComposeOver ComposeMethod = iota ComposeIn ComposeOut ComposeAtop ComposeRover ComposeRin ComposeRout ComposeRatop ComposeXor ComposePlus ComposeCopy )
Here's the list of all available Porter-Duff composition methods. Use ComposeOver for the basic alpha blending.
func (ComposeMethod) Compose ¶
func (cm ComposeMethod) Compose(a, b RGBA) RGBA
Compose composes two colors together according to the ComposeMethod. A is the foreground, B is the background.
type ComposeTarget ¶
type ComposeTarget interface { IBasicTarget // SetComposeMethod sets a Porter-Duff composition method to be used. SetComposeMethod(ComposeMethod) }
ComposeTarget is a IBasicTarget capable of Porter-Duff composition.
type Drawer ¶
type Drawer struct { Triangles ITriangles Picture IPicture Cached CacheMode // contains filtered or unexported fields }
Drawer glues all the fundamental interfaces (ITarget, ITriangles, IPicture) into a coherent and the only intended usage pattern.
Drawer makes it possible to draw any combination of ITriangles and IPicture onto any ITarget efficiently.
To create a Drawer, just assign it's ITriangles and IPicture fields:
d := pixel.Drawer{ITriangles: t, IPicture: p}
If ITriangles is nil, nothing will be drawn. If IPicture is nil, ITriangles will be drawn without a IPicture.
Whenever you change the ITriangles, call Dirty to notify Drawer that ITriangles changed. You don't need to notify Drawer about a change of the IPicture.
Note, that Drawer caches the results of MakePicture from Targets it's drawn to for each IPicture it's set to. What it means is that using a Drawer with an unbounded number of Pictures leads to a memory leak, since Drawer caches them and never forgets. In such a situation, create a new Drawer for each IPicture.
type GLCanvas ¶
type GLCanvas struct {
// contains filtered or unexported fields
}
GLCanvas is an off-screen rectangular IBasicTarget and IPicture at the same time, that you can draw onto.
It supports ITrianglesPosition, ITrianglesColor, ITrianglesPicture and IPictureColor.
func NewGLCanvas ¶
NewGLCanvas creates a new empty, fully transparent GLCanvas with given bounds.
func (*GLCanvas) Color ¶
Color returns the color of the pixel over the given position inside the GLCanvas.
func (*GLCanvas) Draw ¶
Draw draws the content of the GLCanvas onto another ITarget, transformed by the given Matrix, just like if it was a Sprite containing the whole GLCanvas.
func (*GLCanvas) DrawColorMask ¶
DrawColorMask draws the content of the GLCanvas onto another ITarget, transformed by the given Matrix and multiplied by the given mask, just like if it was a Sprite containing the whole GLCanvas.
If the color mask is nil, a fully opaque white mask will be used causing no effect.
func (*GLCanvas) MakePicture ¶
func (c *GLCanvas) MakePicture(p IPicture) ITargetPicture
MakePicture create a specialized copy of the supplied IPicture that draws onto this GLCanvas.
IPictureColor is supported.
func (*GLCanvas) MakeTriangles ¶
func (c *GLCanvas) MakeTriangles(t ITriangles) ITargetTriangles
MakeTriangles creates a specialized copy of the supplied ITriangles that draws onto this GLCanvas.
ITrianglesPosition, ITrianglesColor and ITrianglesPicture are supported.
func (*GLCanvas) Pixels ¶
Pixels returns an alpha-premultiplied RGBA sequence of the content of the GLCanvas.
func (*GLCanvas) SetBounds ¶
SetBounds resizes the GLCanvas to the new bounds. Old content will be preserved.
func (*GLCanvas) SetColorMask ¶
SetColorMask sets a color that every color in triangles or a picture will be multiplied by.
func (*GLCanvas) SetComposeMethod ¶
func (c *GLCanvas) SetComposeMethod(cmp ComposeMethod)
SetComposeMethod sets a Porter-Duff composition method to be used in the following draws onto this GLCanvas.
func (*GLCanvas) SetFragmentShader ¶
SetFragmentShader allows you to set a new fragment shader on the underlying framebuffer. Argument "src" is the GLSL source, not a filename.
func (*GLCanvas) SetPixels ¶
SetPixels replaces the content of the GLCanvas with the provided pixels. The provided slice must be an alpha-premultiplied RGBA sequence of correct length (4 * width * height).
func (*GLCanvas) SetSmooth ¶
SetSmooth sets whether stretched Pictures drawn onto this GLCanvas should be drawn smooth or pixely.
func (*GLCanvas) SetUniform ¶
SetUniform will update the named uniform with the value of any supported underlying attribute variable. If the uniform already exists, including defaults, they will be reassigned to the new value. The value can be a pointer.
type GLJoystick ¶
type GLJoystick struct {
// contains filtered or unexported fields
}
type GLMonitor ¶
type GLMonitor struct {
// contains filtered or unexported fields
}
GLMonitor represents a physical display attached to your computer.
func Monitors ¶
func Monitors() []*GLMonitor
Monitors returns a slice of all currently available monitors.
func PrimaryMonitor ¶
func PrimaryMonitor() *GLMonitor
PrimaryMonitor returns the main monitor (usually the one with the taskbar and stuff).
func (*GLMonitor) PhysicalSize ¶
PhysicalSize returns the size of the display area of the GLMonitor in millimeters.
func (*GLMonitor) Position ¶
Position returns the position of the upper-left corner of the GLMonitor in screen coordinates.
func (*GLMonitor) RefreshRate ¶
RefreshRate returns the refresh frequency of the GLMonitor in Hz (refreshes/second).
func (*GLMonitor) VideoModes ¶
VideoModes returns all available video modes for the monitor.
type GLPicture ¶
type GLPicture interface { IPictureColor Texture() *executor.Texture Update(p IPicture) }
func NewGLPicture ¶
type GLShader ¶
type GLShader struct {
// contains filtered or unexported fields
}
func NewGLShader ¶
func (*GLShader) SetUniform ¶
type GLTriangles ¶
type GLTriangles struct {
// contains filtered or unexported fields
}
func NewGLTriangles ¶
func NewGLTriangles(shader *GLShader, t ITriangles) *GLTriangles
NewGLTriangles returns GLTriangles initialized with the data from the supplied ITriangles.
Only draw the ITriangles using the provided Shader.
func (*GLTriangles) ClipRect ¶
func (gt *GLTriangles) ClipRect(i int) (rect Rect, is bool)
ClipRect returns the Clipping rectangle property of the i-th vertex.
func (*GLTriangles) Color ¶
func (gt *GLTriangles) Color(i int) RGBA
Color returns the Color property of the i-th vertex.
func (*GLTriangles) Copy ¶
func (gt *GLTriangles) Copy() ITriangles
func (*GLTriangles) CopyVertices ¶
func (gt *GLTriangles) CopyVertices()
CopyVertices copies the GLTriangle data down to the vertex data.
func (*GLTriangles) Picture ¶
func (gt *GLTriangles) Picture(i int) (pic Vec, intensity float64)
IPicture returns the IPicture property of the i-th vertex.
func (*GLTriangles) Position ¶
func (gt *GLTriangles) Position(i int) Vec
Position returns the Position property of the i-th vertex.
func (*GLTriangles) SetClipRect ¶
func (gt *GLTriangles) SetClipRect(i int, rect Rect)
SetClipRect sets the Clipping rectangle property of the i-th vertex.
func (*GLTriangles) SetColor ¶
func (gt *GLTriangles) SetColor(i int, c RGBA)
SetColor sets the color property of the i-th vertex.
func (*GLTriangles) SetLen ¶
func (gt *GLTriangles) SetLen(length int)
SetLen efficiently resizes GLTriangles to len.
Time complexity is amortized O(1).
func (*GLTriangles) SetPicture ¶
func (gt *GLTriangles) SetPicture(i int, pic Vec, intensity float64)
SetPicture sets the picture property of the i-th vertex.
func (*GLTriangles) SetPosition ¶
func (gt *GLTriangles) SetPosition(i int, p Vec)
SetPosition sets the position property of the i-th vertex.
func (*GLTriangles) Shader ¶
func (gt *GLTriangles) Shader() *GLShader
Shader returns the GLTriangles's associated shader.
func (*GLTriangles) Slice ¶
func (gt *GLTriangles) Slice(i, j int) ITriangles
Slice returns a sub-ITriangles of this GLTriangles in range [i, j).
func (*GLTriangles) Update ¶
func (gt *GLTriangles) Update(t ITriangles)
Update copies vertex properties from the supplied ITriangles into this GLTriangles.
The two ITriangles (gt and t) must be of the same len.
func (*GLTriangles) VertexSlice ¶
func (gt *GLTriangles) VertexSlice() *executor.VertexSlice
VertexSlice returns the VertexSlice of this GLTriangles.
You can use it to draw them.
type GLWindow ¶
type GLWindow struct {
// contains filtered or unexported fields
}
func NewGLWindow ¶
func NewGLWindow(cfg WindowConfig) (*GLWindow, error)
func (*GLWindow) ClipboardText ¶
ClipboardText returns the current value of the systems clipboard.
func (*GLWindow) Closed ¶
Closed returns the closed flag of the GLWindow, which reports whether the GLWindow should be closed.
The closed flag is automatically set when a user attempts to close the GLWindow.
func (*GLWindow) Color ¶
Color returns the color of the pixel over the given position inside the GLWindow.
func (*GLWindow) CursorVisible ¶
CursorVisible returns the visibility status of the mouse cursor.
func (*GLWindow) Destroy ¶
func (w *GLWindow) Destroy()
Destroy destroys the GLWindow. The GLWindow can't be used any further.
func (*GLWindow) GetPos ¶
GetPos gets the position, in screen coordinates, of the upper-left corner of the client area of the window. The position is rounded to integers.
func (*GLWindow) JoystickAxis ¶
func (w *GLWindow) JoystickAxis(js Joystick, axis GamepadAxis) float64
JoystickAxis returns the value of a joystick axis at the last call to GLWindow.Update. If the axis index is out of range, this will return 0.
This API is experimental.
func (*GLWindow) JoystickAxisCount ¶
JoystickAxisCount returns the number of axes a connected joystick has.
This API is experimental.
func (*GLWindow) JoystickButtonCount ¶
JoystickButtonCount returns the number of buttons a connected joystick has.
This API is experimental.
func (*GLWindow) JoystickJustPressed ¶
func (w *GLWindow) JoystickJustPressed(js Joystick, button GamepadButton) bool
JoystickJustPressed returns whether the joystick Button has just been pressed down. If the button index is out of range, this will return false.
This API is experimental.
func (*GLWindow) JoystickJustReleased ¶
func (w *GLWindow) JoystickJustReleased(js Joystick, button GamepadButton) bool
JoystickJustReleased returns whether the joystick Button has just been released up. If the button index is out of range, this will return false.
This API is experimental.
func (*GLWindow) JoystickName ¶
JoystickName returns the name of the joystick. A disconnected joystick will return an empty string.
This API is experimental.
func (*GLWindow) JoystickPresent ¶
JoystickPresent returns if the joystick is currently connected.
This API is experimental.
func (*GLWindow) JoystickPressed ¶
func (w *GLWindow) JoystickPressed(js Joystick, button GamepadButton) bool
JoystickPressed returns whether the joystick Button is currently pressed down. If the button index is out of range, this will return false.
This API is experimental.
func (*GLWindow) JustPressed ¶
JustPressed returns whether the Button has been pressed in the last frame.
func (*GLWindow) JustReleased ¶
JustReleased returns whether the Button has been released in the last frame.
func (*GLWindow) KeysPressed ¶
func (*GLWindow) MakePicture ¶
func (w *GLWindow) MakePicture(p IPicture) ITargetPicture
MakePicture generates a specialized copy of the supplied IPicture that will draw onto this GLWindow.
GLWindow supports IPictureColor.
func (*GLWindow) MakeTriangles ¶
func (w *GLWindow) MakeTriangles(t ITriangles) ITargetTriangles
MakeTriangles generates a specialized copy of the supplied ITriangles that will draw onto this GLWindow.
GLWindow supports ITrianglesPosition, ITrianglesColor and ITrianglesPicture.
func (*GLWindow) Monitor ¶
GLMonitor returns a monitor the GLWindow is fullscreen on. If the GLWindow is not fullscreen, this function returns nil.
func (*GLWindow) MouseInsideWindow ¶
MouseInsideWindow returns true if the mouse position is within the GLWindow's Bounds.
func (*GLWindow) MousePosition ¶
MousePosition returns the current mouse position in the GLWindow's Bounds.
func (*GLWindow) MousePreviousPosition ¶
MousePreviousPosition returns the previous mouse position in the GLWindow's Bounds.
func (*GLWindow) MouseScroll ¶
MouseScroll returns the mouse scroll amount (in both axes) since the last call to GLWindow.Update.
func (*GLWindow) Repeated ¶
Repeated returns whether a repeat event has been triggered on button.
Repeat event occurs repeatedly when a button is held down for some time.
func (*GLWindow) SetBounds ¶
SetBounds sets the bounds of the GLWindow in pixels. Bounds can be fractional, but the actual size of the window will be rounded to integers.
func (*GLWindow) SetClipboard ¶
SetClipboardString sets the system clipboard to the specified UTF-8 encoded string.
func (*GLWindow) SetClipboardText ¶
SetClipboardText passes the given string to the underlying glfw window to set the systems clipboard.
func (*GLWindow) SetClosed ¶
SetClosed sets the closed flag of the GLWindow.
This is useful when overriding the user's attempt to close the GLWindow, or just to close the GLWindow from within the program.
func (*GLWindow) SetColorMask ¶
SetColorMask sets a global color mask for the GLWindow.
func (*GLWindow) SetComposeMethod ¶
func (w *GLWindow) SetComposeMethod(cmp ComposeMethod)
SetComposeMethod sets a Porter-Duff composition method to be used in the following draws onto this GLWindow.
func (*GLWindow) SetCursorDisabled ¶
func (w *GLWindow) SetCursorDisabled()
SetCursorDisabled hides the cursor and provides unlimited virtual cursor movement make cursor visible using SetCursorVisible
func (*GLWindow) SetCursorVisible ¶
SetCursorVisible sets the visibility of the mouse cursor inside the GLWindow client area.
func (*GLWindow) SetMonitor ¶
SetMonitor sets the GLWindow fullscreen on the given GLMonitor. If the GLMonitor is nil, the GLWindow will be restored to windowed state instead.
The GLWindow will be automatically set to the GLMonitor's resolution. If you want a different resolution, you will need to set it manually with SetBounds method.
func (*GLWindow) SetMousePosition ¶
SetMousePosition positions the mouse cursor anywhere within the GLWindow's Bounds.
func (*GLWindow) SetPos ¶
SetPos sets the position, in screen coordinates, of the upper-left corner of the client area of the window. Position can be fractional, but the actual position of the window will be rounded to integers.
If it is a full screen window, this function does nothing.
func (*GLWindow) SetSmooth ¶
SetSmooth sets whether the stretched Pictures drawn onto this GLWindow should be drawn smooth or pixelated.
func (*GLWindow) SetVSync ¶
SetVSync sets whether the GLWindow's Update should synchronize with the monitor refresh rate.
func (*GLWindow) Show ¶
func (w *GLWindow) Show()
Show makes the window visible, if it was previously hidden. If the window is already visible or is in full screen mode, this function does nothing.
func (*GLWindow) Smooth ¶
Smooth returns whether the stretched Pictures drawn onto this GLWindow are set to be drawn smooth or pixelated.
func (*GLWindow) SwapBuffers ¶
func (w *GLWindow) SwapBuffers()
SwapBuffers swaps buffers. Call this to swap buffers without polling window events. Note that Update invokes SwapBuffers.
func (*GLWindow) Typed ¶
Typed returns the text typed on the keyboard since the last call to GLWindow.Update.
func (*GLWindow) Update ¶
func (w *GLWindow) Update()
Update swaps buffers and polls events. Call this method at the end of each frame.
func (*GLWindow) UpdateInput ¶
func (w *GLWindow) UpdateInput()
UpdateInput polls window events. Call this function to poll window events without swapping buffers. Note that the Update method invokes UpdateInput.
func (*GLWindow) UpdateInputWait ¶
UpdateInputWait blocks until an event is received or a timeout. If timeout is 0 then it will wait indefinitely
type IBasicTarget ¶
type IBasicTarget interface { ITarget // SetMatrix sets a Matrix that every point will be projected by. SetMatrix(Matrix) // SetColorMask sets a color that will be multiplied with the ITrianglesColor property of all // ITriangles. SetColorMask(color.Color) }
IBasicTarget is a ITarget with additional basic adjustment methods.
type IMDraw ¶
type IMDraw struct { Color color.Color Picture Vec Intensity float64 Precision int EndShape EndShape // contains filtered or unexported fields }
func (*IMDraw) Circle ¶
Circle draws a circle of the specified radius around each Pushed point. If the thickness is 0, the circle will be filled, otherwise a circle outline of the specified thickness will be drawn.
func (*IMDraw) CircleArc ¶
CircleArc draws a circle arc of the specified radius around each Pushed point. If the thickness is 0, the arc will be filled, otherwise will be outlined. The arc starts at the low angle and continues to the high angle. If low<high, the arc will be drawn counterclockwise. Otherwise it will be clockwise. The angles are not normalized by any means.
imd.CircleArc(40, 0, 8*math.Pi, 0)
This line will fill the whole circle 4 times.
func (*IMDraw) Draw ¶
Draw draws all currently drawn shapes inside the IM onto another ITarget.
Note, that IMDraw's matrix and color mask have no effect here.
func (*IMDraw) Ellipse ¶
Ellipse draws an ellipse of the specified radius in each axis around each Pushed points. If the thickness is 0, the ellipse will be filled, otherwise an ellipse outline of the specified thickness will be drawn.
func (*IMDraw) EllipseArc ¶
EllipseArc draws an ellipse arc of the specified radius in each axis around each Pushed point. If the thickness is 0, the arc will be filled, otherwise will be outlined. The arc starts at the low angle and continues to the high angle. If low<high, the arc will be drawn counterclockwise. Otherwise it will be clockwise. The angles are not normalized by any means.
imd.EllipseArc(pixel.V(100, 50), 0, 8*math.Pi, 0)
This line will fill the whole ellipse 4 times.
func (*IMDraw) MakePicture ¶
func (imd *IMDraw) MakePicture(p IPicture) ITargetPicture
MakePicture returns a specialized copy of the provided IPicture that draws onto this IMDraw.
func (*IMDraw) MakeTriangles ¶
func (imd *IMDraw) MakeTriangles(t ITriangles) ITargetTriangles
MakeTriangles returns a specialized copy of the provided ITriangles that draws onto this IMDraw.
func (*IMDraw) Polygon ¶
Polygon draws a polygon from the Pushed points. If the thickness is 0, the convex polygon will be filled. Otherwise, an outline of the specified thickness will be drawn. The outline does not have to be convex.
Note, that the filled polygon does not have to be strictly convex. The way it's drawn is that a triangle is drawn between each two adjacent points and the first Pushed point. You can use this property to draw certain kinds of concave polygons.
func (*IMDraw) Push ¶
Push adds some points to the IM queue. All Pushed points will have the same properties except for the position.
func (*IMDraw) Rectangle ¶
Rectangle draws a rectangle between each two subsequent Pushed points. Drawing a rectangle between two points means drawing a rectangle with sides parallel to the axes of the coordinate system, where the two points specify it's two opposite corners.
If the thickness is 0, rectangles will be filled, otherwise will be outlined with the given thickness.
func (*IMDraw) Reset ¶
func (imd *IMDraw) Reset()
Reset restores all point properties to defaults and removes all Pushed points.
This does not affect matrix and color mask set by SetMatrix and SetColorMask.
func (*IMDraw) SetColorMask ¶
SetColorMask sets a color that all further point's color will be multiplied by.
type IPicture ¶
type IPicture interface { // Bounds returns the rectangle of the IPicture. All data is located with this rectangle. // Querying properties outside the rectangle should return default value of that property. Bounds() Rect }
IPicture represents a rectangular area of raster data, such as a color. It has Bounds which specify the rectangle where data is located.
type IPictureColor ¶
IPictureColor specifies IPicture with Color property, so that every position inside the IPicture's Bounds has a color.
Positions outside the IPicture's Bounds must return full transparent (Alpha(0)).
type ITarget ¶
type ITarget interface { // MakeTriangles generates a specialized copy of the provided ITriangles. // // When calling Draw method on the returned ITargetTriangles, the ITargetTriangles will be // drawn onto the ITarget that generated them. // // Note, that not every ITarget has to recognize all possible types of ITriangles. Some may // only recognize ITrianglesPosition and ITrianglesColor and ignore all other properties (if // present) when making new ITargetTriangles. This varies from ITarget to ITarget. MakeTriangles(ITriangles) ITargetTriangles // MakePicture generates a specialized copy of the provided IPicture. // // When calling Draw method on the returned ITargetPicture, the ITargetPicture will be drawn // onto the ITarget that generated it together with the ITargetTriangles supplied to the Draw // method. MakePicture(IPicture) ITargetPicture }
ITarget is something that can be drawn onto, such as a window, a canvas, and so on.
You can notice, that there are no "drawing" methods in a ITarget. That's because all drawing happens indirectly through ITriangles and IPicture instances generated via MakeTriangles and MakePicture method.
type ITargetPicture ¶
type ITargetPicture interface { IPicture // Draw draws the supplied ITargetTriangles (which must be generated by the same ITarget as // this ITargetPicture) with this ITargetPicture. The ITargetTriangles should utilize the data // from this ITargetPicture in some way. Draw(ITargetTriangles) Update(p IPicture) }
ITargetPicture is a IPicture generated by a ITarget using MakePicture method. This IPicture can be drawn onto that (no other) ITarget together with a ITargetTriangles generated by the same ITarget.
The ITargetTriangles specify where, shape and how the IPicture should be drawn.
type ITargetTriangles ¶
type ITargetTriangles interface { ITriangles // Draw draws ITriangles onto an associated ITarget. Draw() }
ITargetTriangles are ITriangles generated by a ITarget with MakeTriangles method. They can be drawn onto that (no other) ITarget.
type ITriangles ¶
type ITriangles interface { // Len returns the number of vertices. The number of triangles is the number of vertices // divided by 3. Len() int // SetLen resizes ITriangles to len vertices. If ITriangles B were obtained by calling Slice // method on ITriangles A, the relationship between A and B is undefined after calling SetLen // on either one of them. SetLen(len int) // Slice returns a sub-ITriangles of this ITriangles, covering vertices in range [i, j). // // If ITriangles B were obtained by calling Slice(4, 9) on ITriangles A, then A and B must // share the same underlying data. Modifying B must change the contents of A in range // [4, 9). The vertex with index 0 at B is the vertex with index 4 in A, and so on. // // Returned ITriangles must have the same underlying type. Slice(i, j int) ITriangles // Update copies vertex properties from the supplied ITriangles into this ITriangles. // // Properties not supported by these ITriangles should be ignored. Properties not supported by // the supplied ITriangles should be left untouched. // // The two ITriangles must have the same Len. Update(ITriangles) // Copy creates an exact independent copy of this ITriangles (with the same underlying type). Copy() ITriangles }
ITriangles represents a list of vertices, where each three vertices form a triangle. (First, second and third is the first triangle, fourth, fifth and sixth is the second triangle, etc.)
type ITrianglesClipped ¶
type ITrianglesClipped interface { ITriangles ClipRect(i int) (rect Rect, is bool) }
ITrianglesClipped specifies ITriangles with Clipping Rectangle property.
The first value returned from ClipRect method is the clipping rectangle. The second one specifies if the triangle is clipped.
type ITrianglesColor ¶
type ITrianglesColor interface { ITriangles Color(i int) RGBA }
ITrianglesColor specifies ITriangles with Color property.
type ITrianglesPicture ¶
type ITrianglesPicture interface { ITriangles Picture(i int) (pic Vec, intensity float64) }
ITrianglesPicture specifies ITriangles with IPicture property.
The first value returned from IPicture method is IPicture coordinates. The second one specifies the weight of the IPicture. Value of 0 means, that IPicture should be completely ignored, 1 means that is should be fully included and anything in between means anything in between.
type ITrianglesPosition ¶
type ITrianglesPosition interface { ITriangles Position(i int) Vec }
ITrianglesPosition specifies ITriangles with Position property.
type Line ¶
type Line struct {
A, B Vec
}
Line is a 2D line segment, between points A and B.
func (Line) Bounds ¶
Bounds returns the lines bounding box. This is in the form of a normalized Rect.
func (Line) Center ¶
Center will return the point at center of the line; that is, the point equidistant from either end.
func (Line) Closest ¶
Closest will return the point on the line which is closest to the Vec provided.
func (Line) Formula ¶
Formula will return the values that represent the line in the formula: y = mx + b This function will return math.Inf+, math.Inf- for a vertical line.
func (Line) Intersect ¶
Intersect will return the point of intersection for the two line segments. If the line segments do not intersect, this function will return the zero-vector and false.
func (Line) IntersectCircle ¶
IntersectCircle will return the shortest Vec such that moving the Line by that Vec will cause the Line and Circle to no longer intesect. If they do not intersect at all, this function will return a zero-vector.
func (Line) IntersectRect ¶
IntersectRect will return the shortest Vec such that moving the Line by that Vec will cause the Line and Rect to no longer intesect. If they do not intersect at all, this function will return a zero-vector.
type Matrix ¶
type Matrix [6]float64
Matrix is a 2x3 affine matrix that can be used for all kinds of spatial transforms, such as movement, scaling and rotations.
Matrix has a handful of useful methods, each of which adds a transformation to the matrix. For example:
pixel.IM.Moved(pixel.V(100, 200)).Rotated(pixel.ZV, math.Pi/2)
This code creates a Matrix that first moves everything by 100 units horizontally and 200 units vertically and then rotates everything by 90 degrees around the origin.
Layout is: [0] [2] [4] [1] [3] [5]
0 0 1 (implicit row)
func (Matrix) Chained ¶
Chained adds another Matrix to this one. All tranformations by the next Matrix will be applied after the transformations of this Matrix.
func (Matrix) Project ¶
Project applies all transformations added to the Matrix to a vector u and returns the result.
Time complexity is O(1).
func (Matrix) Rotated ¶
Rotated rotates everything around a given point by the given angle in radians.
func (Matrix) ScaledXY ¶
ScaledXY scales everything around a given point by the scale factor in each axis respectively.
type PictureRGBA ¶
type PictureRGBA struct {
// contains filtered or unexported fields
}
func NewPictureRGBA ¶
func NewPictureRGBA(rect Rect) *PictureRGBA
func NewPictureRGBAFromImage ¶
func NewPictureRGBAFromImage(img image.Image) *PictureRGBA
func NewPictureRGBAFromPicture ¶
func NewPictureRGBAFromPicture(pic IPicture) *PictureRGBA
func (*PictureRGBA) Bounds ¶
func (s *PictureRGBA) Bounds() Rect
func (*PictureRGBA) Image ¶
func (s *PictureRGBA) Image() *image.RGBA
func (*PictureRGBA) Pixels ¶
func (s *PictureRGBA) Pixels() []uint8
func (*PictureRGBA) SetRGBASize ¶
type RGBA ¶
type RGBA struct {
R, G, B, A float64
}
RGBA represents an alpha-premultiplied RGBA color with components within range [0, 1].
The difference between color.RGBA is that the value range is [0, 1] and the values are floats.
func RGB ¶
RGB returns a fully opaque RGBA color with the given RGB values.
A common way to construct a transparent color is to create one with RGB constructor, then multiply it by a color obtained from the Alpha constructor.
func ToRGBA ¶
ToRGBA converts a color to RGBA format. Using this function is preferred to using RGBAModel, for performance (using RGBAModel introduces additional unnecessary allocations).
func (RGBA) Add ¶
Add adds color d to color c component-wise and returns the result (the components are not clamped).
func (RGBA) Mul ¶
Mul multiplies color c by color d component-wise (the components are not clamped).
func (RGBA) RGBA ¶
RGBA returns alpha-premultiplied red, green, blue and alpha components of the RGBA color.
type Rect ¶
Rect is a 2D rectangle aligned with the axes of the coordinate system. It is defined by two points, Min and Max.
The invariant should hold, that Max's components are greater or equal than Min's components respectively.
func R ¶
R returns a new Rect with given the Min and Max coordinates.
Note that the returned rectangle is not automatically normalized.
func (Rect) Center ¶
Center returns the position of the center of the Rect. `rect.Center()` is equivalent to `rect.Anchor(pixel.Anchor.Center)`
func (Rect) Contains ¶
Contains checks whether a vector u is contained within this Rect (including it's borders).
func (Rect) Intersect ¶
Intersect returns the maximal Rect which is covered by both r and s. Rects r and s must be normalized.
If r and s don't overlap, this function returns a zero-rectangle.
func (Rect) IntersectCircle ¶
IntersectCircle returns a minimal required Vector, such that moving the rect by that vector would stop the Circle and the Rect intersecting. This function returns a zero-vector if the Circle and Rect do not overlap, and if only the perimeters touch.
This function will return a non-zero vector if:
- The Rect contains the Circle, partially or fully
- The Circle contains the Rect, partially of fully
func (Rect) IntersectLine ¶
IntersectLine will return the shortest Vec such that if the Rect is moved by the Vec returned, the Line and Rect no longer intersect.
func (Rect) IntersectionPoints ¶
IntersectionPoints returns all the points where the Rect intersects with the line provided. This can be zero, one or two points, depending on the location of the shapes. The points of intersection will be returned in order of closest-to-l.A to closest-to-l.B.
func (Rect) Intersects ¶
Intersects returns whether or not the given Rect intersects at any point with this Rect.
This function is overall about 5x faster than Intersect, so it is better to use if you have no need for the returned Rect from Intersect.
func (Rect) Norm ¶
Norm returns the Rect in normal form, such that Max is component-wise greater or equal than Min.
func (Rect) Resized ¶
Resized returns the Rect resized to the given size while keeping the position of the given anchor.
r.Resized(r.Min, size) // resizes while keeping the position of the lower-left corner r.Resized(r.Max, size) // same with the top-right corner r.Resized(r.Center(), size) // resizes around the center
This function does not make sense for resizing a rectangle of zero area and will panic. Use ResizedMin in the case of zero area.
func (Rect) ResizedMin ¶
ResizedMin returns the Rect resized to the given size while keeping the position of the Rect's Min.
Sizes of zero area are safe here.
func (Rect) String ¶
String returns the string representation of the Rect.
r := pixel.R(100, 50, 200, 300) r.String() // returns "Rect(100, 50, 200, 300)" fmt.Println(r) // Rect(100, 50, 200, 300)
func (Rect) Union ¶
Union returns the minimal Rect which covers both r and s. Rects r and s must be normalized.
type Sprite ¶
type Sprite struct {
// contains filtered or unexported fields
}
func NewSpriteFromPicture ¶
func (*Sprite) DrawColorMask ¶
type Text ¶
type Text struct { // Orig specifies the text origin, usually the top-left dot position. Dot is always aligned // to Orig when writing newlines. Orig Vec // Dot is the position where the next character will be written. Dot is automatically moved // when writing to a Text object, but you can also manipulate it manually Dot Vec // Color is the color of the text that is to be written. Defaults to white. Color color.Color // LineHeight is the vertical distance between two lines of text. // // Example: // txt.LineHeight = 1.5 * txt.Atlas().LineHeight() LineHeight float64 // TabWidth is the horizontal tab width. Tab characters will align to the multiples of this // width. // // Example: // txt.TabWidth = 8 * txt.Atlas().Glyph(' ').Advance TabWidth float64 // contains filtered or unexported fields }
Text allows for effiecient and convenient text drawing.
To create a Text object, use the New constructor:
txt := text.New(pixel.ZV, text.NewAtlas(face, text.ASCII))
As suggested by the constructor, a Text object is always associated with one font face and a fixed set of runes. For example, the Text we created above can draw text using the font face contained in the face variable and is capable of drawing ASCII characters.
Here we create a Text object which can draw ASCII and Katakana characters:
txt := text.New(0, text.NewAtlas(face, text.ASCII, text.RangeTable(unicode.Katakana)))
Similarly to IMDraw, Text functions as a buffer. It implements io.Writer interface, so writing text to it is really simple:
fmt.Print(txt, "Hello, world!")
Newlines, tabs and carriage returns are supported.
Finally, if we want the written text to show up on some other ITarget, we can draw it:
txt.Draw(target)
Text exports two important fields: Orig and Dot. Dot is the position where the next character will be written. Dot is automatically moved when writing to a Text object, but you can also manipulate it manually. Orig specifies the text origin, usually the top-left dot position. Dot is always aligned to Orig when writing newlines. The Clear method resets the Dot to Orig.
func NewText ¶
New creates a new Text capable of drawing runes contained in the provided Atlas. Orig and Dot will be initially set to orig.
Here we create a Text capable of drawing ASCII characters using the Go Regular font.
ttf, err := truetype.Parse(goregular.TTF) if err != nil { panic(err) } face := truetype.NewFace(ttf, &truetype.Options{ Size: 14, }) txt := text.New(orig, text.NewAtlas(face, text.ASCII))
func (*Text) Atlas ¶
Atlas returns the underlying Text's Atlas containing all of the pre-drawn glyphs. The Atlas is also useful for getting values such as the recommended line height.
func (*Text) Bounds ¶
Bounds returns the bounding box of the text currently written to the Text excluding whitespace.
If the Text is empty, a zero rectangle is returned.
func (*Text) BoundsOf ¶
BoundsOf returns the bounding box of s if it was to be written to the Text right now.
func (*Text) Clear ¶
func (txt *Text) Clear()
Clear removes all written text from the Text. The Dot field is reset to Orig.
func (*Text) Draw ¶
Draw draws all text written to the Text to the provided ITarget. The text is transformed by the provided Matrix.
This method is equivalent to calling DrawColorMask with nil color mask.
If there's a lot of text written to the Text, changing a matrix or a color mask often might hurt performance. Consider using your ITarget's SetMatrix or SetColorMask methods if available.
func (*Text) DrawColorMask ¶
DrawColorMask draws all text written to the Text to the provided ITarget. The text is transformed by the provided Matrix and masked by the provided color mask.
If there's a lot of text written to the Text, changing a matrix or a color mask often might hurt performance. Consider using your ITarget's SetMatrix or SetColorMask methods if available.
func (*Text) Write ¶
Write writes a slice of bytes to the Text. This method never fails, always returns len(p), nil.
func (*Text) WriteByte ¶
WriteByte writes a byte to the Text. This method never fails, always returns nil.
Writing a multi-byte rune byte-by-byte is perfectly supported.
type TriangleData ¶
type TrianglesData ¶
type TrianglesData []TriangleData
TrianglesData specifies a list of ITriangles vertices with three common properties: ITrianglesPosition, ITrianglesColor and ITrianglesPicture.
func MakeTrianglesData ¶
func MakeTrianglesData(len int) *TrianglesData
MakeTrianglesData creates TrianglesData of length len initialized with default property values.
Prefer this function to make(TrianglesData, len), because make zeros them, while this function does the correct initialization.
func (*TrianglesData) ClipRect ¶
func (td *TrianglesData) ClipRect(i int) (rect Rect, has bool)
ClipRect returns the clipping rectangle property of the i-th vertex.
func (*TrianglesData) Color ¶
func (td *TrianglesData) Color(i int) RGBA
Color returns the color property of i-th vertex.
func (*TrianglesData) Copy ¶
func (td *TrianglesData) Copy() ITriangles
Copy returns an exact independent copy of this TrianglesData.
func (*TrianglesData) Len ¶
func (td *TrianglesData) Len() int
Len returns the number of vertices in TrianglesData.
func (*TrianglesData) Picture ¶
func (td *TrianglesData) Picture(i int) (pic Vec, intensity float64)
IPicture returns the picture property of i-th vertex.
func (*TrianglesData) Position ¶
func (td *TrianglesData) Position(i int) Vec
Position returns the position property of i-th vertex.
func (*TrianglesData) SetLen ¶
func (td *TrianglesData) SetLen(len int)
SetLen resizes TrianglesData to len, while keeping the original content.
If len is greater than TrianglesData's current length, the new data is filled with default values ((0, 0), white, (0, 0), 0).
func (*TrianglesData) Slice ¶
func (td *TrianglesData) Slice(i, j int) ITriangles
Slice returns a sub-ITriangles of this TrianglesData.
func (*TrianglesData) Update ¶
func (td *TrianglesData) Update(t ITriangles)
Update copies vertex properties from the supplied ITriangles into this TrianglesData.
ITrianglesPosition, ITrianglesColor and TrianglesTexture are supported.
type Vec ¶
type Vec struct {
X, Y float64
}
Vec is a 2D vector type with X and Y coordinates.
Create vectors with the V constructor:
u := pixel.V(1, 2) v := pixel.V(8, -3)
Use various methods to manipulate them:
w := u.Add(v) fmt.Println(w) // Vec(9, -1) fmt.Println(u.Sub(v)) // Vec(-7, 5) u = pixel.V(2, 3) v = pixel.V(8, 1) if u.X < 0 { fmt.Println("this won't happen") } x := u.Unit().Dot(v.Unit())
func Lerp ¶
Lerp returns a linear interpolation between vectors a and b.
This function basically returns a point along the line between a and b and t chooses which one. If t is 0, then a will be returned, if t is 1, b will be returned. Anything between 0 and 1 will return the appropriate point between a and b and so on.
func (Vec) Angle ¶
Angle returns the angle between the vector u and the x-axis. The result is in range [-Pi, Pi].
func (Vec) Eq ¶
Eq will compare two vectors and return whether they are equal accounting for rounding errors. At worst, the result is correct to 7 significant digits.
func (Vec) Map ¶
Map applies the function f to both x and y components of the vector u and returns the modified vector.
u := pixel.V(10.5, -1.5) v := u.Map(math.Floor) // v is Vec(10, -2), both components of u floored
func (Vec) Normal ¶
Normal returns a vector normal to u. Equivalent to u.Rotated(math.Pi / 2), but faster.
func (Vec) Project ¶
Project returns a projection (or component) of vector u in the direction of vector v.
Behaviour is undefined if v is a zero vector.
func (Vec) String ¶
String returns the string representation of the vector u.
u := pixel.V(4.5, -1.3) u.String() // returns "Vec(4.5, -1.3)" fmt.Println(u) // Vec(4.5, -1.3)
type VideoMode ¶
type VideoMode struct { // Width is the width of the vide mode in pixels. Width int // Height is the height of the video mode in pixels. Height int // RefreshRate holds the refresh rate of the associated monitor in Hz. RefreshRate int }
VideoMode represents all properties of a video mode and is associated with a monitor if it is used in fullscreen mode.
Source Files ¶
- aglbutton.go
- aglcanvas.go
- aglframe.go
- agljoystick.go
- aglmonitor.go
- aglpicture.go
- aglrun.go
- aglshader.go
- aglshaders.go
- agltriangles.go
- aglutils.go
- aglwindow.go
- atlas.go
- batch.go
- circle.go
- compose.go
- drawer.go
- imdraw.go
- interfaces.go
- matrix.go
- picturegba.go
- rectangle.go
- rgba.go
- sprite.go
- text.go
- trianglesData.go
- vector.go