draw

package
v0.0.0-...-09fa35e Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2019 License: MIT Imports: 1 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Black       = Color{0, 0, 0, 255}
	White       = Color{255, 255, 255, 255}
	Transparent = Color{0, 0, 0, 0}
)

Functions

func WH

func WH(w, h int) image.Rectangle

WH creates a rectangle at (0,0) with the given size.

func XYWH

func XYWH(x, y, w, h int) image.Rectangle

XYWH creates a rectangle at the given point with the given size.

func XYXY

func XYXY(x, y, x1, y1 int) image.Rectangle

XYXY creates a rectangle with the given minimum and maximum points.

Types

type Buffer

type Buffer struct {
	Commands   []Command
	FontLookup FontLookup
	All        []CommandList
	// contains filtered or unexported fields
}

A Buffer contains a list of commands.

func (*Buffer) Add

func (b *Buffer) Add(c ...Command)

Add adds commands to the buffer.

func (*Buffer) Fill

func (b *Buffer) Fill(r image.Rectangle, c Color)

Fill adds a command to fill an area with a solid color.

func (*Buffer) Icon

func (b *Buffer) Icon(r image.Rectangle, id string, c Color)

Icon adds a command to draw an icon.

func (*Buffer) Image

func (b *Buffer) Image(r image.Rectangle, i *image.RGBA, c Color, update bool)

Image adds a command to draw an image. update should be true if the image has changed since it was last drawn.

func (*Buffer) Outline

func (b *Buffer) Outline(r image.Rectangle, c Color)

Outline adds a command to outline a rectangle.

func (*Buffer) Pop

func (b *Buffer) Pop()

Pop undoes the last call to Push.

func (*Buffer) Push

func (b *Buffer) Push(r image.Rectangle)

Push constrains drawing to a rectangle. Subsequent operations will be translated and clipped. Subsequent calls to Size will return the rectangle's size.

func (*Buffer) Reset

func (b *Buffer) Reset(w, h int)

Reset clears the command list and sets the size of the drawing area.

func (*Buffer) Shadow

func (b *Buffer) Shadow(r image.Rectangle, c Color, size int)

Shadow adds a command to draw a drop shadow.

func (*Buffer) Size

func (b *Buffer) Size() (int, int)

Size returns the current size of the drawing area.

func (*Buffer) SubImage

func (b *Buffer) SubImage(r image.Rectangle, i *image.RGBA, sub image.Rectangle, c Color, update bool)

SubImage adds a command to draw part of an image. update should be true if the image has changed since it was last drawn.

func (*Buffer) Text

func (b *Buffer) Text(p image.Point, text string, c Color, font Font)

Text adds a command to render text.

type Color

type Color [4]byte

Color is a 32 bit RGBA color with premultiplied alpha.

func Blend

func Blend(c, d Color, f float32) Color

Blend mixes two colors. f must be in range [0,1]

func Gray

func Gray(i float32) Color

Gray creates an opaque gray color from an intensity in range [0,1], where 0 means black and 1 means white.

func RGBA

func RGBA(r, g, b, a float32) Color

RGBA creates a color from float RGBA values. The color components should be in range [0,1] regardless of the alpha value; this constructor will multiply them with the alpha value.

func (Color) A

func (c Color) A() float32

R returns the color's alpha component

func (Color) B

func (c Color) B() float32

R returns the color's blue component

func (Color) G

func (c Color) G() float32

R returns the color's green component

func (Color) R

func (c Color) R() float32

R returns the color's red component

type Command

type Command interface{}

type CommandList

type CommandList struct {
	Commands []Command
	Offset   image.Point
	Clip     image.Rectangle
}

type Fill

type Fill struct {
	Rect  image.Rectangle
	Color Color
}

type Font

type Font struct {
	Name string
	Size float32
}

Font describes a font face.

type FontLookup

type FontLookup interface {
	// GetClosest takes a font face description and returns the best match that is actually supported.
	// If a font has multiple names, it should return a consistent, canonical name.
	GetClosest(Font) Font
	// Metrics returns the FontMetrics for the specified font.
	// Implementations must not assume that the argument has been passed through GetClosest.
	Metrics(Font) FontMetrics
}

A FontLookup provides information about fonts.

type FontMetrics

type FontMetrics interface {
	Ascent() int
	Descent() int
	LineHeight() int
	Advance(s string) float32
	Index(s string, pos float32) int
}

FontMetrics can be used to query the geometry of a font face.

type Icon

type Icon struct {
	Rect  image.Rectangle
	Icon  string
	Color Color
}

type Image

type Image struct {
	Rect   image.Rectangle
	Image  *image.RGBA
	Color  Color
	Update bool
}

type Outline

type Outline struct {
	Rect  image.Rectangle
	Color Color
}

type Shadow

type Shadow struct {
	Rect  image.Rectangle
	Color Color
	Size  int
}

type Text

type Text struct {
	Position image.Point
	Text     string
	Font     Font
	Color    Color
}

Jump to

Keyboard shortcuts

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