Documentation ¶
Overview ¶
GL Image library. Routines for handling images and textures in GO OpenGL (especially with the GoMobile framework)
GL Image library. Routines for handling images and textures in GO OpenGL (especially with the GoMobile framework)
Text editor library. Routines to support a text editor
Index ¶
- func Abs32(x int32) int32
- func Abs64(x int64) int64
- func Abs8(x int8) int8
- func AbsInt(x int) int
- func CalcDiff(renderPix, refImage []byte, width, height int) (int64, []byte)
- func CalcDiffSq(renderPix, refImage []byte, width, height int) (int64, []byte)
- func ClearAllCaches()
- func DrawCursor(xpos, ypos, height, clientWidth int, u8Pix []byte)
- func DrawStringRGBA(txtSize float64, fontColor RGBA, txt, fontfile string) (*image.RGBA, *font.Face)
- func DumpBuff(buff []uint8, width, height uint)
- func Fixed2int(n fixed.Int26_6) int
- func FlipUp(srcW, srcH int, src []byte) []byte
- func GDiff(m, m1 image.Image) int64
- func GFormatToImage(img image.Image, u8Pix []uint8, clientWidth, clientHeight int) ([]uint8, int, int)
- func GetGlyphSize(size float64, str string) (int, int)
- func ImageToGFormat(texWidth, texHeight int, buff []byte) image.Image
- func ImageToGFormatRGBA(texWidth, texHeight int, buff []byte) *image.RGBA
- func InBounds(v, min, max Vec2) bool
- func LoadFont(fileName string) *truetype.Font
- func LoadImage(path string) ([]byte, int, int)
- func MakeTransparent(m []byte, col color.RGBA) []byte
- func MaxI(a, b int) int
- func NextPo2(n int) int
- func PaintTexture(img image.Image, u8Pix []uint8, clientWidth int) []uint8
- func PasteBytes(srcWidth, srcHeight int, srcBytes []byte, xpos, ypos, dstWidth, dstHeight int, ...)
- func PasteImg(img *image.RGBA, xpos, ypos, clientWidth, clientHeight int, u8Pix []uint8, ...)
- func PasteText(tSize float64, xpos, ypos, clientWidth, clientHeight int, text string, ...)
- func RGBAtoColor(in RGBA) color.RGBA
- func RandPic(width, height int) []uint8
- func RenderPara(f *FormatParams, ...) (int, int, int)
- func RenderTokenPara(f *FormatParams, ...) (int, int, int)
- func Rotate270(srcW, srcH int, src []byte) []byte
- func Rotate90(srcW, srcH int, src []byte) []byte
- func SanityCheck(f *FormatParams, txt string)
- func SaveBuff(texWidth, texHeight int, buff []byte, filename string)
- func SaveImage(picture *image.RGBA, filename string)
- func ToChar(i int) rune
- func Uint8ToBytes(in []uint8) []byte
- type FormatParams
- type RGBA
- type Thunk
- type Vec2
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalcDiff ¶
Calculate the pixel difference between two images.
This does a simple pixel compare, by sutracting the RGB pixel values. Itdoes not take into account perceptual differences or gamma or anything clever like that
The higher the returned number, the more different the pictures are
func CalcDiffSq ¶
Calculate the pixel difference between two images.
This does a simple pixel compare, by sutracting the RGB pixel values, then squaring the difference. It does not take into account perceptual differences or gamma or anything clever like that
The higher the returned number, the more different the pictures are
func DrawCursor ¶
Draw a cursor shape
func DrawStringRGBA ¶
func DrawStringRGBA(txtSize float64, fontColor RGBA, txt, fontfile string) (*image.RGBA, *font.Face)
Creates a texture and draws a string to it
FIXME some fonts might not compeletely fit in the texture (usually the decorative ones which extend into another letter)
func DumpBuff ¶
Prints the contents of a 32bit RGBA byte array as ASCII text
For debugging. Any pixel with a red value over 128 will be drawn as "I", otherwise "_"
func FlipUp ¶
Flips a 32bit byte array picture upside down. Creates a target array with with the correct dimensions and returns it
func GDiff ¶
Returns a number representing the graphical difference between two images.
This difference is calculated by comparing each pixel and summing the difference in colour ¶
This difference function is used in some other programs to power some approximation functions, it doesn't actually mean anything
func GFormatToImage ¶
func GFormatToImage(img image.Image, u8Pix []uint8, clientWidth, clientHeight int) ([]uint8, int, int)
Use width and height of 0 to use the image size
func GetGlyphSize ¶
Get the maximum pixel size needed to hold a string
func ImageToGFormat ¶
Converts an image to google's image format, RGBA type
func ImageToGFormatRGBA ¶
Converts an image to google's image format, NRGBA format
func MakeTransparent ¶
Turn all pixels of a colour into transparent pixels
i.e. set the alpha to zero if the RGB matches the colour
The alpha value of the input colour is ignored
func PaintTexture ¶
Copies an image to a correctly-packed texture data array, where "correctly packed" means a byte array suitable for loading into OpenGL as a 32-bit RGBA byte blob
Other formats are not currently supported, patches welcome, etc ¶
Returns the array, modified in place. If u8Pix is nil or texWidth is 0, it creates a new texture array and returns that. Texture is assumed to be square (this used to be required for OpenGL, not sure now?).
func PasteBytes ¶
func PasteBytes(srcWidth, srcHeight int, srcBytes []byte, xpos, ypos, dstWidth, dstHeight int, u8Pix []uint8, transparent, showBorder bool, copyAlpha bool)
PasteBytes
Takes a bag of bytes, and some dimensions, and pastes it into another bag of bytes It's the basic image combining routine
func PasteImg ¶
func PasteImg(img *image.RGBA, xpos, ypos, clientWidth, clientHeight int, u8Pix []uint8, transparent bool)
Pastes a go format image into a bag of bytes image
func PasteText ¶
func PasteText(tSize float64, xpos, ypos, clientWidth, clientHeight int, text string, u8Pix []uint8, transparent bool)
Write some text into a bag of bytes image.
func RenderPara ¶
func RenderPara(f *FormatParams, xpos, ypos, minX, minY, maxX, maxY, clientWidth, clientHeight, cursorX, cursorY int, u8Pix []uint8, text string, transparent bool, doDraw bool, showCursor bool) (int, int, int)
Draw some text into a 32bit RGBA byte array, wrapping where needed. Supports all the options I need for a basic word processor, including vertical text, and different sized lines
This was a bad idea. Instead of all the if statements, we should just assume everything is left-to-right, top-to-bottom, and then rotate the entire block afterwards (we will also have to rotate the characters around their own center)
Return the cursor position (number of characters from start of text) that is closest to the mouse cursor (cursorX, cursorY)
xpos, ypos - The starting draw position, global minX, minY - The leftmost part of the draw subregion. To fill the whole image, set to 0,0 maxX, maxY - The rightmost edge of draw subregion. To fill the whole image, set to the image width clentWidth, clienHeight - maxX-minX? cursorX, cursorY - Mouse cursor coordinates, relative to whole image
func RenderTokenPara ¶
func Rotate270 ¶
Rotate a 32bit byte array into a new byte array. The target array will be created with the correct dimensions
func Rotate90 ¶
Rotate a 32bit byte array into a new byte array. The target array will be created with the correct dimensions
func SanityCheck ¶
func SanityCheck(f *FormatParams, txt string)
Check and correct formatparams to make sure e.g. cursor is always on the screen
func Uint8ToBytes ¶
Convert an array of uint8 to byte, because somehow golang manages to pack them differently in memeory
Types ¶
type FormatParams ¶
type FormatParams struct { Colour *RGBA //Text colour Line int //The line number, i.e. the number of /n characters from the start Cursor int //The cursor position, in characters from the start of the text SelectStart int //Start of the selection box, counted from the start of document SelectEnd int //End of the selection box, counted from the start of document StartLinePos int //Updated during render, holds the closest start of line, including soft line breaks FontSize float64 //Fontsize, in points or something idfk FirstDrawnCharPos int //The first character to draw on the screen. Anything before this is ignored LastDrawnCharPos int //The last character that we were able to fit on the screen TailBuffer bool //Nothing for now Outline bool //Nothing for now Vertical bool //Draw texture vertically for Chinese/Japanese rendering SelectColour *RGBA //Selection text colour }
Holds all the configuration details for drawing a string into a texture. This structure gets written to during the draw
func CopyFormatter ¶
func CopyFormatter(inF *FormatParams) *FormatParams
Duplicate a formatter, that can be modified without changing the original
func NewFormatter ¶
func NewFormatter() *FormatParams
Create a new text formatter, with useful default parameters