Documentation
¶
Index ¶
- Variables
- func ARGB(colorStr string) string
- func Abs(value string) string
- func Acos(value string) string
- func Alpha(colorStr string) string
- func Asin(value string) string
- func Atan(value string) string
- func Average(color1Str, color2Str string) string
- func Blue(colorStr string) string
- func Boolean(value string) string
- func Ceil(value string) string
- func ClearImageDimCache()
- func ColorFunction(colorStr string) string
- func Contrast(colorStr string, args ...string) string
- func Convert(value string, targetUnit string) string
- func Cos(value string) string
- func Darken(colorStr, amount string) string
- func Desaturate(colorStr, amount string) string
- func Difference(color1Str, color2Str string) string
- func E(str string) string
- func Escape(str string) string
- func EvaluateExpression(expr string) string
- func Exclusion(color1Str, color2Str string) string
- func Extract(args ...string) string
- func Fade(colorStr, amount string) string
- func Fadein(colorStr, amount string) string
- func Fadeout(colorStr, amount string) string
- func Floor(value string) string
- func Format(format string, args ...string) string
- func GetUnit(value string) string
- func Green(colorStr string) string
- func Greyscale(colorStr string) string
- func HSL(h, s, l string) string
- func HSLA(h, s, l, a string) string
- func HSV(h, s, v string) string
- func HSVA(h, s, v, a string) string
- func HSVHue(colorStr string) string
- func HSVSaturation(colorStr string) string
- func HSVValue(colorStr string) string
- func Hardlight(color1Str, color2Str string) string
- func Hue(colorStr string) string
- func If(condition string, valueIfTrue string, valueIfFalse string) string
- func ImageHeight(filePath string) (string, error)
- func ImageSize(filePath string) (string, error)
- func ImageWidth(filePath string) (string, error)
- func IsColor(value string) bool
- func IsColorFunction(value string) string
- func IsDefined(varName string) bool
- func IsEm(value string) bool
- func IsEmFunction(value string) string
- func IsKeyword(value string) bool
- func IsKeywordFunction(value string) string
- func IsList(value string) bool
- func IsListFunction(value string) string
- func IsNumber(value string) bool
- func IsNumberFunction(value string) string
- func IsPercentage(value string) bool
- func IsPercentageFunction(value string) string
- func IsPixel(value string) bool
- func IsPixelFunction(value string) string
- func IsRuleset(value string) bool
- func IsRulesetFunction(value string) string
- func IsString(value string) bool
- func IsStringFunction(value string) string
- func IsURL(value string) bool
- func IsURLFunction(value string) string
- func IsUnit(value string, unit string) bool
- func IsUnitFunction(value string, unit string) string
- func Length(values ...string) string
- func Lighten(colorStr, amount string) string
- func Lightness(colorStr string) string
- func LumaFunction(colorStr string) string
- func Luminance(colorStr string) string
- func Max(values ...string) string
- func Min(values ...string) string
- func Mix(color1Str, color2Str string, args ...string) string
- func Mod(a, b string) string
- func Multiply(color1Str, color2Str string) string
- func Negation(color1Str, color2Str string) string
- func Overlay(color1Str, color2Str string) string
- func Percentage(value string) string
- func Pi() string
- func Pow(base, exponent string) string
- func RGB(r, g, b string) string
- func Range(args ...string) string
- func Red(colorStr string) string
- func Replace(str, pattern, replacement string, flags ...string) string
- func Round(value string) string
- func Saturate(colorStr, amount string) string
- func Saturation(colorStr string) string
- func Screen(color1Str, color2Str string) string
- func Shade(colorStr, weight string) string
- func Sin(value string) string
- func Softlight(color1Str, color2Str string) string
- func Spin(colorStr, degrees string) string
- func Sqrt(value string) string
- func Tan(value string) string
- func Tint(colorStr, weight string) string
- func Unit(args ...string) string
- type Color
- func (c *Color) Darken(amount float64) *Color
- func (c *Color) Desaturate(amount float64) *Color
- func (c *Color) Greyscale() *Color
- func (c *Color) Lighten(amount float64) *Color
- func (c *Color) Luma() float64
- func (c *Color) Mix(other *Color, weight float64) *Color
- func (c *Color) Saturate(amount float64) *Color
- func (c *Color) Spin(degrees float64) *Color
- func (c *Color) ToHSL() (h, s, l float64)
- func (c *Color) ToHSV() (h, s, v float64)
- func (c *Color) ToHex() string
- func (c *Color) ToRGB() string
Constants ¶
This section is empty.
Variables ¶
var ( // BaseDir is set by the renderer to enable resolving relative image paths BaseDir string )
Functions ¶
func Boolean ¶
Boolean converts a value to a boolean In LESS, only the literal keyword "true" returns true; everything else is false
func ClearImageDimCache ¶
func ClearImageDimCache()
ClearImageDimCache clears the image dimension cache (useful for testing)
func ColorFunction ¶
ColorFunction parses a string as a color
func Convert ¶
Convert converts a number to a different unit Supports: px, cm, mm, in, pt, pc, em, ex, ch, rem, vw, vh, vmin, vmax, %
func Difference ¶
Difference blends two colors using difference mode
func Escape ¶
Escape URL-encodes a string (using strict LESS escaping rules) LESS escape() does NOT escape all special characters - only specific ones
func EvaluateExpression ¶
EvaluateExpression evaluates a mathematical expression with units e.g., "10px * 2" -> "20px", "20px - 5px" -> "15px"
func Extract ¶
Extract gets an item from a list by index (1-based) Can be called as extract(list, index) or extract(item1, item2, item3, index)
func HSL ¶
HSL creates a color from HSL components (hue 0-360, saturation 0-100, lightness 0-100) Returns in hsl() format, not hex
func HSLA ¶
HSLA creates a color from HSLA components (hue 0-360, saturation 0-100, lightness 0-100, alpha 0-1) Returns in hsla() format
func HSVSaturation ¶
HSVSaturation extracts the saturation from a color (HSV saturation)
func ImageHeight ¶
ImageHeight returns the height of an image file in pixels
func ImageWidth ¶
ImageWidth returns the width of an image file in pixels
func IsColorFunction ¶
IsColorFunction is the exposed function for iscolor()
func IsDefined ¶
IsDefined checks if a variable is defined (this requires context) For now, return false as this needs renderer context
func IsEmFunction ¶
IsEmFunction is the exposed function for isem()
func IsKeyword ¶
IsKeyword checks if a value is a keyword In LESS, any bare word/identifier (not a number, color, or string) is a keyword
func IsKeywordFunction ¶
IsKeywordFunction is the exposed function for iskeyword()
func IsListFunction ¶
IsListFunction is the exposed function for islist()
func IsNumberFunction ¶
IsNumberFunction is the exposed function for isnumber()
func IsPercentage ¶
IsPercentage checks if a value is a percentage
func IsPercentageFunction ¶
IsPercentageFunction is the exposed function for ispercentage()
func IsPixelFunction ¶
IsPixelFunction is the exposed function for ispixel()
func IsRuleset ¶
IsRuleset checks if a value is a ruleset/object (stored in a variable) This would need context from the renderer to properly determine
func IsRulesetFunction ¶
IsRulesetFunction is the exposed function for isruleset()
func IsStringFunction ¶
IsStringFunction is the exposed function for isstring()
func IsURLFunction ¶
IsURLFunction is the exposed function for isurl()
func IsUnitFunction ¶
IsUnitFunction is the exposed function for isunit()
func Length ¶
Length returns the length of a list/string value In LESS, quoted strings count as a single item (length 1), not character count Can be called as length(value) or length(item1, item2, item3) where items form a list
func LumaFunction ¶
LumaFunction returns the perceived brightness (luminance) of a color as a string
func Percentage ¶
Percentage converts a decimal number to a percentage
func Range ¶
Range generates a comma-separated list of numbers from start to end Supports: range(end), range(start, end), range(start, end, step)
func Replace ¶
Replace replaces a pattern in a string with a replacement string replace(string, pattern, replacement, flags?)
func Saturation ¶
Saturation extracts the saturation component (0-100) from a color
Types ¶
type Color ¶
type Color struct {
R, G, B, A float64 // values 0-255 for RGB, 0-1 for A
}
Color represents an RGBA color
func HSLToColor ¶
HSLToColor converts HSL to RGB Color
func HSVToColor ¶
HSVToColor converts HSV to RGB Color
func ParseColor ¶
ParseColor parses a color from a hex string, rgb(a) function, hsl(a) function, or CSS keyword
func (*Color) Desaturate ¶
Desaturate decreases saturation
func (*Color) Luma ¶
Luma returns the perceived brightness (luminance) of the color as a percentage Uses the formula: luma = 0.2126*R + 0.7152*G + 0.0722*B (relative luminance)