Documentation ¶
Index ¶
- Constants
- func DefaultAdvance(height int, from, to rune) float32
- func GetPalletteSampler(ctx vk.APIContext, dev *vk.Device) *vk.Sampler
- type Appearance
- type ColorIndex
- type Glyph
- type GlyphBuilder
- type GlyphSet
- type GlyphSetIndex
- type MaskIndex
- type Palette
- func (th *Palette) AddGlyphSet(ctx vk.APIContext, gs *GlyphSet) GlyphSetIndex
- func (th *Palette) ComputeMask(ctx vk.APIContext, dev *vk.Device, compute func(x, y, maskSize int) color.RGBA) MaskIndex
- func (pl *Palette) Dispose()
- func (pl *Palette) Draw(dc *vmodel.DrawContext, position Position, appearance Appearance) bool
- func (pl *Palette) DrawString(dc *vmodel.DrawContext, fontSize int, text string, position Position, ...) bool
- func (th *Palette) GetSet(index GlyphSetIndex) *GlyphSet
- func (pl *Palette) MeasureString(gsIndex GlyphSetIndex, text string, fontHeight int) int
- type Position
- type Range
- type SetBuilder
- func (sb *SetBuilder) AddComputedGray(name string, size image.Point, edges image.Rectangle, ...)
- func (sb *SetBuilder) AddEdgedGlyph(name string, mainColor ColorIndex, kind string, content []byte, ...) *GlyphBuilder
- func (sb *SetBuilder) AddGlyph(name string, mainColor ColorIndex, kind string, content []byte)
- func (sb *SetBuilder) Build(dev *vk.Device) *GlyphSet
- type SetKind
- type VectorBuilder
- func (vb *VectorBuilder) AddCorner(from mgl32.Vec2, mid mgl32.Vec2, to mgl32.Vec2)
- func (vb *VectorBuilder) AddCornerRect(outside bool, left mgl32.Vec2, size mgl32.Vec2, corners mgl32.Vec4) *VectorBuilder
- func (vb *VectorBuilder) AddLine(p1, p2 mgl32.Vec2) *VectorBuilder
- func (vb *VectorBuilder) AddPoint(p1 mgl32.Vec2) *VectorBuilder
- func (vb *VectorBuilder) AddQuadratic(p1, p2, p3 mgl32.Vec2) *VectorBuilder
- func (vb *VectorBuilder) AddRect(outside bool, left mgl32.Vec2, size mgl32.Vec2) *VectorBuilder
- func (vb *VectorBuilder) AddRoundedRect(outside bool, left mgl32.Vec2, size mgl32.Vec2, corners mgl32.Vec4) *VectorBuilder
- type VectorSetBuilder
- func (vsb *VectorSetBuilder) AddChar(font *sfnt.Font, pixelSize int, r rune) *VectorBuilder
- func (vsb *VectorSetBuilder) AddEdgedGlyph(name string, margin int, edges image.Rectangle) *VectorBuilder
- func (vsb *VectorSetBuilder) AddFont(ctx vk.APIContext, fontContent []byte, ranges ...Range)
- func (vsb *VectorSetBuilder) AddGlyph(name string, margin int) *VectorBuilder
- func (vsb *VectorSetBuilder) Build(ctx vk.APIContext, dev *vk.Device) *GlyphSet
Constants ¶
const ( // Foreground / Background ratio in RED channel. Alpha channel is alpha RED = ColorIndex(0) // Foreground / Background ratio in GREEN channel. Alpha channel is alpha GREEN = ColorIndex(1) // Foreground / Background ratio in BLUE channel. Alpha channel is alpha BLUE = ColorIndex(2) // Foreground / Background ratio in RED channel. RED channel is also alpha. GRAY = ColorIndex(3) // Foreground / Background ratio in RED channel. GREEN channel controls alpha. If GREEN > 0.5 then alpha = 0 else alpha = 1 RED_GREENA = ColorIndex(4) )
const ( SETDepthField = SetKind(0) SETGrayScale = SetKind(1) SETRGBA = SetKind(2) )
const (
MAXGlyphSets = 16
)
const MAXImageWidth = 32768
const NOMINALFontSize = 32
const (
NullSet = GlyphSetIndex(-1)
)
Variables ¶
This section is empty.
Functions ¶
func DefaultAdvance ¶
func GetPalletteSampler ¶
Sampler used in gyph shader. Clamps samping to edge
Types ¶
type Appearance ¶
type ColorIndex ¶
type ColorIndex uint32
type Glyph ¶
type Glyph struct { Name string Location image.Rectangle CharOffset image.Point // Edges from 3 or 9 part glyph. left, top, right, bottom Edges image.Rectangle }
Glyph is individual glyph in glyph set.
type GlyphBuilder ¶
type GlyphBuilder struct {
// contains filtered or unexported fields
}
type GlyphSet ¶
type GlyphSet struct { Desc vk.ImageDescription Advance func(height int, from, to rune) float32 // contains filtered or unexported fields }
GlyphSet is set of prerendered glyph. GlyphSet can be either SETDepthField - All glyphs are rendered as signed depth fields. These allows more accurate sampling of glyph edges when sizing them. This is ideal for font's and other single colored glyphs SETGrayScale - Grays scale glyph mixes blending between font color and back color based on image grayness. Alpha channel is used to control glyphs alpha factor.
type GlyphSetIndex ¶
type GlyphSetIndex int
type Palette ¶
type Palette struct {
// contains filtered or unexported fields
}
Palette is set of glyph sets and masks. Palette, when built maps to single descriptor that can be bound to glyph shader.
func NewPalette ¶
NewPalette initialized new palette and allocates room for mask image. Mask image is single multilayered image that glyph shader can use to amplify forecolor or backcolor. Masks can be used to create gradient effects to rendered glyph
func (*Palette) AddGlyphSet ¶
func (th *Palette) AddGlyphSet(ctx vk.APIContext, gs *GlyphSet) GlyphSetIndex
Add glyph set to palette. You should add all glyph sets to palette before using it.
func (*Palette) ComputeMask ¶
func (th *Palette) ComputeMask(ctx vk.APIContext, dev *vk.Device, compute func(x, y, maskSize int) color.RGBA) MaskIndex
ComputeMask fills one mask using given function.
func (*Palette) Draw ¶
func (pl *Palette) Draw(dc *vmodel.DrawContext, position Position, appearance Appearance) bool
func (*Palette) DrawString ¶
func (pl *Palette) DrawString(dc *vmodel.DrawContext, fontSize int, text string, position Position, appearance Appearance) bool
func (*Palette) GetSet ¶
func (th *Palette) GetSet(index GlyphSetIndex) *GlyphSet
GetSet retrieves glyph set from palette.
func (*Palette) MeasureString ¶
func (pl *Palette) MeasureString(gsIndex GlyphSetIndex, text string, fontHeight int) int
type Position ¶
type SetBuilder ¶
type SetBuilder struct { Ctx vk.APIContext // contains filtered or unexported fields }
func NewSetBuilder ¶
func NewSetBuilder(ctx vk.APIContext, kind SetKind) *SetBuilder
NewSetBuilder initialize new build that can build glyphset using images. Images can have foreground / background ratio (SETGrayScale) or full rgba image (SETRGBA) All images in one glyph set must have same kind
func (*SetBuilder) AddComputedGray ¶
func (sb *SetBuilder) AddComputedGray(name string, size image.Point, edges image.Rectangle, intensity func(x, y int) (color float32, alpha float32))
Add computed glyph. Function will panic it set is not SETGrayScale
func (*SetBuilder) AddEdgedGlyph ¶
func (sb *SetBuilder) AddEdgedGlyph(name string, mainColor ColorIndex, kind string, content []byte, edges image.Rectangle) *GlyphBuilder
Add edged glyph. See docs/vui.md) for more info
func (*SetBuilder) AddGlyph ¶
func (sb *SetBuilder) AddGlyph(name string, mainColor ColorIndex, kind string, content []byte)
Add glyph to glyph set
type VectorBuilder ¶
type VectorBuilder struct {
// contains filtered or unexported fields
}
func (*VectorBuilder) AddCornerRect ¶
func (vb *VectorBuilder) AddCornerRect(outside bool, left mgl32.Vec2, size mgl32.Vec2, corners mgl32.Vec4) *VectorBuilder
func (*VectorBuilder) AddLine ¶
func (vb *VectorBuilder) AddLine(p1, p2 mgl32.Vec2) *VectorBuilder
func (*VectorBuilder) AddPoint ¶
func (vb *VectorBuilder) AddPoint(p1 mgl32.Vec2) *VectorBuilder
func (*VectorBuilder) AddQuadratic ¶
func (vb *VectorBuilder) AddQuadratic(p1, p2, p3 mgl32.Vec2) *VectorBuilder
func (*VectorBuilder) AddRect ¶
func (vb *VectorBuilder) AddRect(outside bool, left mgl32.Vec2, size mgl32.Vec2) *VectorBuilder
func (*VectorBuilder) AddRoundedRect ¶
func (vb *VectorBuilder) AddRoundedRect(outside bool, left mgl32.Vec2, size mgl32.Vec2, corners mgl32.Vec4) *VectorBuilder
type VectorSetBuilder ¶
type VectorSetBuilder struct { Ctx vk.APIContext MaxDistance float32 // contains filtered or unexported fields }
VectorSetBuilder converts vector based images (fonts and drawn) to glyph set
func (*VectorSetBuilder) AddChar ¶
func (vsb *VectorSetBuilder) AddChar(font *sfnt.Font, pixelSize int, r rune) *VectorBuilder
Add individual character from font to vector builder
func (*VectorSetBuilder) AddEdgedGlyph ¶
func (vsb *VectorSetBuilder) AddEdgedGlyph(name string, margin int, edges image.Rectangle) *VectorBuilder
Add glyph that have 3 sides: top, center, bottom or left, center, right. 9 side glyphs have left, top, right, bottom, center and all corners.
func (*VectorSetBuilder) AddFont ¶
func (vsb *VectorSetBuilder) AddFont(ctx vk.APIContext, fontContent []byte, ranges ...Range)
Add font to vector set builder. Glyph names will be directly font character converted as string Currently only fonts containing lines and quadratics bezier lines are support (this should include all ttf fonts) Cubic bezier lines are not
func (*VectorSetBuilder) AddGlyph ¶
func (vsb *VectorSetBuilder) AddGlyph(name string, margin int) *VectorBuilder
Add glyph using Vector builder. Margin will be added to final glyph. You must have few pixel around edges to separate glyph inside from outside
func (*VectorSetBuilder) Build ¶
func (vsb *VectorSetBuilder) Build(ctx vk.APIContext, dev *vk.Device) *GlyphSet
Convert added vector sets to glyph set. This glyph set will be signed depth field