-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample_decay_test.go
More file actions
32 lines (26 loc) · 851 Bytes
/
example_decay_test.go
File metadata and controls
32 lines (26 loc) · 851 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
package texture_test
import (
"fmt"
"github.com/jphsd/graphics2d/image"
"github.com/jphsd/texture"
)
func Example_decay() {
// Original waveform
nl := texture.NewNLSin()
w := texture.NewNLWave([]float64{62}, []*texture.NonLinear{nl}, true, false)
w1 := texture.NewInvertWave(w)
f := texture.NewLinearGradient(w1)
// Decay factor
nl2 := texture.NewNLLinear()
w2 := texture.NewNLWave([]float64{600}, []*texture.NonLinear{nl2}, false, false)
w3 := texture.NewInvertWave(w2)
f2 := texture.NewLinearGradient(w3)
// Remap [-1,1] => [0,1]
f4 := texture.NewRemapFilter(f2, 0, 1)
// Combine waves to get decay waveform
f3 := texture.NewMulCombiner(f, f4)
img := texture.NewTextureGray16(600, 600, f3, 0, 0, 1, 1, false)
image.SaveImage(img, "Example_decay")
fmt.Printf("Generated Example_decay")
// Output: Generated Example_decay
}