integration

package
v0.0.0-...-b5003a3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2021 License: MIT Imports: 10 Imported by: 16

Documentation

Index

Constants

View Source
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

func ColourComponentClamp(i int32) uint8

ColourComponentClamp clamps an integer into the 0..255 range (acting as a safe converter from int32 to uint8)

func ColourFromARGB

func ColourFromARGB(a uint8, r uint8, g uint8, b uint8) uint32

ColourFromARGB creates a colour from the separate A/R/G/B quantities.

func ColourMix

func ColourMix(cola uint32, colb uint32, amount float64) uint32

ColourMix linearly interpolates between two colours in the standard space (no "linear light" business)

func ColourToARGB

func ColourToARGB(col uint32) (a uint8, r uint8, g uint8, b uint8)

ColourToARGB splits a colour apart.

func ColourTransform2Blend

func ColourTransform2Blend(dest uint32, source uint32) uint32

ColourTransform2Blend implements standard blending.

func ColourTransformBlueToStencil

func ColourTransformBlueToStencil(c uint32) uint32

ColourTransformBlueToStencil uses the blue channel as an alpha stencil and gives the image a white background.

func ColourTransformInvert

func ColourTransformInvert(c uint32) uint32

ColourTransformInvert inverts the colour channels.

func ConvertGoImageColourToUint32

func ConvertGoImageColourToUint32(col color.Color) uint32

ConvertGoImageColourToUint32 converts a Go colour into an ARGB colour uint32 as losslessly as possible.

func ConvertUint32ToGoImageColour

func ConvertUint32ToGoImageColour(col uint32) color.NRGBA

ConvertUint32ToGoImageColour converts a uint32 colour to a colour.NRGBA (which is essentially in the same format)

func CreateHardcodedPNGImage

func CreateHardcodedPNGImage(pngb64 string) image.Image

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

func CreateTTFFont(ft *truetype.Font, dpi float64, size float64) font.Face

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.

func ScaleImageToHalfSize

func ScaleImageToHalfSize(source image.Image) image.Image

ScaleImageToHalfSize scales an image to half-size using a trivial "average covered pixels" algorithm that handles a lot of situations well assuming content that's aligned to the implicit "2x2 grid".

Types

type ColourTransform

type ColourTransform func(c uint32) uint32

ColourTransform transforms colours. It's useful when doing image transforms from alphaless images to alpha/etc.

type ColourTransform2

type ColourTransform2 func(a uint32, b uint32) uint32

ColourTransform2 combines two colours to make a third.

func (ColourTransform2) Run

func (ct ColourTransform2) Run(part1 image.Image, part2 image.Image, shift frenyard.Vec2i) image.Image

Run runs the colour transform on a pair of images to create a third image.

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

type TextLayouterResult struct {
	Area  frenyard.Area2i
	Lines []TypeChunk
}

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

func NewColouredTextTypeChunk(text string, face font.Face, colour uint32) TypeChunk

NewColouredTextTypeChunk is a version of NewTextTypeChunk that supports putting coloured text inline.

func NewCompoundTypeChunk

func NewCompoundTypeChunk(content []TypeChunk) TypeChunk

NewCompoundTypeChunk creates a type chunk from multiple sub-type-chunks.

func NewTextTypeChunk

func NewTextTypeChunk(text string, face font.Face) TypeChunk

NewTextTypeChunk creates a TypeChunk from text and a font. This is the simplest kind of TypeChunk.

func NewUnderlineTypeChunk

func NewUnderlineTypeChunk(text TypeChunk, underlineColour uint32) TypeChunk

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL