automated snapshot
This commit is contained in:
34
main.go
34
main.go
@@ -3,7 +3,7 @@ package main
|
||||
import (
|
||||
// "fmt"
|
||||
"log"
|
||||
"math/rand"
|
||||
//"math/rand"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
@@ -46,7 +46,7 @@ func main() {
|
||||
t0 := time.Now()
|
||||
|
||||
/*
|
||||
*/
|
||||
|
||||
|
||||
rng := rand.New(rand.NewSource(0))
|
||||
imageField := NewImageField("/home/d/Dropbox/art/passage/data/david.png")
|
||||
@@ -59,24 +59,34 @@ func main() {
|
||||
field: imageField,
|
||||
},
|
||||
}
|
||||
*/
|
||||
|
||||
sketch := NewSketch(sourceWidth, sourceHeight)
|
||||
|
||||
sierpinskiLayer := &SierpinskiArrow { dirty: true }
|
||||
|
||||
contourLayer := NewContourLayer(&sketch, rng, field)
|
||||
//sketch.CreateLayer("testPattern", &TestPattern{}, int32(sourceWidth), int32(sourceHeight))
|
||||
//sketch.CreateLayer("actors", &contourLayer, int32(sourceWidth), int32(sourceHeight))
|
||||
//sketch.CreateLayer("field", &FieldLayer{field: &field, dirty: true}, int32(sourceWidth), int32(sourceHeight))
|
||||
sketch.CreateLayer("contours", contourLayer)
|
||||
//contourLayer := NewContourLayer(&sketch, rng, field)
|
||||
//sketch.CreateLayer("field", &FieldLayer{field: field, dirty: true})
|
||||
//sketch.CreateLayer("contours", contourLayer)
|
||||
sketch.CreateLayer("sierpinski", sierpinskiLayer)
|
||||
|
||||
ports := MakePorts()
|
||||
ports["sierpinskiArrowAngle"] = Sine {
|
||||
Amp: 120,
|
||||
Bias: 100,
|
||||
Freq: 0.1,
|
||||
}
|
||||
ports["sierpinskiArrowAngle"] =
|
||||
Const {
|
||||
V: 60,
|
||||
}
|
||||
|
||||
|
||||
ports["sierpinskiArrowDepth"] =
|
||||
Const {
|
||||
V: 6,
|
||||
}
|
||||
|
||||
ports["sierpinskiArrowLength"] =
|
||||
Const {
|
||||
V: 10000,
|
||||
}
|
||||
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
rl "github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
@@ -9,6 +10,8 @@ type SierpinskiArrow struct{
|
||||
}
|
||||
|
||||
func (s *SierpinskiArrow) Draw(ctx *RenderCtx) {
|
||||
rl.Translatef(float32(ctx.SourceWidth) / 2.0, float32(ctx.SourceHeight) / 2.0, 0)
|
||||
rl.ClearBackground(rl.NewColor(0, 0, 0, 0))
|
||||
sierpinskiArrow(ctx, int(ctx.Ports["sierpinskiArrowDepth"]), ctx.Ports["sierpinskiArrowLength"])
|
||||
}
|
||||
|
||||
@@ -21,6 +24,7 @@ func (s *SierpinskiArrow) IsDirty() bool {
|
||||
}
|
||||
|
||||
func sierpinskiArrow(ctx *RenderCtx, order int, length float64) {
|
||||
fmt.Printf("drawing SierpinskiArrow, order = %d, length = %.2f\n", order, length)
|
||||
if order == 0 {
|
||||
curve(ctx, order, length, ctx.Ports["sierpinskiArrowAngle"])
|
||||
} else {
|
||||
|
||||
@@ -70,8 +70,6 @@ func NewSketch(sourceWidth, sourceHeight int32) Sketch {
|
||||
|
||||
func (s *Sketch) CreateLayer(name string, layer Layer) {
|
||||
texture := rl.LoadRenderTexture(s.sourceWidth, s.sourceHeight)
|
||||
rl.GenTextureMipmaps(&texture.Texture)
|
||||
rl.SetTextureFilter(texture.Texture, rl.FilterTrilinear)
|
||||
config := NewLayerConfig()
|
||||
layerTools :=
|
||||
LayerTools {
|
||||
@@ -91,9 +89,11 @@ func (s *Sketch) Draw(ctx *RenderCtx) {
|
||||
layer.Update(ctx)
|
||||
if instance.layer.IsDirty() {
|
||||
rl.BeginTextureMode(instance.texture)
|
||||
rl.PushMatrix()
|
||||
layer.Draw(ctx)
|
||||
rl.PopMatrix()
|
||||
rl.EndTextureMode()
|
||||
rl.GenTextureMipmaps(&instance.texture.Texture)
|
||||
//rl.GenTextureMipmaps(&instance.texture.Texture)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user