xcolor

package module
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2018 License: MIT Imports: 5 Imported by: 1

README

xcolor

Go: To use the color expression strings of the LaTeX xcolor package

API

See GoDoc.

LICENSE

MIT License

CHANGELOG

  • Version 0.2.1 <2018/03/01>

    • Bug fix.
  • Version 0.2.0 <2018/02/27>

    • Beta release.

Takayuki YATO (aka. "ZR")
https://github.com/zr-tex8r

Documentation

Overview

Package xcolor enables one to specify a color using color expression strings as used in the LaTeX package "xcolor".

The package employs its own internal structs for representing colors, and mainly uses the structs. It also supports conversion to values of the standard color.Color type.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GoColor

func GoColor(expr string) (color.Color, error)

GoColor converts a color expression to a color value of the standard color.Color type. Equivalent to Parse(expr).GoColor().

func LoadPreset

func LoadPreset(name string) error

LoadPreset loads a color name preset; the preset name "XXX" corresponds to the option "XXXnames" of the LaTeX xcolor package. The set names available are: "dvips", "svg".

Types

type Color

type Color interface {
	// Model tells the model of this color.
	Model() Model
	// Params returns the values of the numerical parameters for this color.
	Params() []float64
	// Compl returns the complementary of this color.
	Compl() Color
	// Blend returns the blended color made of this and c.
	Blend(r float64, c Color) Color
	// Convert converts this color to another color model.
	Convert(m Model) Color
	// HtmlCode returns the HTML color literal for this color.
	HtmlCode() string
	// CssCode returns the CSS color literal for this color.
	CssCode() string
	// GoColor() convert to the Color value of standard color package.
	GoColor() color.Color
	// RGBA() is provided so that Color will satisfy color.Color.
	RGBA() (r, g, b, a uint32)

	fmt.Stringer
	// contains filtered or unexported methods
}

Interface Color represents a color.

Note: although the type Color can be used as color.Color by itself, such use will be agnostic of the underlying color model, unless the program knows the xcolor package and treats its concrete types. On the other hand, the conversion using GoColor() will yield values of appropriate concrete types of 'image/color', namely, NRGBA, CMYK and Gray.

func NewCmyk

func NewCmyk(c, m, y, k float64) Color

NewCmyk makes an rgb color.

func NewGray

func NewGray(w float64) Color

NewGray makes a gray color.

func NewRgb

func NewRgb(r, g, b float64) Color

NewRgb makes an rgb color.

func Parse

func Parse(expr string) (Color, error)

Parse converts a color expression to a Color value.

type Model

type Model int

Enum Model represents a color model.

const (
	Gray Model = iota
	Rgb
	Cmyk
)

func (Model) String

func (m Model) String() string

Jump to

Keyboard shortcuts

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