34 lines
508 B
Go
34 lines
508 B
Go
package main
|
|
|
|
import (
|
|
"github.com/ojrac/opensimplex-go"
|
|
)
|
|
|
|
type Field interface {
|
|
/**
|
|
* return a value on the range 0,1
|
|
*/
|
|
Get(x float32, y float32) float32
|
|
}
|
|
|
|
// TRANSFORM FIELDS
|
|
type ScaleField struct {
|
|
Scale float32
|
|
Field Field
|
|
}
|
|
|
|
func (f *ScaleField) Get(x, y float32) float32 {
|
|
return f.Field.Get(x / f.Scale, y / f.Scale)
|
|
}
|
|
|
|
// NOISE FIELDS
|
|
|
|
type SimplexNoiseField struct {
|
|
Noise opensimplex.Noise32
|
|
}
|
|
|
|
func (f *SimplexNoiseField) Get(x, y float32) float32 {
|
|
return f.Noise.Eval2(x, y)
|
|
}
|
|
|