drawgl

package module
v0.0.0-...-ed1255c Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2016 License: MIT Imports: 10 Imported by: 0

README

drawgl

Drawing with graphs

Documentation

Index

Constants

View Source
const (
	RGB Channel = iota
	Red         = 1 << iota
	Green
	Blue
	Alpha
)

Variables

View Source
var (
	ErrOutOfBounds = errors.New("out of bounds")
)
View Source
var (
	FloatColorModel color.Model = color.ModelFunc(floatColorModel)
)

Functions

func MaskFactor

func MaskFactor(pt image.Point, mask Mask) (factor float32)

func ParseLength

func ParseLength(dimen string) (px int, percent float64, err error)

ParseLength parses a string containing a number an an optional unit of length. The supported units are '%' for a percentage, 'px' or none for a pixel. It returns both pixel and percentage, as well as any possible error that might have occured during parsing.

func TranslateCoords

func TranslateCoords(x, y int, b image.Rectangle, h EdgeHandler) (mx, my int)

Types

type Channel

type Channel int

func (Channel) Is

func (c Channel) Is(o Channel) bool

Is checks whether the channel contains a given value

func (Channel) MarshalJSON

func (c Channel) MarshalJSON() (b []byte, err error)

func (Channel) Normalize

func (c Channel) Normalize(includeAlpha ...bool) Channel

Normalize returns a normalized version a channel value. If the value is the composite RGB value, it is transformed to Red | Green | Blue. If includeAlpha is given and true, the alpha is also added to the channel

func (*Channel) UnmarshalJSON

func (c *Channel) UnmarshalJSON(b []byte) (err error)

type ColorValue

type ColorValue float32

func (ColorValue) Clamped

func (v ColorValue) Clamped() ColorValue

Clamped returns a clamped color value, with a range 0-1

type EdgeHandler

type EdgeHandler int
const (
	Extend EdgeHandler = iota
	Wrap
)

type FloatColor

type FloatColor struct {
	R, G, B, A ColorValue
}

func MaskColor

func MaskColor(dst FloatColor, src FloatColor, c Channel, f float32, op draw.Op) FloatColor

func (FloatColor) ApproxEqual

func (c FloatColor) ApproxEqual(o FloatColor) bool

ApproxEqual is used by tests to check whether a color is approximately equal to another

func (FloatColor) RGBA

func (c FloatColor) RGBA() (uint32, uint32, uint32, uint32)

type FloatImage

type FloatImage struct {
	// Pix holds the image's pixels, in R, G, B, A order and big-endian format. The pixel at
	// (x, y) starts at Pix[(y-Rect.Min.Y)*Stride + (x-Rect.Min.X)*4].
	Pix []ColorValue
	// Stride is the Pix stride (in bytes) between vertically adjacent pixels.
	Stride int
	// Rect is the image's bounds.
	Rect image.Rectangle
}

func ConvertImage

func ConvertImage(img image.Image) *FloatImage

func CopyImage

func CopyImage(img *FloatImage) *FloatImage

func NewFloatImage

func NewFloatImage(r image.Rectangle) *FloatImage

NewFloatImage returns a new FloatImage with the given bounds.

func (*FloatImage) At

func (p *FloatImage) At(x, y int) color.Color

func (*FloatImage) Bounds

func (p *FloatImage) Bounds() image.Rectangle

func (*FloatImage) ColorModel

func (p *FloatImage) ColorModel() color.Model

func (*FloatImage) FloatAt

func (p *FloatImage) FloatAt(x, y int) FloatColor

func (*FloatImage) Opaque

func (p *FloatImage) Opaque() bool

Opaque scans the entire image and reports whether it is fully opaque.

func (*FloatImage) PixOffset

func (p *FloatImage) PixOffset(x, y int) int

PixOffset returns the index of the first element of Pix that corresponds to the pixel at (x, y).

func (*FloatImage) Set

func (p *FloatImage) Set(x, y int, c color.Color)

func (*FloatImage) SetColor

func (p *FloatImage) SetColor(x, y int, c FloatColor)

func (*FloatImage) SubImage

func (p *FloatImage) SubImage(r image.Rectangle) image.Image

SubImage returns an image representing the portion of the image p visible through r. The returned value shares pixels with the original image.

func (*FloatImage) UnsafeFloatAt

func (p *FloatImage) UnsafeFloatAt(x, y int) FloatColor

func (*FloatImage) UnsafeSetColor

func (p *FloatImage) UnsafeSetColor(x, y int, c FloatColor)

type Graph

type Graph struct {
}

func (Graph) Process

func (g Graph) Process(start graph.Linker) error

type LinearRectangleIterator

type LinearRectangleIterator image.Rectangle

func (LinearRectangleIterator) Iterate

func (rect LinearRectangleIterator) Iterate(mask Mask, fn func(pt image.Point, factor float32))

func (LinearRectangleIterator) VerticalIterate

func (rect LinearRectangleIterator) VerticalIterate(mask Mask, fn func(pt image.Point, factor float32))

type Mask

type Mask struct {
	Image image.Image
	Rect  image.Rectangle
	// contains filtered or unexported fields
}

func NewMask

func NewMask(image image.Image, rect image.Rectangle) Mask

type Meta

type Meta map[string]interface{}

type ParallelRectangleIterator

type ParallelRectangleIterator image.Rectangle

func (ParallelRectangleIterator) Iterate

func (rect ParallelRectangleIterator) Iterate(mask Mask, fn func(pt image.Point, factor float32))

func (ParallelRectangleIterator) VerticalIterate

func (rect ParallelRectangleIterator) VerticalIterate(mask Mask, fn func(pt image.Point, factor float32))

type Processor

type Processor interface {
	Process(wd graph.WalkData, buffers map[graph.ConnectorName]Result, output chan<- Result)
}

type RectangleIterator

type RectangleIterator interface {
	// Iterate iterates over the image buffer, calling the fn function for each
	// point. The cycle order is row -> column. Implementations must ensure
	// that all columns of a given row are received in a single goroutine
	Iterate(mask Mask, fn func(pt image.Point, factor float32))
	// VerticalIterate iterates over the image buffer, calling the fn function
	// for each point. The cycle order is column -> row. Implementations must
	// ensure that all rows of a given column are received in a single
	// goroutine
	VerticalIterate(mask Mask, fn func(pt image.Point, factor float32))
}

func DefaultRectangleIterator

func DefaultRectangleIterator(rect image.Rectangle, forceLinear ...bool) RectangleIterator

type Result

type Result struct {
	Id           graph.Id
	Buffer       *FloatImage
	NamedBuffers map[graph.ConnectorName]*FloatImage
	Meta         Meta
	Error        error
}

Directories

Path Synopsis
examples
io

Jump to

Keyboard shortcuts

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