Documentation ¶
Index ¶
- Constants
- Variables
- func ColorEqualUint32(c color.Color, u uint32) bool
- func InitShaders()
- func SetDefaultFont(urls string)
- type Canvas
- type Color
- func (c Color) Alpha() byte
- func (c *Color) EqualUint32(u uint32) bool
- func (c Color) RGBA() (uint32, uint32, uint32, uint32)
- func (c *Color) Set(i uint32)
- func (c *Color) SetAlpha(i byte)
- func (c Color) String() string
- func (c Color) ToColor() color.Color
- func (c Color) ToFloat32() float32
- func (c Color) Unpack() (byte, byte, byte, byte)
- func (c Color) Vec4() [4]float32
- type FPSComponent
- func (f *FPSComponent) Hide()
- func (f *FPSComponent) Move(x, y float32)
- func (f *FPSComponent) New(w *ecs.World)
- func (*FPSComponent) Remove(ecs.BasicEntity)
- func (f *FPSComponent) SetAnchor(ax, ay float32)
- func (f *FPSComponent) SetFormat(format string)
- func (f *FPSComponent) Show()
- func (f *FPSComponent) String() string
- func (f *FPSComponent) Update(dt float32)
- type Font
- type FontAtlas
- type LoadingComponent
- func (l *LoadingComponent) Hide()
- func (l *LoadingComponent) Move(x, y float32)
- func (l *LoadingComponent) New(w *ecs.World)
- func (l *LoadingComponent) Pause(state bool)
- func (*LoadingComponent) Remove(ecs.BasicEntity)
- func (l *LoadingComponent) SetSpeed(speed float32)
- func (l *LoadingComponent) Show()
- func (l *LoadingComponent) Speed() float32
- func (l *LoadingComponent) State() bool
- func (l *LoadingComponent) Toggle()
- func (l *LoadingComponent) Update(dt float32)
- type MouseAction
- type Padding
- type Point
- type Points
- type Shape
- func NewCircle(cx, cy, radius, arc, strokeWidth float32, strokeColor, fillColor uint32) *Shape
- func NewCurve(x, y, width, height, strokeWidth float32, points Points, clr uint32) *Shape
- func NewLine(x1, y1, x2, y2, lineWidth float32, clr uint32) *Shape
- func NewPolygon(x, y, width, height float32, strokeWidth float32, points Points, ...) *Shape
- func NewRect(x, y, width, height, strokeWidth float32, strokeColor, fillColor uint32) *Shape
- func NewStippleLine(points Points, factor int32, pattern uint16, lineWidth float32, clr uint32) *Shape
- func NewStippleRect(x, y, width, height float32, factor int32, pattern uint16, lineWidth float32, ...) *Shape
- func NewText(text string, x, y, ax, ay, size float32, color uint32) *Shape
- func NewTextWithStyle(text string, x, y, ax, ay, size float32, color uint32, style *TextStyle) *Shape
- func (s *Shape) AddArc(arc float32)
- func (s *Shape) AddRotate(deg float32)
- func (s *Shape) GetBasicEntity() *ecs.BasicEntity
- func (s *Shape) GetMouseComponent() *common.MouseComponent
- func (s *Shape) GetRenderComponent() *common.RenderComponent
- func (s *Shape) GetSpaceComponent() *common.SpaceComponent
- func (s *Shape) Hidden()
- func (s *Shape) ID() uint64
- func (s *Shape) Move(x, y float32)
- func (s *Shape) MoveStippleLeft()
- func (s *Shape) MoveStippleRight()
- func (s *Shape) MoveX(x float32)
- func (s *Shape) MoveY(y float32)
- func (s *Shape) OnClick(fn func(*Shape))
- func (s *Shape) OnDrag(fn func(*Shape, float32, float32))
- func (s *Shape) OnHover(enter, leave func(*Shape))
- func (s *Shape) OnUpdate(fn func(*Shape, float32))
- func (s *Shape) Rotate(deg float32)
- func (s *Shape) SetAnchor(ax, ay float32)
- func (s *Shape) SetArc(arc float32)
- func (s *Shape) SetBgStyle(style uint8)
- func (s *Shape) SetFillColor(clr uint32)
- func (s *Shape) SetLetterSpacing(spacing float32)
- func (s *Shape) SetLineSpacing(spacing float32)
- func (s *Shape) SetPoints(points Points)
- func (s *Shape) SetRadius(radius float32)
- func (s *Shape) SetStipple(factor int32, pattern uint16)
- func (s *Shape) SetStrokeColor(clr uint32)
- func (s *Shape) SetStrokeWidth(width float32)
- func (s *Shape) SetText(text string)
- func (s *Shape) Show()
- func (s *Shape) Stipple() (int32, uint16)
- func (s *Shape) Transform(x, y, width, height float32)
- func (s *Shape) Visible() bool
- type ShapeKind
- type Shapes
- type Stipple
- type StippleLine
- type StippleRect
- type Text
- type TextStyle
Constants ¶
const ( BG_FILL_FULL uint8 = iota BG_FILL_WRAP )
const Font04b08 = "04b08.ttf"
const FontDroidSans = "DroidSansFallbackFull.ttf"
Variables ¶
var ( TextShader = &textShader{cameraEnabled: true} TextHUDShader = &textShader{} ShapeShader = &shapeShader{cameraEnabled: true} ShapeHUDShader = &shapeShader{} )
Functions ¶
func ColorEqualUint32 ¶
ColorEqualUint32 判断 color.Color 和 uint32 是否相等
func InitShaders ¶
func InitShaders()
func SetDefaultFont ¶
func SetDefaultFont(urls string)
Types ¶
type Canvas ¶
type Canvas struct {
// contains filtered or unexported fields
}
Using Canvas instead of RenderSystem
func (*Canvas) Draw ¶
func (c *Canvas) Draw()
After that, the contents of push will be rendered in the next frame
func (*Canvas) Remove ¶
func (c *Canvas) Remove(basic ecs.BasicEntity)
type Color ¶
type Color struct {
// contains filtered or unexported fields
}
Color implementation image.Color Interface
func ParseColor ¶
ParseColor creating color with color.Color
func (*Color) EqualUint32 ¶
type FPSComponent ¶
type FPSComponent struct {
// contains filtered or unexported fields
}
func NewFPSComponent ¶
func NewFPSComponent(x, y, size float32, fgColor, bgColor uint32) (f *FPSComponent)
func (*FPSComponent) Hide ¶
func (f *FPSComponent) Hide()
func (*FPSComponent) Move ¶
func (f *FPSComponent) Move(x, y float32)
func (*FPSComponent) New ¶
func (f *FPSComponent) New(w *ecs.World)
func (*FPSComponent) Remove ¶
func (*FPSComponent) Remove(ecs.BasicEntity)
func (*FPSComponent) SetAnchor ¶
func (f *FPSComponent) SetAnchor(ax, ay float32)
func (*FPSComponent) SetFormat ¶
func (f *FPSComponent) SetFormat(format string)
func (*FPSComponent) Show ¶
func (f *FPSComponent) Show()
func (*FPSComponent) String ¶
func (f *FPSComponent) String() string
func (*FPSComponent) Update ¶
func (f *FPSComponent) Update(dt float32)
type Font ¶
type Font struct { URL string Size float64 TTF *truetype.Font // contains filtered or unexported fields }
func (*Font) CreatePreloaded ¶
CreatePreloaded is for loading fonts which have already been defined (and loaded) within Preload
type FontAtlas ¶
type FontAtlas struct { Image *image.NRGBA Texture *gl.Texture // XLocation contains the X-coordinate of the starting position of all characters XLocation map[rune]float32 // YLocation contains the Y-coordinate of the starting position of all characters YLocation map[rune]float32 // Width contains the width in pixels of all the characters, including the spacing between characters Width map[rune]float32 // Height contains the height in pixels of all the characters Height map[rune]float32 // TotalWidth is the total amount of pixels the `FontAtlas` is wide; useful for determining the `Viewport`, // which is relative to this value. TotalWidth float32 // TotalHeight is the total amount of pixels the `FontAtlas` is high; useful for determining the `Viewport`, // which is relative to this value. TotalHeight float32 // The position of the last character CurrentX, CurrentY float32 // LineHeight is Ascent+Descent LineHeight float32 Ascent float32 // left-side and right-side bearings LeftSide, RightSide map[rune]float32 // OffsetY Ascent + bounds.Min.Y OffsetY map[rune]float32 }
A FontAtlas is a representation of some of the Font characters, as an image
type LoadingComponent ¶
type LoadingComponent struct {
// contains filtered or unexported fields
}
func NewLoadingComponent ¶
func NewLoadingComponent(x, y, size float32, fgColor, bgColor uint32) *LoadingComponent
func (*LoadingComponent) Hide ¶
func (l *LoadingComponent) Hide()
func (*LoadingComponent) Move ¶
func (l *LoadingComponent) Move(x, y float32)
func (*LoadingComponent) New ¶
func (l *LoadingComponent) New(w *ecs.World)
Implement Initializer interface
func (*LoadingComponent) Pause ¶
func (l *LoadingComponent) Pause(state bool)
func (*LoadingComponent) Remove ¶
func (*LoadingComponent) Remove(ecs.BasicEntity)
Implement System interface
func (*LoadingComponent) SetSpeed ¶
func (l *LoadingComponent) SetSpeed(speed float32)
func (*LoadingComponent) Show ¶
func (l *LoadingComponent) Show()
func (*LoadingComponent) Speed ¶
func (l *LoadingComponent) Speed() float32
func (*LoadingComponent) State ¶
func (l *LoadingComponent) State() bool
func (*LoadingComponent) Toggle ¶
func (l *LoadingComponent) Toggle()
func (*LoadingComponent) Update ¶
func (l *LoadingComponent) Update(dt float32)
Implement System interface
type MouseAction ¶
type MouseAction uint8
const ( MOUSE_NONE MouseAction = iota MOUSE_CLICKED MOUSE_DRAGGED )
type Shape ¶
type Shape struct { Entity *ecs.BasicEntity Render *common.RenderComponent Space *common.SpaceComponent Mouse *common.MouseComponent // contains filtered or unexported fields }
基础形状
func NewPolygon ¶
func NewPolygon(x, y, width, height float32, strokeWidth float32, points Points, strokeColor, fillColor uint32) *Shape
NewPolygon this is ComplexTriangles
func NewStippleLine ¶
func NewStippleLine(points Points, factor int32, pattern uint16, lineWidth float32, clr uint32) *Shape
NewStippleLine
func NewStippleRect ¶
func NewStippleRect(x, y, width, height float32, factor int32, pattern uint16, lineWidth float32, clr uint32) *Shape
NewStippleRect
func NewText ¶
NewText use default font ax, ay is anchor point, range -1..1, use 0.5 center the text in x, y
func NewTextWithStyle ¶
func (*Shape) GetBasicEntity ¶
func (s *Shape) GetBasicEntity() *ecs.BasicEntity
implementation of common.BasicFace
func (*Shape) GetMouseComponent ¶
func (s *Shape) GetMouseComponent() *common.MouseComponent
implementation of common.Mouseable
func (*Shape) GetRenderComponent ¶
func (s *Shape) GetRenderComponent() *common.RenderComponent
implementation of common.RenderFace
func (*Shape) GetSpaceComponent ¶
func (s *Shape) GetSpaceComponent() *common.SpaceComponent
implementation of common.SpaceFace
func (*Shape) SetBgStyle ¶
func (*Shape) SetLetterSpacing ¶
func (*Shape) SetLineSpacing ¶
func (*Shape) SetPoints ¶
(*Shape) SetPoints 支持这些形状 SHAPE_KIND_STIPPLE_LINE, SHAPE_KIND_POLYGON, SHAPE_KIND_CURVE
func (*Shape) SetStipple ¶
(*Shape) SetStipple
func (*Shape) SetStrokeWidth ¶
(*Shape) SetStrokeWidth
type StippleLine ¶
StippleLine
func (StippleLine) Close ¶
func (StippleLine) Close()
func (StippleLine) Height ¶
func (StippleLine) Height() float32
func (StippleLine) Texture ¶
func (StippleLine) Texture() *gl.Texture
func (StippleLine) Width ¶
func (StippleLine) Width() float32
type StippleRect ¶
StippleRect
func (StippleRect) Close ¶
func (StippleRect) Close()
func (StippleRect) Height ¶
func (StippleRect) Height() float32
func (StippleRect) Texture ¶
func (StippleRect) Texture() *gl.Texture
func (StippleRect) Width ¶
func (StippleRect) Width() float32
type Text ¶
type Text struct { // Font is the reference to the font you're using to render this. This includes the font size. Font *Font // Text is the actual text you want to draw. This may include newlines (\n). Text string // LineSpacing is the amount of additional spacing there is between the lines (when `Text` consists of multiple lines). LineSpacing float32 // LetterSpacing is the amount of additional spacing there is between the characters. LetterSpacing float32 // The shader uses the position here instead of the SpaceComponent.Position. // Because Padding changes size and position of SpaceComponent. Position engo.Point // font color Color *Color // BG fill style, BG_FILL_FULL or BG_FILL_WRAP BgStyle uint8 // Only when the BgStyle is BG_TYPE_FULL. // This changes the size of the entity (common.SpaceComponent). // In order to make common.MouseComponent working. Padding Padding // contains filtered or unexported fields }
Text represents a string drawn onto the screen, as used by the `TextShader`.
func (Text) Height ¶
Height returns the height the Text generated from a FontAtlas. This implements the common.Drawable interface.