-
Notifications
You must be signed in to change notification settings - Fork 1
/
component.go
26 lines (23 loc) · 788 Bytes
/
component.go
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
package texture
import (
"image/color"
)
// Component composes a value, vector and color field.
type Component struct {
Name string
Value Field
Vector VectorField
Color ColorField
}
// NewComponent takes a source field and returns a component instance. The three colors control
// the color values at t = 0, 0.5, 1 in the supplied nonlinear color field created from the
// nonlinear and lerp functions. The vector field is produced by calculating the normals of the
// source field, scaled by bscale.
func NewComponent(src Field,
c1, c2, c3 color.Color,
lerp LerpType,
bscale float64) *Component {
normals := NewNormal(src, bscale, bscale, 1, 1)
cc := NewColorConv(src, c1, c3, []color.Color{c2}, []float64{0.5}, lerp)
return &Component{"Component", src, normals, cc}
}