Documentation
¶
Overview ¶
Example (No_change) ¶
package main
import (
"fmt"
"github.com/stilvoid/shue"
)
func exec(input string, format string, lighten int, invert bool) {
c, _ := shue.Parse(input)
c.Lighten(lighten)
if invert {
c.Invert()
}
out, _ := shue.Format(format, c)
fmt.Println(out)
}
func main() {
exec("123", "hex3", 100, false)
exec("1234", "hex4", 100, false)
exec("123456", "hex6", 100, false)
exec("12345678", "hex8", 100, false)
exec("rgb(32,64,128)", "rgb", 100, false)
exec("rgba(32,64,128,0.125)", "rgba", 100, false)
exec("hsl(120,50%,66%)", "hsl", 100, false)
exec("hsla(120,50%,66%,0.1)", "hsla", 100, false)
}
Output: #123 #1234 #123456 #12345678 rgb(32, 64, 128) rgba(32, 64, 128, 0.125) hsl(120, 50%, 66%) hsla(120, 50%, 66%, 0.1)
Index ¶
- Variables
- func Format(format string, colour Colour) (string, error)
- type Colour
- func (c *Colour) Equal(other Colour) bool
- func (c *Colour) HSL() (float64, float64, float64)
- func (c *Colour) HSLA() (float64, float64, float64, float64)
- func (c *Colour) Invert()
- func (c *Colour) Lighten(value int)
- func (c *Colour) RGB() (float64, float64, float64)
- func (c *Colour) RGBA() (float64, float64, float64, float64)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Formats []string
Functions ¶
Types ¶
type Colour ¶
type Colour struct {
R, G, B, A float64
}
func (*Colour) Invert ¶
func (c *Colour) Invert()
Example ¶
package main
import (
"fmt"
"github.com/stilvoid/shue"
)
func exec(input string, format string, lighten int, invert bool) {
c, _ := shue.Parse(input)
c.Lighten(lighten)
if invert {
c.Invert()
}
out, _ := shue.Format(format, c)
fmt.Println(out)
}
func main() {
exec("fff", "hex6", 100, true)
exec("000", "hex6", 100, true)
exec("0180f0", "hex6", 100, true)
}
Output: #000000 #ffffff #fe7f0f
func (*Colour) Lighten ¶
Example (And_invert) ¶
package main
import (
"fmt"
"github.com/stilvoid/shue"
)
func exec(input string, format string, lighten int, invert bool) {
c, _ := shue.Parse(input)
c.Lighten(lighten)
if invert {
c.Invert()
}
out, _ := shue.Format(format, c)
fmt.Println(out)
}
func main() {
exec("888", "hex6", 150, true)
exec("444", "hex6", 200, true)
exec("fff", "hex6", 20, true)
}
Output: #333333 #777777 #cccccc
Example (Darker) ¶
package main
import (
"fmt"
"github.com/stilvoid/shue"
)
func exec(input string, format string, lighten int, invert bool) {
c, _ := shue.Parse(input)
c.Lighten(lighten)
if invert {
c.Invert()
}
out, _ := shue.Format(format, c)
fmt.Println(out)
}
func main() {
exec("000", "hex6", 50, false)
exec("fff", "hex6", 50, false)
exec("808080", "hex6", 50, false)
exec("ff8060", "hex6", 50, false)
}
Output: #000000 #808080 #404040 #b02300
Example (Lighter) ¶
package main
import (
"fmt"
"github.com/stilvoid/shue"
)
func exec(input string, format string, lighten int, invert bool) {
c, _ := shue.Parse(input)
c.Lighten(lighten)
if invert {
c.Invert()
}
out, _ := shue.Format(format, c)
fmt.Println(out)
}
func main() {
exec("000", "hex6", 150, false)
exec("fff", "hex6", 150, false)
exec("808080", "hex6", 150, false)
exec("804020", "hex6", 150, false)
}
Output: #000000 #ffffff #c0c0c0 #c06030
Click to show internal directories.
Click to hide internal directories.