automated snapshot

This commit is contained in:
sumi
2025-12-20 01:51:28 -06:00
parent b89137415c
commit c8229f02d0
4 changed files with 169 additions and 83 deletions

View File

@@ -19,16 +19,16 @@ type ScaleField struct {
}
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
x, y float32
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
@@ -44,13 +44,13 @@ func (f *SimplexNoiseField) Get(x, y float32) float32 {
// IMAGE FIELDS
type ImageField struct {
image *rl.Image
pixels ImagePixels
image *rl.Image
pixels ImagePixels
offsetX, offsetY float32
}
type ImagePixels struct {
w, h int
w, h int
colors []rl.Color
}
@@ -61,22 +61,22 @@ func (p *ImagePixels) Get(x, y int) rl.Color {
if y < 0 || y >= p.h {
return rl.Black
}
return p.colors[x + y * p.w]
return p.colors[x+y*p.w]
}
func NewImageField(path string) ImageField {
image := rl.LoadImage(path)
colors := rl.LoadImageColors(image)
pixels := ImagePixels {
w: int(image.Width),
h: int(image.Height),
pixels := ImagePixels{
w: int(image.Width),
h: int(image.Height),
colors: colors,
}
offsetX := float32(image.Width / 2)
offsetY := float32(image.Height / 2)
return ImageField {
image: image,
pixels: pixels,
return ImageField{
image: image,
pixels: pixels,
offsetX: offsetX,
offsetY: offsetY,
}
@@ -84,6 +84,6 @@ func NewImageField(path string) ImageField {
func (f *ImageField) Get(x, y float32) float32 {
// todo : blend colors
c := f.pixels.Get(int(x+f.offsetX), int(y + f.offsetY))
c := f.pixels.Get(int(x+f.offsetX), int(y+f.offsetY))
return Brightness(c)
}