renderer

package
v0.0.0-...-0efad91 Latest Latest
Warning

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

Go to latest
Published: May 3, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MonoFontFace, MonoFontFaceBold                                      font.Face
	MonoFontHeight, MonoFontAdvance, MonoFontGlyphWidth, MonoFontAscent fixed.Int26_6
)

These variables represent a default monospaced font for renderers to use and caches of properties that are useful for a renderer. Renderers don't *have* to use them, but doing so avoids race conditions with freetype and makes it easier to use default implementations built around them, as well as ensures consistency between renderers of different languages.

View Source
var AttributeColour = BuiltinTypeColour
View Source
var BuiltinTypeColour = color.RGBA{0x00, 0x6D, 0, 0xFF}
View Source
var CommentColour = color.RGBA{0, 0, 0xFF, 0xFF}
View Source
var DeleteBackground = color.RGBA{0xFF, 0xDC, 0xDC, 0xFF}
View Source
var ErrNoCharacter = errors.New("No character under the mouse cursor.")
View Source
var InsertBackground = color.RGBA{0xEF, 0xFF, 0xEF, 0xFF}
View Source
var KeywordColour = color.RGBA{0x6D, 0x6D, 0, 0xFF}
View Source
var NormalBackground = color.RGBA{0xFF, 0xFF, 0xDC, 0xFF}

Background colours

View Source
var OperatorColour = color.RGBA{0x55, 0x55, 0x55, 0xFF}
View Source
var StringColour = color.RGBA{0xFF, 0, 0, 0xFF}
View Source
var TagColour = color.RGBA{0x8A, 0x66, 0x00, 0xFF} //KeywordColour
View Source
var TagDelimitorColour = color.RGBA{0x70, 0x94, 0xAE, 0xFF} // < and > characters in HTML

Mostly for HTML-like languages

View Source
var TaglineBackground = color.RGBA{0xEA, 0xFF, 0xFF, 0xFF}
View Source
var TextColour = color.RGBA{0, 0, 0, 0xFF}
View Source
var TextHighlight = color.RGBA{0xBC, 0xFC, 0xF9, 0xFF}

Text colours

Functions

func GetNamedRenderer

func GetNamedRenderer(name string) demodel.Renderer

func GetRenderer

func GetRenderer(buff *demodel.CharBuffer) demodel.Renderer

func RecalculateFontFace

func RecalculateFontFace(dpi float64)

func RegisterRenderer

func RegisterRenderer(name string, r demodel.Renderer)

Types

type DefaultImageMapper

type DefaultImageMapper struct {
	LastBuf     *demodel.CharBuffer
	LastBufSize int
	IMap        *ImageMap
}

DefaultImageMapper is a type that can be mixed in to renderers to provide a default implementation of GetImageMap() equivalent to what would be used by the NoSyntaxRenderer.

func (*DefaultImageMapper) GetImageMap

func (imap *DefaultImageMapper) GetImageMap(buf *demodel.CharBuffer, viewport image.Rectangle) demodel.ImageMap

func (*DefaultImageMapper) InvalidateCache

func (imap *DefaultImageMapper) InvalidateCache()

type DefaultSizeCalcer

type DefaultSizeCalcer struct {
	LastBuf     *demodel.CharBuffer
	LastBufSize int
	SizeCache   image.Rectangle
}

A DefaultSizeCalcer is a type that can be mixed in to renders to provide a default implementation of Bounds, for calculating what the bounds would be with the NoSyntaxRenderer. This is useful for renderers which only provide syntax highlighting but do nothing that would change the size of the image rendered.

func (*DefaultSizeCalcer) Bounds

func (*DefaultSizeCalcer) InvalidateCache

func (r *DefaultSizeCalcer) InvalidateCache()

type ImageLoc

type ImageLoc struct {
	Loc fixed.Rectangle26_6

	Idx uint
}

type ImageMap

type ImageMap struct {
	IMap []ImageLoc
	Buf  *demodel.CharBuffer
}

func (ImageMap) At

func (im ImageMap) At(x, y int) (uint, error)

func (ImageMap) Get

func (im ImageMap) Get(idx uint) (image.Rectangle, error)

Returns the bounding rectangle for the character at index idx in the character buffer.

type TaglineRenderer

type TaglineRenderer struct {
	DefaultSizeCalcer
	DefaultImageMapper
}

TaglineRenderer is like the default renderer which doesn't provide syntax highlighting, but uses a different background colour which doesn't change regardless of mode.

func (TaglineRenderer) CanRender

func (r TaglineRenderer) CanRender(*demodel.CharBuffer) bool

func (*TaglineRenderer) InvalidateCache

func (r *TaglineRenderer) InvalidateCache()

func (TaglineRenderer) RenderInto

func (r TaglineRenderer) RenderInto(dst draw.Image, buf *demodel.CharBuffer, viewport image.Rectangle) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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