automated snapshot
This commit is contained in:
22
field.go
22
field.go
@@ -14,21 +14,21 @@ type Field interface {
|
||||
|
||||
// TRANSFORM FIELDS
|
||||
type ScaleField struct {
|
||||
Field Field
|
||||
Scale float32
|
||||
field Field
|
||||
scale float32
|
||||
}
|
||||
|
||||
func (f *ScaleField) Get(x, y float32) float32 {
|
||||
return f.Field.Get(x / f.Scale, y / f.Scale)
|
||||
return f.field.Get(x / f.scale, y / f.scale)
|
||||
}
|
||||
|
||||
type TranslateField struct {
|
||||
Field Field
|
||||
field Field
|
||||
x, y float32
|
||||
}
|
||||
|
||||
func (f *TranslateField) Get(x, y float32) float32 {
|
||||
return f.Field.Get(x + f.x, y + f.y)
|
||||
return f.field.Get(x + f.x, y + f.y)
|
||||
}
|
||||
|
||||
// NOISE FIELDS
|
||||
@@ -46,6 +46,7 @@ func (f *SimplexNoiseField) Get(x, y float32) float32 {
|
||||
type ImageField struct {
|
||||
image *rl.Image
|
||||
pixels ImagePixels
|
||||
offsetX, offsetY float32
|
||||
}
|
||||
|
||||
type ImagePixels struct {
|
||||
@@ -71,11 +72,18 @@ func NewImageField(path string) ImageField {
|
||||
h: int(image.Height),
|
||||
colors: colors,
|
||||
}
|
||||
return ImageField { image: image, pixels: pixels }
|
||||
offsetX := float32(image.Width / 2)
|
||||
offsetY := float32(image.Height / 2)
|
||||
return ImageField {
|
||||
image: image,
|
||||
pixels: pixels,
|
||||
offsetX: offsetX,
|
||||
offsetY: offsetY,
|
||||
}
|
||||
}
|
||||
|
||||
func (f *ImageField) Get(x, y float32) float32 {
|
||||
// todo : blend colors
|
||||
c := f.pixels.Get(int(x), int(y))
|
||||
c := f.pixels.Get(int(x+f.offsetX), int(y + f.offsetY))
|
||||
return Brightness(c)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user