automated snapshot

This commit is contained in:
sumi
2025-12-23 22:23:04 -06:00
parent 312d9895f5
commit b5a0015e16
2 changed files with 30 additions and 14 deletions

View File

@@ -90,22 +90,28 @@ func (s *Sketch) AddColorLayer(name string, c rl.Color) {
s.AddLayer(name, colorLayer)
}
func (s *Sketch) Draw(ctx *RenderCtx) {
func (s *Sketch) Redraw(ctx *RenderCtx) {
// render onto all layer textures
for _, instance := range s.layerToolsOrdered {
layer := instance.layer
layer.Update(ctx)
if instance.layer.IsDirty() {
rl.BeginTextureMode(instance.texture)
rl.PushMatrix()
layer.Draw(ctx)
rl.PopMatrix()
rl.EndTextureMode()
// ignore this layer entirely unless it's visible
if instance.config.visible {
layer.Update(ctx)
// re-render to texture if dirty
if instance.layer.IsDirty() {
rl.BeginTextureMode(instance.texture)
rl.PushMatrix()
layer.Draw(ctx)
rl.PopMatrix()
rl.EndTextureMode()
}
}
}
}
// composite all layers to screen
func (s *Sketch) Draw(ctx *RenderCtx) {
s.Redraw(ctx)
// copy from full texture for compositing, with vertical flipping
src := rl.Rectangle {
@@ -122,7 +128,6 @@ func (s *Sketch) Draw(ctx *RenderCtx) {
viewport := s.CalcViewport(ctx)
rl.BeginTextureMode(s.composite)
//rl.ClearBackground(rl.Black)
for _, instance := range s.layerToolsOrdered {
config := instance.config
if config.visible {