draw

package
v0.0.0-...-955f326 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2020 License: MPL-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PNGExt  = ".png"
	JPGExt  = ".jpg"
	JPEGExt = ".jpeg"
	GIFExt  = ".gif"
)

Image file extensions.

Variables

View Source
var (
	AliceBlue            = RGB(240, 248, 255)
	AntiqueWhite         = RGB(250, 235, 215)
	Aqua                 = RGB(0, 255, 255)
	Aquamarine           = RGB(127, 255, 212)
	Azure                = RGB(240, 255, 255)
	Beige                = RGB(245, 245, 220)
	Bisque               = RGB(255, 228, 196)
	Black                = RGB(0, 0, 0)
	BlanchedAlmond       = RGB(255, 235, 205)
	Blue                 = RGB(0, 0, 255)
	BlueViolet           = RGB(138, 43, 226)
	Brown                = RGB(165, 42, 42)
	BurlyWood            = RGB(222, 184, 135)
	CadetBlue            = RGB(95, 158, 160)
	Chartreuse           = RGB(127, 255, 0)
	Chocolate            = RGB(210, 105, 30)
	Coral                = RGB(255, 127, 80)
	CornflowerBlue       = RGB(100, 149, 237)
	Cornsilk             = RGB(255, 248, 220)
	Crimson              = RGB(220, 20, 60)
	Cyan                 = RGB(0, 255, 255)
	DarkBlue             = RGB(0, 0, 139)
	DarkCyan             = RGB(0, 139, 139)
	DarkGoldenRod        = RGB(184, 134, 11)
	DarkGray             = RGB(169, 169, 169)
	DarkGreen            = RGB(0, 100, 0)
	DarkGrey             = RGB(169, 169, 169)
	DarkKhaki            = RGB(189, 183, 107)
	DarkMagenta          = RGB(139, 0, 139)
	DarkOliveGreen       = RGB(85, 107, 47)
	DarkOrange           = RGB(255, 140, 0)
	DarkOrchid           = RGB(153, 50, 204)
	DarkRed              = RGB(139, 0, 0)
	DarkSalmon           = RGB(233, 150, 122)
	DarkSeaGreen         = RGB(143, 188, 143)
	DarkSlateBlue        = RGB(72, 61, 139)
	DarkSlateGray        = RGB(47, 79, 79)
	DarkSlateGrey        = RGB(47, 79, 79)
	DarkTurquoise        = RGB(0, 206, 209)
	DarkViolet           = RGB(148, 0, 211)
	DeepPink             = RGB(255, 20, 147)
	DeepSkyBlue          = RGB(0, 191, 255)
	DimGray              = RGB(105, 105, 105)
	DimGrey              = RGB(105, 105, 105)
	DodgerBlue           = RGB(30, 144, 255)
	FireBrick            = RGB(178, 34, 34)
	FloralWhite          = RGB(255, 250, 240)
	ForestGreen          = RGB(34, 139, 34)
	Fuchsia              = RGB(255, 0, 255)
	Gainsboro            = RGB(220, 220, 220)
	GhostWhite           = RGB(248, 248, 255)
	Gold                 = RGB(255, 215, 0)
	GoldenRod            = RGB(218, 165, 32)
	Gray                 = RGB(128, 128, 128)
	Green                = RGB(0, 128, 0)
	GreenYellow          = RGB(173, 255, 47)
	Grey                 = RGB(128, 128, 128)
	HoneyDew             = RGB(240, 255, 240)
	HotPink              = RGB(255, 105, 180)
	IndianRed            = RGB(205, 92, 92)
	Indigo               = RGB(75, 0, 130)
	Ivory                = RGB(255, 255, 240)
	Khaki                = RGB(240, 230, 140)
	Lavender             = RGB(230, 230, 250)
	LavenderBlush        = RGB(255, 240, 245)
	LawnGreen            = RGB(124, 252, 0)
	LemonChiffon         = RGB(255, 250, 205)
	LightBlue            = RGB(173, 216, 230)
	LightCoral           = RGB(240, 128, 128)
	LightCyan            = RGB(224, 255, 255)
	LightGoldenRodYellow = RGB(250, 250, 210)
	LightGray            = RGB(211, 211, 211)
	LightGreen           = RGB(144, 238, 144)
	LightGrey            = RGB(211, 211, 211)
	LightPink            = RGB(255, 182, 193)
	LightSalmon          = RGB(255, 160, 122)
	LightSeaGreen        = RGB(32, 178, 170)
	LightSkyBlue         = RGB(135, 206, 250)
	LightSlateGray       = RGB(119, 136, 153)
	LightSlateGrey       = RGB(119, 136, 153)
	LightSteelBlue       = RGB(176, 196, 222)
	LightYellow          = RGB(255, 255, 224)
	Lime                 = RGB(0, 255, 0)
	LimeGreen            = RGB(50, 205, 50)
	Linen                = RGB(250, 240, 230)
	Magenta              = RGB(255, 0, 255)
	Maroon               = RGB(128, 0, 0)
	MediumAquaMarine     = RGB(102, 205, 170)
	MediumBlue           = RGB(0, 0, 205)
	MediumOrchid         = RGB(186, 85, 211)
	MediumPurple         = RGB(147, 112, 219)
	MediumSeaGreen       = RGB(60, 179, 113)
	MediumSlateBlue      = RGB(123, 104, 238)
	MediumSpringGreen    = RGB(0, 250, 154)
	MediumTurquoise      = RGB(72, 209, 204)
	MediumVioletRed      = RGB(199, 21, 133)
	MidnightBlue         = RGB(25, 25, 112)
	MintCream            = RGB(245, 255, 250)
	MistyRose            = RGB(255, 228, 225)
	Moccasin             = RGB(255, 228, 181)
	NavajoWhite          = RGB(255, 222, 173)
	Navy                 = RGB(0, 0, 128)
	OldLace              = RGB(253, 245, 230)
	Olive                = RGB(128, 128, 0)
	OliveDrab            = RGB(107, 142, 35)
	Orange               = RGB(255, 165, 0)
	OrangeRed            = RGB(255, 69, 0)
	Orchid               = RGB(218, 112, 214)
	PaleGoldenRod        = RGB(238, 232, 170)
	PaleGreen            = RGB(152, 251, 152)
	PaleTurquoise        = RGB(175, 238, 238)
	PaleVioletRed        = RGB(219, 112, 147)
	PapayaWhip           = RGB(255, 239, 213)
	PeachPuff            = RGB(255, 218, 185)
	Peru                 = RGB(205, 133, 63)
	Pink                 = RGB(255, 192, 203)
	Plum                 = RGB(221, 160, 221)
	PowderBlue           = RGB(176, 224, 230)
	Purple               = RGB(128, 0, 128)
	Red                  = RGB(255, 0, 0)
	RosyBrown            = RGB(188, 143, 143)
	RoyalBlue            = RGB(65, 105, 225)
	SaddleBrown          = RGB(139, 69, 19)
	Salmon               = RGB(250, 128, 114)
	SandyBrown           = RGB(244, 164, 96)
	SeaGreen             = RGB(46, 139, 87)
	SeaShell             = RGB(255, 245, 238)
	Sienna               = RGB(160, 82, 45)
	Silver               = RGB(192, 192, 192)
	SkyBlue              = RGB(135, 206, 235)
	SlateBlue            = RGB(106, 90, 205)
	SlateGray            = RGB(112, 128, 144)
	SlateGrey            = RGB(112, 128, 144)
	Snow                 = RGB(255, 250, 250)
	SpringGreen          = RGB(0, 255, 127)
	SteelBlue            = RGB(70, 130, 180)
	Tan                  = RGB(210, 180, 140)
	Teal                 = RGB(0, 128, 128)
	Thistle              = RGB(216, 191, 216)
	Tomato               = RGB(255, 99, 71)
	Turquoise            = RGB(64, 224, 208)
	Violet               = RGB(238, 130, 238)
	Wheat                = RGB(245, 222, 179)
	White                = RGB(255, 255, 255)
	WhiteSmoke           = RGB(245, 245, 245)
	Yellow               = RGB(255, 255, 0)
	YellowGreen          = RGB(154, 205, 50)
)

CSS named colors.

View Source
var (
	AlternateSelectedControlTextColor          = &DynamicColor{Color: White}
	ControlAccentColor                         = &DynamicColor{Color: RGB(0, 122, 255)}
	ControlBackgroundColor                     = &DynamicColor{Color: White}
	ControlColor                               = &DynamicColor{Color: White}
	ControlEdgeAdjColor                        = &DynamicColor{Color: ThemeBlack().SetAlphaIntensity(0.35)}
	ControlEdgeHighlightAdjColor               = &DynamicColor{Color: ThemeWhite().SetAlphaIntensity(0.35)}
	ControlTextColor                           = &DynamicColor{Color: ARGB(0.847059, 0, 0, 0)}
	DisabledControlTextColor                   = &DynamicColor{Color: ARGB(0.247059, 0, 0, 0)}
	FindHighlightColor                         = &DynamicColor{Color: Yellow}
	GridColor                                  = &DynamicColor{Color: RGB(204, 204, 204)}
	HeaderTextColor                            = &DynamicColor{Color: ARGB(0.847059, 0, 0, 0)}
	HighlightColor                             = &DynamicColor{Color: White}
	InvalidBackgroundColor                     = &DynamicColor{Color: RGB(255, 204, 204)}
	KeyboardFocusIndicatorColor                = &DynamicColor{Color: ARGB(0.247059, 0, 103, 244)}
	LabelColor                                 = &DynamicColor{Color: ARGB(0.847059, 0, 0, 0)}
	LinkColor                                  = &DynamicColor{Color: RGB(0, 104, 218)}
	PlaceholderTextColor                       = &DynamicColor{Color: ARGB(0.247059, 0, 0, 0)}
	QuaternaryLabelColor                       = &DynamicColor{Color: ARGB(0.098039, 0, 0, 0)}
	SecondaryLabelColor                        = &DynamicColor{Color: ARGB(0.498039, 0, 0, 0)}
	SelectedContentBackgroundColor             = &DynamicColor{Color: RGB(0, 99, 225)}
	SelectedControlColor                       = &DynamicColor{Color: RGB(179, 215, 255)}
	SelectedControlTextColor                   = &DynamicColor{Color: ARGB(0.847059, 0, 0, 0)}
	SelectedMenuItemTextColor                  = &DynamicColor{Color: White}
	SelectedTextBackgroundColor                = &DynamicColor{Color: RGB(179, 215, 255)}
	SelectedTextColor                          = &DynamicColor{Color: Black}
	SeparatorColor                             = &DynamicColor{Color: ARGB(0.098039, 0, 0, 0)}
	ShadowColor                                = &DynamicColor{Color: Black}
	SystemBlueColor                            = &DynamicColor{Color: RGB(0, 122, 255)}
	SystemBrownColor                           = &DynamicColor{Color: RGB(162, 132, 94)}
	SystemGrayColor                            = &DynamicColor{Color: RGB(142, 142, 147)}
	SystemGreenColor                           = &DynamicColor{Color: RGB(40, 205, 65)}
	SystemOrangeColor                          = &DynamicColor{Color: RGB(255, 149, 0)}
	SystemPinkColor                            = &DynamicColor{Color: RGB(255, 45, 85)}
	SystemPurpleColor                          = &DynamicColor{Color: RGB(175, 82, 222)}
	SystemRedColor                             = &DynamicColor{Color: RGB(255, 59, 48)}
	SystemYellowColor                          = &DynamicColor{Color: RGB(255, 204, 0)}
	TertiaryLabelColor                         = &DynamicColor{Color: ARGB(0.247059, 0, 0, 0)}
	TextAlternateBackgroundColor               = &DynamicColor{Color: RGB(244, 245, 245)}
	TextBackgroundColor                        = &DynamicColor{Color: White}
	TextColor                                  = &DynamicColor{Color: Black}
	UnderPageBackgroundColor                   = &DynamicColor{Color: ARGB(0.898039, 150, 150, 150)}
	UnemphasizedSelectedContentBackgroundColor = &DynamicColor{Color: Gainsboro}
	UnemphasizedSelectedTextBackgroundColor    = &DynamicColor{Color: Gainsboro}
	UnemphasizedSelectedTextColor              = &DynamicColor{Color: Black}
	WindowBackgroundColor                      = &DynamicColor{Color: RGB(236, 236, 236)}
	WindowFrameTextColor                       = &DynamicColor{Color: ARGB(0.847059, 0, 0, 0)}
)

System provided dynamic colors. The defaults are based upon macOS Mojave's (10.14.x) standard light theme. Each OS implementation should update them appropriately at app launch as well as whenever the system theme changes.

Functions

func DistillImageURL

func DistillImageURL(urlStr string) string

DistillImageURL distills a URL string into either a URL string that likely has an image we can use, or an empty string.

func FontFamilies

func FontFamilies() []string

FontFamilies retrieves the names of the installed font families.

func HasImageSuffix

func HasImageSuffix(p string) bool

HasImageSuffix returns true if the string has one of the image suffixes that we can process.

func HideCursorUntilMouseMoves

func HideCursorUntilMouseMoves()

HideCursorUntilMouseMoves hides the cursor until the mouse is moved.

func Initialize

func Initialize()

Initialize is not intended for client code to call.

func MarkSystemColorsForUpdate

func MarkSystemColorsForUpdate()

MarkSystemColorsForUpdate marks the system colors to be updated the next time UpdateSystemColors() is called.

func ThemeIsDark

func ThemeIsDark() bool

ThemeIsDark returns true if the current theme is a dark one.

func UpdateSystemColors

func UpdateSystemColors()

UpdateSystemColors updates the system colors, but only if a call to MarkSystemColorsForUpdate() was made since the last time this function was called.

Types

type Color

type Color uint32

Color contains the value of a color used for drawing, stored as 0xBBGGRRAA.

func ARGB

func ARGB(alpha float64, red, green, blue int) Color

ARGB creates a new Color from RGB values in the range 0-255 and an alpha value in the range 0-1.

func ARGBfloat

func ARGBfloat(alpha, red, green, blue float64) Color

ARGBfloat creates a new Color from ARGB values in the range 0-1.

func ColorDecode

func ColorDecode(buffer string) Color

ColorDecode creates a Color from a string. The string may be in any of the standard CSS formats:

- CSS predefined color name, e.g. "Yellow" - CSS rgb(), e.g. "rgb(255, 255, 0)" - CSS rgba(), e.g. "rgba(255, 255, 0, 0.3)" - CSS short hexadecimal colors, e.g. "#FF0" - CSS long hexadecimal colors, e.g. "#FFFF00" - CCS hsl(), e.g. "hsl(120, 100%, 50%)" - CSS hsla(), e.g. "hsla(120, 100%, 50%, 0.3)"

func HSB

func HSB(hue, saturation, brightness float64) Color

HSB creates a new opaque Color from HSB values in the range 0-1.

func HSBA

func HSBA(hue, saturation, brightness, alpha float64) Color

HSBA creates a new Color from HSBA values in the range 0-1.

func RGB

func RGB(red, green, blue int) Color

RGB creates a new opaque Color from RGB values in the range 0-255.

func ThemeBlack

func ThemeBlack() Color

ThemeBlack returns Black for a light theme and White for a dark theme.

func ThemeWhite

func ThemeWhite() Color

ThemeWhite returns White for a light theme and Black for a dark theme.

func (Color) AdjustBrightness

func (c Color) AdjustBrightness(amount float64) Color

AdjustBrightness creates a new color from this color with its brightness adjusted by the specified amount.

func (Color) AdjustHue

func (c Color) AdjustHue(amount float64) Color

AdjustHue creates a new color from this color with its hue adjusted by the specified amount.

func (Color) AdjustSaturation

func (c Color) AdjustSaturation(amount float64) Color

AdjustSaturation creates a new color from this color with its saturation adjusted by the specified amount.

func (Color) Alpha

func (c Color) Alpha() int

Alpha returns the alpha channel, in the range of 0-255.

func (Color) AlphaIntensity

func (c Color) AlphaIntensity() float64

AlphaIntensity returns the alpha channel, in the range of 0-1.

func (Color) Blend

func (c Color) Blend(other Color, pct float64) Color

Blend blends this color with another color. pct is the amount of the other color to use.

func (Color) Blue

func (c Color) Blue() int

Blue returns the blue channel, in the range of 0-255.

func (Color) BlueIntensity

func (c Color) BlueIntensity() float64

BlueIntensity returns the blue channel, in the range of 0-1.

func (Color) Brightness

func (c Color) Brightness() float64

Brightness of the color, a value from 0-1.

func (Color) GoString

func (c Color) GoString() string

GoString implements the fmt.GoStringer interface.

func (Color) Green

func (c Color) Green() int

Green returns the green channel, in the range of 0-255.

func (Color) GreenIntensity

func (c Color) GreenIntensity() float64

GreenIntensity returns the green channel, in the range of 0-1.

func (Color) HSB

func (c Color) HSB() (hue, saturation, brightness float64)

HSB returns the hue, saturation and brightness of the color. Values are in the range 0-1.

func (Color) HasAlpha

func (c Color) HasAlpha() bool

HasAlpha returns true if the color is not fully opaque.

func (Color) Hue

func (c Color) Hue() float64

Hue of the color, a value from 0-1.

func (Color) Invisible

func (c Color) Invisible() bool

Invisible returns true if the color is fully transparent.

func (Color) Luminance

func (c Color) Luminance() float64

Luminance returns a value from 0-1 representing the perceived brightness. Lower values represent darker colors, while higher values represent brighter colors.

func (Color) MarshalText

func (c Color) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (Color) Monochrome

func (c Color) Monochrome() bool

Monochrome returns true if each color component is the same, making it a shade of gray.

func (Color) Opaque

func (c Color) Opaque() bool

Opaque returns true if the color is fully opaque.

func (Color) Premultiply

func (c Color) Premultiply() Color

Premultiply multiplies the color channels by the alpha channel.

func (Color) RGBA

func (c Color) RGBA() (r, g, b, a uint32)

RGBA implements color.Color. Assumes the color not premultiplied and must be premultiplied to meet the contract of color.Color.

func (Color) Red

func (c Color) Red() int

Red returns the red channel, in the range of 0-255.

func (Color) RedIntensity

func (c Color) RedIntensity() float64

RedIntensity returns the red channel, in the range of 0-1.

func (Color) Saturation

func (c Color) Saturation() float64

Saturation of the color, a value from 0-1.

func (Color) SetAlpha

func (c Color) SetAlpha(alpha int) Color

SetAlpha returns a new color based on this color, but with the alpha channel replaced.

func (Color) SetAlphaIntensity

func (c Color) SetAlphaIntensity(alpha float64) Color

SetAlphaIntensity returns a new color based on this color, but with the alpha channel replaced.

func (Color) SetBlue

func (c Color) SetBlue(blue int) Color

SetBlue returns a new color based on this color, but with the blue channel replaced.

func (Color) SetBlueIntensity

func (c Color) SetBlueIntensity(blue float64) Color

SetBlueIntensity returns a new color based on this color, but with the blue channel replaced.

func (Color) SetBrightness

func (c Color) SetBrightness(brightness float64) Color

SetBrightness creates a new color from this color with the specified brightness.

func (Color) SetGreen

func (c Color) SetGreen(green int) Color

SetGreen returns a new color based on this color, but with the green channel replaced.

func (Color) SetGreenIntensity

func (c Color) SetGreenIntensity(green float64) Color

SetGreenIntensity returns a new color based on this color, but with the green channel replaced.

func (Color) SetHue

func (c Color) SetHue(hue float64) Color

SetHue creates a new color from this color with the specified hue, a value from 0-1.

func (Color) SetRed

func (c Color) SetRed(red int) Color

SetRed returns a new color based on this color, but with the red channel replaced.

func (Color) SetRedIntensity

func (c Color) SetRedIntensity(red float64) Color

SetRedIntensity returns a new color based on this color, but with the red channel replaced.

func (Color) SetSaturation

func (c Color) SetSaturation(saturation float64) Color

SetSaturation creates a new color from this color with the specified saturation.

func (Color) String

func (c Color) String() string

String implements the fmt.Stringer interface. The output can be used as a color in CSS.

func (*Color) UnmarshalText

func (c *Color) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

func (Color) Unpremultiply

func (c Color) Unpremultiply() Color

Unpremultiply divides the color channels by the alpha channel, effectively undoing a Premultiply call. Note that you will not necessarily get the original value back after calling Premultiply followed by Unpremultiply.

type Context

type Context interface {
	Pather
	// OSContext returns the underlying OS graphics context.
	OSContext() OSContext
	// Save pushes a copy of the current graphics state onto the stack for the
	// context. The current path is not saved as part of this call.
	Save()
	// Restore sets the current graphics state to the state most recently
	// saved by a call to Save().
	Restore()
	// SetOpacity sets the opacity level used when drawing. Values can range
	// from 0 (transparent) to 1 (opaque).
	SetOpacity(opacity float64)
	// SetPatternOffset sets the offset to start the ink pattern at.
	SetPatternOffset(x, y float64)
	// SetStrokeWidth sets the current stroke width.
	SetStrokeWidth(width float64)
	// SetLineCap sets the current line cap style.
	SetLineCap(lineCap linecap.LineCap)
	// SetLineJoin sets the current line join style.
	SetLineJoin(lineJoin linejoin.LineJoin)
	// SetMiterLimit sets the current miter limit for joins of connected
	// lines. Only relevant when LineJoinMiter is used.
	SetMiterLimit(limit float64)
	// SetLineDash sets the pattern for dashed lines. The phase specifies how
	// far into the dash pattern the line starts. The segments specify the
	// length of painted and unpainted segments of the dash pattern.
	SetLineDash(phase float64, segments ...float64)
	// SetInterpolationQualityHint sets the interpolation quality hint for
	// image rendering.
	SetInterpolationQualityHint(q quality.Quality)
	// Translate the coordinate system.
	Translate(x, y float64)
	// Scale the coordinate system.
	Scale(x, y float64)
	// Rotate the coordinate system.
	Rotate(angleInRadians float64)
	// Fill the current path using the non-zero winding rule, then clear the
	// current path state. https://en.wikipedia.org/wiki/Nonzero-rule
	Fill(ink Ink)
	// FillEvenOdd the current path using the even-odd rule, then clear the
	// current path state. https://en.wikipedia.org/wiki/Even-odd_rule
	FillEvenOdd(ink Ink)
	// Stroke the current path, then clear the current path state.
	Stroke(ink Ink)
	// GetClipRect returns the rectangle that encompasses the current clipping
	// path.
	GetClipRect() geom.Rect
	// Clip sets the clipping path to the intersection of the current clipping
	// path and the current path using the non-zero winding rule, then clears
	// the current path state. https://en.wikipedia.org/wiki/Nonzero-rule
	Clip()
	// ClipEvenOdd sets the clipping path to the intersection of the current
	// clipping path and the current path using the even-odd rule, then clears
	// the current path state. https://en.wikipedia.org/wiki/Even-odd_rule
	ClipEvenOdd()
	// DrawString draws a string at the specified location using the specified
	// font and ink.
	DrawString(x, y float64, font *Font, ink Ink, str string)
	// Dispose of the context, releasing any OS resources associated with it.
	Dispose()
}

Context defines the methods required of all drawing contexts.

func NewContextForOSContext

func NewContextForOSContext(gc *OSContext) Context

NewContextForOSContext creates a new graphics context for the given OS graphic context.

type Cursor

type Cursor struct {
	// contains filtered or unexported fields
}

Cursor provides a graphical cursor for the mouse location.

var (
	ArrowCursor            *Cursor
	TextCursor             *Cursor
	VerticalTextCursor     *Cursor
	CrossHairCursor        *Cursor
	ClosedHandCursor       *Cursor
	OpenHandCursor         *Cursor
	PointingHandCursor     *Cursor
	ResizeLeftCursor       *Cursor
	ResizeRightCursor      *Cursor
	ResizeLeftRightCursor  *Cursor
	ResizeUpCursor         *Cursor
	ResizeDownCursor       *Cursor
	ResizeUpDownCursor     *Cursor
	DisappearingItemCursor *Cursor
	NotAllowedCursor       *Cursor
	DragLinkCursor         *Cursor
	DragCopyCursor         *Cursor
	ContextMenuCursor      *Cursor
)

Available system cursors

func NewCursor

func NewCursor(img *Image, hotSpot geom.Point) *Cursor

NewCursor creates a new custom cursor from an image.

func (*Cursor) MakeCurrent

func (c *Cursor) MakeCurrent()

MakeCurrent makes this cursor the current cursor.

type DynamicColor

type DynamicColor struct {
	Color Color
}

DynamicColor holds a color that may be changed.

type Font

type Font struct {
	// contains filtered or unexported fields
}

Font holds an instance of a platform font.

var (
	// UserFont is the font used by default for documents and other text under
	// the user’s control (that is, text whose font the user can normally
	// change).
	UserFont *Font
	// UserMonospacedFont is the font used by default for documents and other
	// text under the user’s control when that font is fixed-pitch.
	UserMonospacedFont *Font
	// SystemFont is the system font used for standard user-interface items
	// such as window titles, button labels, etc.
	SystemFont *Font
	// EmphasizedSystemFont is the system font used for emphasis in alerts.
	EmphasizedSystemFont *Font
	// SmallSystemFont is the standard small system font used for informative
	// text in alerts, column headings in lists, help tags, utility window
	// titles, toolbar item labels, tool palettes, tool tips, and small
	// controls.
	SmallSystemFont *Font
	// SmallEmphasizedSystemFont is the small system font used for emphasis.
	SmallEmphasizedSystemFont *Font
	// ViewsFont is the font used as the default font of text in lists and
	// tables.
	ViewsFont *Font
	// LabelFont is the font used for labels.
	LabelFont *Font
	// MenuFont is the font used for menus.
	MenuFont *Font
	// MenuCmdKeyFont is the font used for menu item command key equivalents.
	MenuCmdKeyFont *Font
)

func NewFont

func NewFont(desc FontDescriptor) *Font

NewFont creates a new font from the supplied FontDescriptor.

func NewFontFromData

func NewFontFromData(data []byte) (*Font, error)

NewFontFromData creates a new font from the supplied data, typically the contents of a font file.

func (*Font) Ascent

func (f *Font) Ascent() float64

Ascent returns the distance from the baseline to the top of a typical capital letter.

func (*Font) Descent

func (f *Font) Descent() float64

Descent returns the distance from the baseline to the bottom of the typical letter that has a descender, such as a lower case 'g'.

func (*Font) Descriptor

func (f *Font) Descriptor() FontDescriptor

Descriptor returns the FontDescriptor for this font.

func (*Font) Dispose

func (f *Font) Dispose()

Dispose of the font, releasing any OS resources associated with it.

func (*Font) Extents

func (f *Font) Extents(str string) geom.Size

Extents of the string rendered with this font. Note that this does not account for any embedded line endings nor tabs.

func (*Font) Height

func (f *Font) Height() float64

Height returns the height of the font, typically Ascent() + Descent().

func (*Font) IndexForPosition

func (f *Font) IndexForPosition(x float64, str string) int

IndexForPosition returns the rune index within the string for the specified x-coordinate, where 0 is the start of the string. Note that this does not account for any embedded line endings nor tabs.

func (*Font) Leading

func (f *Font) Leading() float64

Leading returns the recommended distance between the bottom of the descender line to the top of the next line.

func (*Font) Monospaced

func (f *Font) Monospaced() bool

Monospaced returns true if the font characters have a fixed width.

func (*Font) PositionForIndex

func (f *Font) PositionForIndex(index int, str string) float64

PositionForIndex returns the x-coordinate where the specified rune index starts. The returned coordinate assumes 0 is the start of the string. Note that this does not account for any embedded line endings nor tabs.

func (*Font) String

func (f *Font) String() string

String implements fmt.Stringer.

func (*Font) Width

func (f *Font) Width(str string) float64

Width of the string rendered with this font. Note that this does not account for any embedded line endings nor tabs.

type FontDescriptor

type FontDescriptor struct {
	Family string  // Family name of the Font, such as "Times New Roman".
	Size   float64 // Size of the font, in points (1/72 of an inch).
	Bold   bool
	Italic bool
}

FontDescriptor holds information necessary to construct a Font.

func (*FontDescriptor) String

func (d *FontDescriptor) String() string

String implements the fmt.Stringer interface.

type Gradient

type Gradient struct {
	Start       geom.Point
	StartRadius float64
	End         geom.Point
	EndRadius   float64
	Stops       []Stop
}

Gradient defines a smooth transition between colors across an area. Start and End should hold values from 0 to 1. These will be be used to set a relative starting and ending position for the gradient. If StartRadius and EndRadius are both greater than 0, then the gradient will be a radial one instead of a linear one.

func NewEvenlySpacedGradient

func NewEvenlySpacedGradient(start, end geom.Point, startRadius, endRadius float64, colors ...*DynamicColor) *Gradient

NewEvenlySpacedGradient creates a new gradient with the specified colors evenly spread across the whole range. start and end should hold values from 0 to 1, representing the percentage position within the area that will be filled.

func NewHorizontalEvenlySpacedGradient

func NewHorizontalEvenlySpacedGradient(colors ...*DynamicColor) *Gradient

NewHorizontalEvenlySpacedGradient creates a new gradient with the specified colors evenly spread across the whole range.

func NewVerticalEvenlySpacedGradient

func NewVerticalEvenlySpacedGradient(colors ...*DynamicColor) *Gradient

NewVerticalEvenlySpacedGradient creates a new gradient with the specified colors evenly spread across the whole range.

func (*Gradient) Reversed

func (g *Gradient) Reversed() *Gradient

Reversed creates a copy of the current Gradient and inverts the locations of each color stop in that copy.

type Image

type Image softref.SoftRef

Image holds a reference to an image.

func NewImageFromBytes

func NewImageFromBytes(buffer []byte, scale float64) (*Image, error)

NewImageFromBytes creates a new image from raw bytes.

func NewImageFromData

func NewImageFromData(data *ImageData) (*Image, error)

NewImageFromData creates a new image from the ImageData.

func NewImageFromURL

func NewImageFromURL(urlStr string, scale float64) (*Image, error)

NewImageFromURL creates a new image from data retrieved from the URL. The http.DefaultClient will be used if the data URL is remote.

func (*Image) Data

func (r *Image) Data() *ImageData

Data extracts the raw pixel data.

func (*Image) Draw

func (r *Image) Draw(gc Context, where geom.Point)

Draw the image at the specified location using its logical size.

func (*Image) DrawInRect

func (r *Image) DrawInRect(gc Context, rect geom.Rect)

DrawInRect draws the image into the area specified by the rect, scaling if necessary.

func (*Image) IsValid

func (r *Image) IsValid() bool

IsValid returns true if the image is still valid (i.e. hasn't been disposed).

func (*Image) LogicalGeomSize

func (r *Image) LogicalGeomSize() geom.Size

LogicalGeomSize returns the logical (device-independent) size.

func (*Image) LogicalHeight

func (r *Image) LogicalHeight() int

LogicalHeight returns the logical (device-independent) height.

func (*Image) LogicalSize

func (r *Image) LogicalSize() (width, height int)

LogicalSize returns the logical (device-independent) size.

func (*Image) LogicalWidth

func (r *Image) LogicalWidth() int

LogicalWidth returns the logical (device-independent) width.

func (*Image) NewScaledImage

func (r *Image) NewScaledImage(width, height int, q quality.Quality) (*Image, error)

NewScaledImage creates a new image by scaling this image.

func (*Image) NewSubImage

func (r *Image) NewSubImage(x, y, width, height int) (*Image, error)

NewSubImage creates a new image from a portion of this image.

func (*Image) PixelSize

func (r *Image) PixelSize() (width, height int)

PixelSize returns the pixel size of the image, i.e. the actual size of the image determined by the raw pixels.

type ImageData

type ImageData struct {
	Pixels []Color // The pixel data
	Width  int     // The width of the image, in pixels
	Height int     // The height of the image, in pixels
	Scale  float64 // The scale to apply to the image size to obtain the device-independent dimensions
}

ImageData is the raw information that makes up an Image.

func (*ImageData) At

func (imgData *ImageData) At(x, y int) color.Color

At implements image.Image.

func (*ImageData) Bounds

func (imgData *ImageData) Bounds() image.Rectangle

Bounds implements image.Image.

func (*ImageData) ColorModel

func (imgData *ImageData) ColorModel() color.Model

ColorModel implements image.Image.

func (*ImageData) LogicalHeight

func (imgData *ImageData) LogicalHeight() int

LogicalHeight returns the logical (device-independent) height.

func (*ImageData) LogicalSize

func (imgData *ImageData) LogicalSize() (width, height int)

LogicalSize returns the logical (device-independent) size.

func (*ImageData) LogicalWidth

func (imgData *ImageData) LogicalWidth() int

LogicalWidth returns the logical (device-independent) width.

func (*ImageData) MarshalJSON

func (imgData *ImageData) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*ImageData) UnmarshalJSON

func (imgData *ImageData) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (*ImageData) Validate

func (imgData *ImageData) Validate() error

Validate checks the ImageData and reports any errors found.

type Ink

type Ink interface {
	// contains filtered or unexported methods
}

Ink holds a color/pattern/gradient to draw with.

var (
	ControlBackgroundInk         Ink = controlBackgroundGradient
	ControlSelectedBackgroundInk Ink = controlSelectedBackgroundGradient
	ControlFocusedBackgroundInk  Ink = controlFocusedBackgroundGradient
	ControlPressedBackgroundInk  Ink = controlPressedBackgroundGradient
)

System provided dynamic inks.

type OSContext

type OSContext = int // RAW: Implement

OSContext is the platform-specific drawing context on Windows.

type Path

type Path struct {
	// contains filtered or unexported fields
}

Path is a description of a series of shapes or lines.

func (*Path) Append

func (p *Path) Append(other *Path)

Append the other path to the end of this path.

func (*Path) BeginPath

func (p *Path) BeginPath()

BeginPath discards any existing path data and starts a fresh path.

func (*Path) Bounds

func (p *Path) Bounds() geom.Rect

Bounds returns the bounding rectangle for this path.

func (*Path) Clone

func (p *Path) Clone() *Path

Clone creates an exact copy of this path.

func (*Path) ClosePath

func (p *Path) ClosePath()

ClosePath closes and terminates the current sub-path.

func (*Path) CubicCurveTo

func (p *Path) CubicCurveTo(cp1x, cp1y, cp2x, cp2y, x, y float64)

CubicCurveTo appends a cubic Bezier curve from the current point, using the provided controls points and end point.

func (*Path) Ellipse

func (p *Path) Ellipse(rect geom.Rect)

Ellipse adds an ellipse to the path. The ellipse is a complete sub-path, i.e. it starts with a MoveTo and ends with a ClosePath operation.

func (*Path) LineTo

func (p *Path) LineTo(x, y float64)

LineTo appends a straight line segment from the current point to the specified point.

func (*Path) MoveTo

func (p *Path) MoveTo(x, y float64)

MoveTo begins a new sub-path at the specified point.

func (*Path) Polygon

func (p *Path) Polygon(polygon poly.Polygon)

Polygon add a polygon to the path. The ellipse is a complete sub-path, i.e. it starts with a MoveTo and ends with a ClosePath operation.

func (*Path) QuadCurveTo

func (p *Path) QuadCurveTo(cpx, cpy, x, y float64)

QuadCurveTo appends a quadratic Bezier curve from the current point, using a control point and an end point.

func (*Path) Rect

func (p *Path) Rect(rect geom.Rect)

Rect adds a rectangle to the path. The rectangle is a complete sub-path, i.e. it starts with a MoveTo and ends with a ClosePath operation.

func (*Path) RoundedRect

func (p *Path) RoundedRect(rect geom.Rect, cornerRadius float64)

RoundedRect adds a rounded rectangle to the path. The rectangle is a complete sub-path, i.e. it starts with a MoveTo and ends with a ClosePath operation.

func (*Path) SendPath

func (p *Path) SendPath(pather Pather)

SendPath sends the contents of the path into the target Pather.

type PathSender

type PathSender interface {
	SendPath(pathBuilder Pather)
}

PathSender sends the contents of a path into the target Pather.

type Pather

type Pather interface {
	// BeginPath discards any existing path data and starts a fresh path.
	BeginPath()
	// MoveTo begins a new sub-path at the specified point.
	MoveTo(x, y float64)
	// LineTo appends a straight line segment from the current point to the
	// specified point.
	LineTo(x, y float64)
	// QuadCurveTo appends a quadratic Bezier curve from the current point,
	// using a control point and an end point.
	QuadCurveTo(cpx, cpy, x, y float64)
	// CubicCurveTo appends a cubic Bezier curve from the current point, using
	// the provided controls points and end point.
	CubicCurveTo(cp1x, cp1y, cp2x, cp2y, x, y float64)
	// Rect adds a rectangle to the path. The rectangle is a complete
	// sub-path, i.e. it starts with a MoveTo and ends with a ClosePath
	// operation.
	Rect(rect geom.Rect)
	// RoundedRect adds a rounded rectangle to the path. The rectangle is a
	// complete sub-path, i.e. it starts with a MoveTo and ends with a
	// ClosePath operation.
	RoundedRect(rect geom.Rect, cornerRadius float64)
	// Ellipse adds an ellipse to the path. The ellipse is a complete
	// sub-path, i.e. it starts with a MoveTo and ends with a ClosePath
	// operation.
	Ellipse(rect geom.Rect)
	// Polygon add a polygon to the path. The ellipse is a complete sub-path,
	// i.e. it starts with a MoveTo and ends with a ClosePath operation.
	Polygon(polygon poly.Polygon)
	// ClosePath closes and terminates the current sub-path.
	ClosePath()
}

Pather defines the methods necessary for describing of a series of shapes or lines.

type Pattern

type Pattern softref.SoftRef

Pattern holds a pattern for drawing.

func NewPattern

func NewPattern(img *Image) *Pattern

NewPattern creates a new pattern from an image.

func (*Pattern) Image

func (p *Pattern) Image() *Image

Image returns the underlying image.

func (*Pattern) IsValid

func (p *Pattern) IsValid() bool

IsValid returns true if the pattern is still valid (i.e. hasn't been disposed).

type Stop

type Stop struct {
	Color    *DynamicColor
	Location float64
}

Stop provides information about the color and position of one 'color stop' in a gradient.

func (Stop) String

func (s Stop) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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