draw

package
v0.0.0-...-226917b Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2021 License: MIT Imports: 1 Imported by: 3

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

This section is empty.

Types

type Buffer

type Buffer struct {
	Commands []Command
	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) Clip

func (b *Buffer) Clip() Rect

Clip returns the area that is currently visible

func (*Buffer) Fill

func (b *Buffer) Fill(r Rect, c Color)

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

func (*Buffer) Frame

func (b *Buffer) Frame(r Rect, c Color, cr, th float64)

Outline adds a command to outline a rectangle.

func (*Buffer) Icon

func (b *Buffer) Icon(r Rect, id string, c Color)

Icon adds a command to draw an icon.

func (*Buffer) Image

func (b *Buffer) Image(r Rect, i Drawable, c Color)

Image adds a command to draw an image.

func (*Buffer) Pop

func (b *Buffer) Pop()

Pop undoes the last call to Push.

func (*Buffer) Push

func (b *Buffer) Push(r Rect)

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 float64)

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

func (*Buffer) Shadow

func (b *Buffer) Shadow(r Rect, c Color, size float64)

Shadow adds a command to draw a drop shadow.

func (*Buffer) Size

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

Size returns the current size of the drawing area.

func (*Buffer) SubImage

func (b *Buffer) SubImage(r Rect, i Drawable, sub Rect, c Color)

SubImage adds a command to draw part of an image.

func (*Buffer) Text

func (b *Buffer) Text(x, y float64, text string, font Font, c Color, size float64)

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
	X, Y     float64
	Clip     Rect
}

type Drawable

type Drawable interface {
	Size(int, int) (int, int)
	Draw(dst *image.RGBA, force bool) bool
}

type Fill

type Fill struct {
	Rect  Rect
	Color Color
}

type Font

type Font string

Font describes a font face.

type FontLookup

type FontLookup interface {
	Measure(string, Font, float64) TextMetrics
	Index(string, float64, Font, float64) int
}

A FontLookup provides information about fonts.

type Frame

type Frame struct {
	Rect      Rect
	Radius    float64
	Thickness float64
	Color     Color
}

type Icon

type Icon struct {
	Rect  Rect
	Icon  string
	Color Color
}

type Image

type Image struct {
	Image Drawable
	Rect  Rect
	Color Color
}

type Rect

type Rect struct {
	X, Y, W, H float64
}

func WH

func WH(w, h float64) Rect

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

func XYWH

func XYWH(x, y, w, h float64) Rect

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

func XYXY

func XYXY(x, y, x1, y1 float64) Rect

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

func (Rect) Add

func (r Rect) Add(x, y float64) Rect

func (Rect) Contains

func (r Rect) Contains(x, y float64) bool

func (Rect) Empty

func (r Rect) Empty() bool

func (Rect) In

func (r Rect) In(s Rect) bool

func (Rect) Intersect

func (r Rect) Intersect(s Rect) Rect

type Shadow

type Shadow struct {
	Rect  Rect
	Color Color
	Size  float64
}

type Text

type Text struct {
	X, Y  float64
	Text  string
	Font  Font
	Color Color
	Size  float64
}

type TextMetrics

type TextMetrics struct {
	Ascent, Descent float64
	Advance         float64
}

type TextStyle

type TextStyle struct {
	Font  Font
	Color Color
}

Jump to

Keyboard shortcuts

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