automated snapshot
This commit is contained in:
59
main.go
59
main.go
@@ -44,8 +44,8 @@ func main() {
|
|||||||
|
|
||||||
// point at source center
|
// point at source center
|
||||||
// put source center at center of screen
|
// put source center at center of screen
|
||||||
var camera = TextureCam {
|
var camera = TextureCam{
|
||||||
LookAt: rl.Vector2 { X: float32(sourceWidth) / 2.0, Y: float32(sourceHeight) / 2.0 },
|
LookAt: rl.Vector2{X: float32(sourceWidth) / 2.0, Y: float32(sourceHeight) / 2.0},
|
||||||
Zoom: 1.0,
|
Zoom: 1.0,
|
||||||
SourceWidth: sourceWidth,
|
SourceWidth: sourceWidth,
|
||||||
SourceHeight: sourceHeight,
|
SourceHeight: sourceHeight,
|
||||||
@@ -61,9 +61,9 @@ func main() {
|
|||||||
|
|
||||||
field :=
|
field :=
|
||||||
TranslateField{
|
TranslateField{
|
||||||
x: -float32(sourceWidth/2.0),
|
x: -float32(sourceWidth / 2.0),
|
||||||
y: -float32(sourceHeight/2.0),
|
y: -float32(sourceHeight / 2.0),
|
||||||
field: &ScaleField {
|
field: &ScaleField{
|
||||||
scale: 5.0,
|
scale: 5.0,
|
||||||
field: &imageField,
|
field: &imageField,
|
||||||
},
|
},
|
||||||
@@ -75,11 +75,11 @@ func main() {
|
|||||||
sketch := NewSketch()
|
sketch := NewSketch()
|
||||||
//sketch.CreateLayer("testPattern", &TestPattern{}, int32(sourceWidth), int32(sourceHeight))
|
//sketch.CreateLayer("testPattern", &TestPattern{}, int32(sourceWidth), int32(sourceHeight))
|
||||||
//sketch.CreateLayer("actors", &contourLayer, 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("field", &FieldLayer{field: &field, dirty: true}, int32(sourceWidth), int32(sourceHeight))
|
||||||
sketch.CreateLayer("contours", &contourLayer, int32(sourceWidth), int32(sourceHeight))
|
sketch.CreateLayer("contours", &contourLayer, int32(sourceWidth), int32(sourceHeight))
|
||||||
|
|
||||||
ports := MakePorts()
|
ports := MakePorts()
|
||||||
ports["sierpinskiArrowAngle"] = Sine {
|
ports["sierpinskiArrowAngle"] = Sine{
|
||||||
Amp: 120,
|
Amp: 120,
|
||||||
Bias: 100,
|
Bias: 100,
|
||||||
Freq: 0.1,
|
Freq: 0.1,
|
||||||
@@ -126,7 +126,7 @@ func main() {
|
|||||||
if c == 'c' {
|
if c == 'c' {
|
||||||
resetCamera(&camera)
|
resetCamera(&camera)
|
||||||
} else if c >= '1' && c <= '9' {
|
} else if c >= '1' && c <= '9' {
|
||||||
zoom := 1 << int(ch - '0')
|
zoom := 1 << int(ch-'0')
|
||||||
camera.Zoom = float32(zoom)
|
camera.Zoom = float32(zoom)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -140,7 +140,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func resetCamera(cam *TextureCam) {
|
func resetCamera(cam *TextureCam) {
|
||||||
cam.LookAt = rl.Vector2 { X: float32(cam.SourceWidth) / 2.0, Y: float32(cam.SourceHeight) / 2.0 }
|
cam.LookAt = rl.Vector2{X: float32(cam.SourceWidth) / 2.0, Y: float32(cam.SourceHeight) / 2.0}
|
||||||
cam.Zoom = 1.0
|
cam.Zoom = 1.0
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,7 +150,7 @@ type FieldLayer struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *FieldLayer) Update(ctx *RenderCtx) {
|
func (s *FieldLayer) Update(ctx *RenderCtx) {
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *FieldLayer) Draw(ctx *RenderCtx) {
|
func (s *FieldLayer) Draw(ctx *RenderCtx) {
|
||||||
@@ -171,30 +171,45 @@ func (s *FieldLayer) IsDirty() bool {
|
|||||||
type ContourLayer struct {
|
type ContourLayer struct {
|
||||||
field Field
|
field Field
|
||||||
actors []*Actor
|
actors []*Actor
|
||||||
|
rng *rand.Rand
|
||||||
|
sourceWidth int
|
||||||
|
sourceHeight int
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewContourLayer(rng *rand.Rand, field Field, sourceWidth int, sourceHeight int) ContourLayer {
|
func NewContourLayer(rng *rand.Rand, field Field, sourceWidth int, sourceHeight int) ContourLayer {
|
||||||
|
|
||||||
actors := make([]*Actor, 20000)
|
actors := make([]*Actor, 0)
|
||||||
for i := range len(actors) {
|
|
||||||
x := rng.Int() % sourceWidth
|
layer := ContourLayer {
|
||||||
y := rng.Int() % sourceHeight
|
rng: rng,
|
||||||
actors[i] =
|
|
||||||
&Actor{
|
|
||||||
position: rl.Vector2 { X: float32(x), Y: float32(y) },
|
|
||||||
field: field,
|
field: field,
|
||||||
|
actors: actors,
|
||||||
|
sourceWidth: sourceWidth,
|
||||||
|
sourceHeight: sourceHeight,
|
||||||
|
}
|
||||||
|
|
||||||
|
layer.AddActors(1)
|
||||||
|
|
||||||
|
return layer
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ContourLayer) AddActors(n int) {
|
||||||
|
for range n {
|
||||||
|
x := s.rng.Int() % s.sourceWidth
|
||||||
|
y := s.rng.Int() % s.sourceHeight
|
||||||
|
newActor :=
|
||||||
|
&Actor {
|
||||||
|
position: rl.Vector2{X: float32(x), Y: float32(y)},
|
||||||
|
field: s.field,
|
||||||
stepSize: 1,
|
stepSize: 1,
|
||||||
color: rl.NewColor(11, 35, 176, 100),
|
color: rl.NewColor(11, 35, 176, 100),
|
||||||
}
|
}
|
||||||
}
|
s.actors = append(s.actors, newActor)
|
||||||
|
|
||||||
return ContourLayer{
|
|
||||||
actors: actors,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ContourLayer) Update(ctx *RenderCtx) {
|
func (s *ContourLayer) Update(ctx *RenderCtx) {
|
||||||
;
|
s.AddActors(100) // parameterize
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ContourLayer) Draw(ctx *RenderCtx) {
|
func (s *ContourLayer) Draw(ctx *RenderCtx) {
|
||||||
|
|||||||
Reference in New Issue
Block a user