draw2dgl

package
v0.0.0-...-c41aa97 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2017 License: BSD-2-Clause Imports: 14 Imported by: 0

Documentation

Overview

Package draw2dgl provides a graphic context that can draw vector graphics and text on OpenGL.

Index

Constants

View Source
const M16 uint32 = 1<<16 - 1

Variables

This section is empty.

Functions

func DrawContour

func DrawContour(path draw2d.PathBuilder, ps []truetype.Point, dx, dy float64)

DrawContour draws the given closed contour at the given sub-pixel offset.

Types

type FontExtents

type FontExtents struct {
	// Ascent is the distance that the text
	// extends above the baseline.
	Ascent float64

	// Descent is the distance that the text
	// extends below the baseline.  The descent
	// is given as a negative value.
	Descent float64

	// Height is the distance from the lowest
	// descending point to the highest ascending
	// point.
	Height float64
}

FontExtents contains font metric information.

func Extents

func Extents(font *truetype.Font, size float64) FontExtents

Extents returns the FontExtents for a font. TODO needs to read this https://developer.apple.com/fonts/TrueType-Reference-Manual/RM02/Chap2.html#intro

type GraphicContext

type GraphicContext struct {
	*draw2dbase.StackGraphicContext

	FontCache draw2d.FontCache

	DPI int
	// contains filtered or unexported fields
}

func NewGraphicContext

func NewGraphicContext(width, height int) *GraphicContext

NewGraphicContext creates a new Graphic context from an image.

func (*GraphicContext) Clear

func (gc *GraphicContext) Clear()

TODO

func (*GraphicContext) ClearRect

func (gc *GraphicContext) ClearRect(x1, y1, x2, y2 int)

TODO

func (*GraphicContext) CreateStringPath

func (gc *GraphicContext) CreateStringPath(s string, x, y float64) float64

CreateStringPath creates a path from the string s at x, y, and returns the string width. The text is placed so that the left edge of the em square of the first character of s and the baseline intersect at x, y. The majority of the affected pixels will be above and to the right of the point, but some may be below or to the left. For example, drawing a string that starts with a 'J' in an italic font may affect pixels below and left of the point.

func (*GraphicContext) DrawImage

func (gc *GraphicContext) DrawImage(img image.Image)

TODO

func (*GraphicContext) Fill

func (gc *GraphicContext) Fill(paths ...*draw2d.Path)

func (*GraphicContext) FillString

func (gc *GraphicContext) FillString(text string) (width float64)

FillString draws the text at point (0, 0)

func (*GraphicContext) FillStringAt

func (gc *GraphicContext) FillStringAt(text string, x, y float64) (width float64)

FillStringAt draws the text at the specified point (x, y)

func (*GraphicContext) FillStroke

func (gc *GraphicContext) FillStroke(paths ...*draw2d.Path)

func (*GraphicContext) GetDPI

func (gc *GraphicContext) GetDPI() int

func (*GraphicContext) GetStringBounds

func (gc *GraphicContext) GetStringBounds(s string) (left, top, right, bottom float64)

GetStringBounds returns the approximate pixel bounds of the string s at x, y. The the left edge of the em square of the first character of s and the baseline intersect at 0, 0 in the returned coordinates. Therefore the top and left coordinates may well be negative.

func (*GraphicContext) SetDPI

func (gc *GraphicContext) SetDPI(dpi int)

func (*GraphicContext) SetFont

func (gc *GraphicContext) SetFont(font *truetype.Font)

SetFont sets the font used to draw text.

func (*GraphicContext) SetFontSize

func (gc *GraphicContext) SetFontSize(fontSize float64)

SetFontSize sets the font size in points (as in “a 12 point font”).

func (*GraphicContext) Stroke

func (gc *GraphicContext) Stroke(paths ...*draw2d.Path)

func (*GraphicContext) StrokeString

func (gc *GraphicContext) StrokeString(text string) (width float64)

StrokeString draws the contour of the text at point (0, 0)

func (*GraphicContext) StrokeStringAt

func (gc *GraphicContext) StrokeStringAt(text string, x, y float64) (width float64)

StrokeStringAt draws the contour of the text at point (x, y)

type Painter

type Painter struct {
	// The Porter-Duff composition operator.
	Op draw.Op
	// contains filtered or unexported fields
}

func NewPainter

func NewPainter() *Painter

NewRGBAPainter creates a new RGBAPainter for the given image.

func (*Painter) Flush

func (p *Painter) Flush()

func (*Painter) Paint

func (p *Painter) Paint(ss []raster.Span, done bool)

Paint satisfies the Painter interface by painting ss onto an image.RGBA.

func (*Painter) SetColor

func (p *Painter) SetColor(c color.Color)

SetColor sets the color to paint the spans.

Jump to

Keyboard shortcuts

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