Documentation ¶
Index ¶
- Constants
- func ColourComponentClamp(i int32) uint8
- func ColourFromARGB(a uint8, r uint8, g uint8, b uint8) uint32
- func ColourMix(cola uint32, colb uint32, amount float64) uint32
- func ColourToARGB(col uint32) (a uint8, r uint8, g uint8, b uint8)
- func ColourTransform2Blend(dest uint32, source uint32) uint32
- func ColourTransformBlueToStencil(c uint32) uint32
- func ColourTransformInvert(c uint32) uint32
- func ConvertGoImageColourToUint32(col color.Color) uint32
- func ConvertUint32ToGoImageColour(col uint32) color.NRGBA
- func CreateHardcodedPNGImage(pngb64 string) image.Image
- func CreateHardcodedPNGTexture(pngb64 string, ct []ColourTransform) frenyard.Texture
- func CreateTTFFont(ft *truetype.Font, dpi float64, size float64) font.Face
- func FontRectangleConverter(bounds fixed.Rectangle26_6) frenyard.Area2i
- func GoImageToTexture(img image.Image, ct []ColourTransform) frenyard.Texture
- func ScaleImageToHalfSize(source image.Image) image.Image
- type ColourTransform
- type ColourTransform2
- type TextLayouterOptions
- type TextLayouterResult
- type TypeChunk
- type TypeChunkComponentBreakStatus
Constants ¶
const DPIPixels float64 = 72
DPIPixels is the DPI setting where one typographical point is equal to one typographical pixel.
Variables ¶
This section is empty.
Functions ¶
func ColourComponentClamp ¶
ColourComponentClamp clamps an integer into the 0..255 range (acting as a safe converter from int32 to uint8)
func ColourFromARGB ¶
ColourFromARGB creates a colour from the separate A/R/G/B quantities.
func ColourMix ¶
ColourMix linearly interpolates between two colours in the standard space (no "linear light" business)
func ColourToARGB ¶
ColourToARGB splits a colour apart.
func ColourTransform2Blend ¶
ColourTransform2Blend implements standard blending.
func ColourTransformBlueToStencil ¶
ColourTransformBlueToStencil uses the blue channel as an alpha stencil and gives the image a white background.
func ColourTransformInvert ¶
ColourTransformInvert inverts the colour channels.
func ConvertGoImageColourToUint32 ¶
ConvertGoImageColourToUint32 converts a Go colour into an ARGB colour uint32 as losslessly as possible.
func ConvertUint32ToGoImageColour ¶
ConvertUint32ToGoImageColour converts a uint32 colour to a colour.NRGBA (which is essentially in the same format)
func CreateHardcodedPNGImage ¶
CreateHardcodedPNGImage gets an image.Image from a base64 string.
func CreateHardcodedPNGTexture ¶
func CreateHardcodedPNGTexture(pngb64 string, ct []ColourTransform) frenyard.Texture
CreateHardcodedPNGTexture gets a frenyard.Texture from a base64 string.
func CreateTTFFont ¶
CreateTTFFont is a wrapper around truetype.NewFace
func FontRectangleConverter ¶
func FontRectangleConverter(bounds fixed.Rectangle26_6) frenyard.Area2i
FontRectangleConverter converts a fixed.Rectangle26_6 into pixels (rounding outwards)
func GoImageToTexture ¶
func GoImageToTexture(img image.Image, ct []ColourTransform) frenyard.Texture
GoImageToTexture imports an image from Go's "image" library to a texture.
Types ¶
type ColourTransform ¶
ColourTransform transforms colours. It's useful when doing image transforms from alphaless images to alpha/etc.
type ColourTransform2 ¶
ColourTransform2 combines two colours to make a third.
type TextLayouterOptions ¶
type TextLayouterOptions struct { Text TypeChunk // SizeUnlimited should be used if an axis should be unbounded. Limits frenyard.Vec2i }
TextLayouterOptions contains the options for text layout.
type TextLayouterResult ¶
TextLayouterResult contains the results from text layouting.
func TheOneTextLayouterToRuleThemAll ¶
func TheOneTextLayouterToRuleThemAll(opts TextLayouterOptions) TextLayouterResult
TheOneTextLayouterToRuleThemAll lays out text with wrapping limits and other such constraints.
func (*TextLayouterResult) Draw ¶
func (tlr *TextLayouterResult) Draw() frenyard.Texture
Draw draws the laid-out text to a texture.
type TypeChunk ¶
type TypeChunk interface { // Amount of components in the type. FyCComponentCount() int // Break status of a specific component. FyCComponentBreakStatus(index int) TypeChunkComponentBreakStatus // Given a specific component, returns the advance. Can account for kerning. FyCComponentAdvance(index int, kerning bool) fixed.Int26_6 // Gets a subsection. 'end' is non-inclusive; thus Section(0, ComponentCount()) returns a chunk equivalent to the TypeChunk itself. FyCSection(start int, end int) TypeChunk // Line height (should be maximum of total line height in the chunk for evenness). As pixels to keep things nice. FyCHeight() int // Returns the dot, and then the bounds. These bounds can and should be increased where possible to try and reduce vertical 'bumps'. FyCBounds(dot fixed.Point26_6) (fixed.Point26_6, fixed.Rectangle26_6) // Draws to an image. Returns the new dot. FyCDraw(img draw.Image, dot fixed.Point26_6) fixed.Point26_6 }
TypeChunk represents a chunk of abstract text-like stuff.
func NewColouredTextTypeChunk ¶
NewColouredTextTypeChunk is a version of NewTextTypeChunk that supports putting coloured text inline.
func NewCompoundTypeChunk ¶
NewCompoundTypeChunk creates a type chunk from multiple sub-type-chunks.
func NewTextTypeChunk ¶
NewTextTypeChunk creates a TypeChunk from text and a font. This is the simplest kind of TypeChunk.
func NewUnderlineTypeChunk ¶
NewUnderlineTypeChunk underlines a TypeChunk.
type TypeChunkComponentBreakStatus ¶
type TypeChunkComponentBreakStatus uint8
TypeChunkComponentBreakStatus represents the break status of a component.
const TypeChunkComponentBreakStatusNewline TypeChunkComponentBreakStatus = 2
TypeChunkComponentBreakStatusNewline is an obligatory break, real component may act erroneously
const TypeChunkComponentBreakStatusNone TypeChunkComponentBreakStatus = 0
TypeChunkComponentBreakStatusNone represents no break at all.
const TypeChunkComponentBreakStatusSpace TypeChunkComponentBreakStatus = 1
TypeChunkComponentBreakStatusSpace is an optional break