Documentation ¶
Index ¶
- Constants
- Variables
- func DistillImageURL(urlStr string) string
- func FontFamilies() []string
- func HasImageSuffix(p string) bool
- func HideCursorUntilMouseMoves()
- func Initialize()
- func MarkSystemColorsForUpdate()
- func ThemeIsDark() bool
- func UpdateSystemColors()
- type Color
- func ARGB(alpha float64, red, green, blue int) Color
- func ARGBfloat(alpha, red, green, blue float64) Color
- func ColorDecode(buffer string) Color
- func HSB(hue, saturation, brightness float64) Color
- func HSBA(hue, saturation, brightness, alpha float64) Color
- func RGB(red, green, blue int) Color
- func ThemeBlack() Color
- func ThemeWhite() Color
- func (c Color) AdjustBrightness(amount float64) Color
- func (c Color) AdjustHue(amount float64) Color
- func (c Color) AdjustSaturation(amount float64) Color
- func (c Color) Alpha() int
- func (c Color) AlphaIntensity() float64
- func (c Color) Blend(other Color, pct float64) Color
- func (c Color) Blue() int
- func (c Color) BlueIntensity() float64
- func (c Color) Brightness() float64
- func (c Color) GoString() string
- func (c Color) Green() int
- func (c Color) GreenIntensity() float64
- func (c Color) HSB() (hue, saturation, brightness float64)
- func (c Color) HasAlpha() bool
- func (c Color) Hue() float64
- func (c Color) Invisible() bool
- func (c Color) Luminance() float64
- func (c Color) MarshalText() ([]byte, error)
- func (c Color) Monochrome() bool
- func (c Color) Opaque() bool
- func (c Color) Premultiply() Color
- func (c Color) RGBA() (r, g, b, a uint32)
- func (c Color) Red() int
- func (c Color) RedIntensity() float64
- func (c Color) Saturation() float64
- func (c Color) SetAlpha(alpha int) Color
- func (c Color) SetAlphaIntensity(alpha float64) Color
- func (c Color) SetBlue(blue int) Color
- func (c Color) SetBlueIntensity(blue float64) Color
- func (c Color) SetBrightness(brightness float64) Color
- func (c Color) SetGreen(green int) Color
- func (c Color) SetGreenIntensity(green float64) Color
- func (c Color) SetHue(hue float64) Color
- func (c Color) SetRed(red int) Color
- func (c Color) SetRedIntensity(red float64) Color
- func (c Color) SetSaturation(saturation float64) Color
- func (c Color) String() string
- func (c *Color) UnmarshalText(text []byte) error
- func (c Color) Unpremultiply() Color
- type Context
- type Cursor
- type DynamicColor
- type Font
- func (f *Font) Ascent() float64
- func (f *Font) Descent() float64
- func (f *Font) Descriptor() FontDescriptor
- func (f *Font) Dispose()
- func (f *Font) Extents(str string) geom.Size
- func (f *Font) Height() float64
- func (f *Font) IndexForPosition(x float64, str string) int
- func (f *Font) Leading() float64
- func (f *Font) Monospaced() bool
- func (f *Font) PositionForIndex(index int, str string) float64
- func (f *Font) String() string
- func (f *Font) Width(str string) float64
- type FontDescriptor
- type Gradient
- type Image
- func (r *Image) Data() *ImageData
- func (r *Image) Draw(gc Context, where geom.Point)
- func (r *Image) DrawInRect(gc Context, rect geom.Rect)
- func (r *Image) IsValid() bool
- func (r *Image) LogicalGeomSize() geom.Size
- func (r *Image) LogicalHeight() int
- func (r *Image) LogicalSize() (width, height int)
- func (r *Image) LogicalWidth() int
- func (r *Image) NewScaledImage(width, height int, q quality.Quality) (*Image, error)
- func (r *Image) NewSubImage(x, y, width, height int) (*Image, error)
- func (r *Image) PixelSize() (width, height int)
- type ImageData
- func (imgData *ImageData) At(x, y int) color.Color
- func (imgData *ImageData) Bounds() image.Rectangle
- func (imgData *ImageData) ColorModel() color.Model
- func (imgData *ImageData) LogicalHeight() int
- func (imgData *ImageData) LogicalSize() (width, height int)
- func (imgData *ImageData) LogicalWidth() int
- func (imgData *ImageData) MarshalJSON() ([]byte, error)
- func (imgData *ImageData) UnmarshalJSON(data []byte) error
- func (imgData *ImageData) Validate() error
- type Ink
- type OSContext
- type Path
- func (p *Path) Append(other *Path)
- func (p *Path) BeginPath()
- func (p *Path) Bounds() geom.Rect
- func (p *Path) Clone() *Path
- func (p *Path) ClosePath()
- func (p *Path) CubicCurveTo(cp1x, cp1y, cp2x, cp2y, x, y float64)
- func (p *Path) Ellipse(rect geom.Rect)
- func (p *Path) LineTo(x, y float64)
- func (p *Path) MoveTo(x, y float64)
- func (p *Path) Polygon(polygon poly.Polygon)
- func (p *Path) QuadCurveTo(cpx, cpy, x, y float64)
- func (p *Path) Rect(rect geom.Rect)
- func (p *Path) RoundedRect(rect geom.Rect, cornerRadius float64)
- func (p *Path) SendPath(pather Pather)
- type PathSender
- type Pather
- type Pattern
- type Stop
Constants ¶
const ( PNGExt = ".png" JPGExt = ".jpg" JPEGExt = ".jpeg" GIFExt = ".gif" )
Image file extensions.
Variables ¶
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) 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.
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 ¶
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 ¶
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 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 ¶
ARGB creates a new Color from RGB values in the range 0-255 and an alpha value in the range 0-1.
func ColorDecode ¶
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 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 ¶
AdjustBrightness creates a new color from this color with its brightness adjusted by the specified amount.
func (Color) AdjustHue ¶
AdjustHue creates a new color from this color with its hue adjusted by the specified amount.
func (Color) AdjustSaturation ¶
AdjustSaturation creates a new color from this color with its saturation adjusted by the specified amount.
func (Color) AlphaIntensity ¶
AlphaIntensity returns the alpha channel, in the range of 0-1.
func (Color) Blend ¶
Blend blends this color with another color. pct is the amount of the other color to use.
func (Color) BlueIntensity ¶
BlueIntensity returns the blue channel, in the range of 0-1.
func (Color) Brightness ¶
Brightness of the color, a value from 0-1.
func (Color) GreenIntensity ¶
GreenIntensity returns the green channel, in the range of 0-1.
func (Color) HSB ¶
HSB returns the hue, saturation and brightness of the color. Values are in the range 0-1.
func (Color) Luminance ¶
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 ¶
MarshalText implements encoding.TextMarshaler.
func (Color) Monochrome ¶
Monochrome returns true if each color component is the same, making it a shade of gray.
func (Color) Premultiply ¶
Premultiply multiplies the color channels by the alpha channel.
func (Color) RGBA ¶
RGBA implements color.Color. Assumes the color not premultiplied and must be premultiplied to meet the contract of color.Color.
func (Color) RedIntensity ¶
RedIntensity returns the red channel, in the range of 0-1.
func (Color) Saturation ¶
Saturation of the color, a value from 0-1.
func (Color) SetAlpha ¶
SetAlpha returns a new color based on this color, but with the alpha channel replaced.
func (Color) SetAlphaIntensity ¶
SetAlphaIntensity returns a new color based on this color, but with the alpha channel replaced.
func (Color) SetBlue ¶
SetBlue returns a new color based on this color, but with the blue channel replaced.
func (Color) SetBlueIntensity ¶
SetBlueIntensity returns a new color based on this color, but with the blue channel replaced.
func (Color) SetBrightness ¶
SetBrightness creates a new color from this color with the specified brightness.
func (Color) SetGreen ¶
SetGreen returns a new color based on this color, but with the green channel replaced.
func (Color) SetGreenIntensity ¶
SetGreenIntensity returns a new color based on this color, but with the green channel replaced.
func (Color) SetHue ¶
SetHue creates a new color from this color with the specified hue, a value from 0-1.
func (Color) SetRed ¶
SetRed returns a new color based on this color, but with the red channel replaced.
func (Color) SetRedIntensity ¶
SetRedIntensity returns a new color based on this color, but with the red channel replaced.
func (Color) SetSaturation ¶
SetSaturation creates a new color from this color with the specified saturation.
func (Color) String ¶
String implements the fmt.Stringer interface. The output can be used as a color in CSS.
func (*Color) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
func (Color) Unpremultiply ¶
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 ¶
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 (*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 ¶
NewFontFromData creates a new font from the supplied data, typically the contents of a font file.
func (*Font) Ascent ¶
Ascent returns the distance from the baseline to the top of a typical capital letter.
func (*Font) Descent ¶
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 ¶
Extents of the string rendered with this font. Note that this does not account for any embedded line endings nor tabs.
func (*Font) IndexForPosition ¶
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 ¶
Leading returns the recommended distance between the bottom of the descender line to the top of the next line.
func (*Font) Monospaced ¶
Monospaced returns true if the font characters have a fixed width.
func (*Font) PositionForIndex ¶
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.
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.
type Image ¶
Image holds a reference to an image.
func NewImageFromBytes ¶
NewImageFromBytes creates a new image from raw bytes.
func NewImageFromData ¶
NewImageFromData creates a new image from the ImageData.
func NewImageFromURL ¶
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) DrawInRect ¶
DrawInRect draws the image into the area specified by the rect, scaling if necessary.
func (*Image) IsValid ¶
IsValid returns true if the image is still valid (i.e. hasn't been disposed).
func (*Image) LogicalGeomSize ¶
LogicalGeomSize returns the logical (device-independent) size.
func (*Image) LogicalHeight ¶
LogicalHeight returns the logical (device-independent) height.
func (*Image) LogicalSize ¶
LogicalSize returns the logical (device-independent) size.
func (*Image) LogicalWidth ¶
LogicalWidth returns the logical (device-independent) width.
func (*Image) NewScaledImage ¶
NewScaledImage creates a new image by scaling this image.
func (*Image) NewSubImage ¶
NewSubImage creates a new image from a portion of this image.
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) ColorModel ¶
ColorModel implements image.Image.
func (*ImageData) LogicalHeight ¶
LogicalHeight returns the logical (device-independent) height.
func (*ImageData) LogicalSize ¶
LogicalSize returns the logical (device-independent) size.
func (*ImageData) LogicalWidth ¶
LogicalWidth returns the logical (device-independent) width.
func (*ImageData) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (*ImageData) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
type Ink ¶
type Ink interface {
// contains filtered or unexported methods
}
Ink holds a color/pattern/gradient to draw with.
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) BeginPath ¶
func (p *Path) BeginPath()
BeginPath discards any existing path data and starts a fresh path.
func (*Path) ClosePath ¶
func (p *Path) ClosePath()
ClosePath closes and terminates the current sub-path.
func (*Path) CubicCurveTo ¶
CubicCurveTo appends a cubic Bezier curve from the current point, using the provided controls points and end point.
func (*Path) Ellipse ¶
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 ¶
LineTo appends a straight line segment from the current point to the specified point.
func (*Path) 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 ¶
QuadCurveTo appends a quadratic Bezier curve from the current point, using a control point and an end point.
func (*Path) 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 ¶
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.
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 ¶
Pattern holds a pattern for drawing.
func NewPattern ¶
NewPattern creates a new pattern from an image.