Package render

import ""

Overview ▾

package render provides several routines for drawing simple shapes and gradients. It also makes an attempt at unifying colors with the Color type.


const (
    BorderTop = 1 << iota
const (
    GradientHorz = iota
const (
    GradientRegular = iota
const (
    DiagTopLeft = iota


var NoColor = Color{}

type Color

type Color struct {
    // contains filtered or unexported fields

func NewColor

func NewColor(clr int) Color

func NewGradient

func NewGradient(start, end int) Color

func NewImageColor

func NewImageColor(clr color.Color) Color

func NewImageGradient

func NewImageGradient(startClr, endClr color.Color) Color

func (*Color) ColorSet

func (c *Color) ColorSet(clr int)

func (*Color) GradientSet

func (c *Color) GradientSet(start, end int)

func (Color) ImageColor

func (c Color) ImageColor() color.RGBA

func (Color) Int

func (c Color) Int() int

func (Color) IsGradient

func (c Color) IsGradient() bool

IsGradient returns whether the theme color is a gradient or not. Basically, a themeColor can either be a regular color (like an int) or a gradient when both 'start' and 'end' have valid color values.

func (Color) RGB

func (c Color) RGB() (r, g, b int)

func (Color) RGB8

func (c Color) RGB8() (r, g, b uint8)

func (Color) Steps

func (c Color) Steps(size int) []color.RGBA

steps returns a slice of colors corresponding to the gradient of colors from start to end. The size is determined by the 'size' parameter. The first and last colors in the slice are guaranteed to be c.start and c.end. (Unless the size is 1, in which case, the first and only color in the slice is c.start.) XXX: Optimize.

func (Color) String

func (c Color) String() string

func (Color) Uint32

func (c Color) Uint32() uint32

type Image

type Image struct {

func New

func New(ximg *xgraphics.Image) *Image

func NewBorder

func NewBorder(X *xgbutil.XUtil, borderType int, borderColor,
    bgColor Color, width, height, gradientType, gradientDir int) *Image

func NewCorner

func NewCorner(X *xgbutil.XUtil, borderType int, borderColor,
    bgColor Color, width, height, diagonal int) *Image

func NewSolid

func NewSolid(X *xgbutil.XUtil, bgColor Color, width, height int) *Image

func (*Image) Gradient

func (img *Image) Gradient(gradientType, gradientDir int, clr Color)

func (*Image) GradientFunc

func (img *Image) GradientFunc(gradientType, gradientDir int, clr Color,
    pixel func(x, y int) bool)

XXX: Optimize.

func (*Image) ThinBorder

func (img *Image) ThinBorder(borderType int, borderColor Color)

XXX: Optimize.