automated snapshot
This commit is contained in:
54
blinds.go
Normal file
54
blinds.go
Normal file
@@ -0,0 +1,54 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
sg "github.com/d2fn/sumi/internal/graphics"
|
||||
rl "github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
type BlindsLayer struct {
|
||||
Field Field
|
||||
Dirty bool
|
||||
}
|
||||
|
||||
func NewBlindsLayer(field Field) *BlindsLayer {
|
||||
return &BlindsLayer {
|
||||
Field: field,
|
||||
Dirty: true,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *BlindsLayer) Draw(env *Env, g *sg.Graphics) {
|
||||
|
||||
rowHeight := float32(10.0)
|
||||
rows := int32(g.Bounds.Height / rowHeight)
|
||||
|
||||
g.Clear()
|
||||
|
||||
c := rl.White
|
||||
c.A = 100
|
||||
|
||||
g.SetStrokeColor(c)
|
||||
g.SetStrokeWeight(1.0)
|
||||
y := float32(10.0)
|
||||
for range rows {
|
||||
for x := 10; x < int(g.Width()) - 10; x++ {
|
||||
fieldValue := l.Field.Get(float32(x), float32(y))
|
||||
strokeHeight := rl.Remap(fieldValue, 0.0, 1.0, 0.0, rowHeight * 1.3)
|
||||
a := sg.Point { X: float32(x), Y: float32(y) - strokeHeight / 2.0 }
|
||||
b := sg.Point { X: float32(x), Y: float32(y) + strokeHeight / 2.0 }
|
||||
g.DrawLine(a, b)
|
||||
}
|
||||
y += rowHeight
|
||||
}
|
||||
|
||||
l.Dirty = false
|
||||
}
|
||||
|
||||
func (l *BlindsLayer) Update(env *Env, g *sg.Graphics) {
|
||||
|
||||
}
|
||||
|
||||
func (l *BlindsLayer) IsDirty() bool {
|
||||
return l.Dirty
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user