-
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathexample_test.go
More file actions
36 lines (29 loc) · 585 Bytes
/
example_test.go
File metadata and controls
36 lines (29 loc) · 585 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package colorgrad_test
import (
"fmt"
"github.com/mazznoer/colorgrad"
)
func Example_presetGradient() {
grad := colorgrad.Rainbow()
dmin, dmax := grad.Domain()
fmt.Println(dmin, dmax)
fmt.Println(grad.At(0).HexString())
// Output:
// 0 1
// #6e40aa
}
func Example_customGradient() {
grad, err := colorgrad.NewGradient().
HtmlColors("red", "#FFD700", "lime").
Domain(0, 0.35, 1).
Mode(colorgrad.BlendOklab).
Build()
if err != nil {
panic(err)
}
fmt.Println(grad.At(0).HexString())
fmt.Println(grad.At(1).HexString())
// Output:
// #ff0000
// #00ff00
}