refactoring progress
This commit is contained in:
67
main.go
67
main.go
@@ -9,7 +9,7 @@ import (
|
||||
"os"
|
||||
"time"
|
||||
|
||||
g "github.com/d2fn/sumi/internal/graphics"
|
||||
sg "github.com/d2fn/sumi/internal/graphics"
|
||||
"github.com/ojrac/opensimplex-go"
|
||||
|
||||
gui "github.com/gen2brain/raylib-go/raygui"
|
||||
@@ -17,13 +17,14 @@ import (
|
||||
//"github.com/ojrac/opensimplex-go"
|
||||
)
|
||||
|
||||
|
||||
func Bootstrap() sg.Graphics {
|
||||
|
||||
var (
|
||||
snapshotsPath string
|
||||
storage *Storage
|
||||
)
|
||||
|
||||
func Bootstrap() g.Layout {
|
||||
|
||||
rl.InitWindow(800, 600, "bootstrap")
|
||||
|
||||
monitor := rl.GetCurrentMonitor()
|
||||
@@ -74,12 +75,27 @@ func Bootstrap() g.Layout {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
return g.Layout {
|
||||
Monitor: g.Rect{X: 0, Y: 0, Width: float32(monitorWidth), Height: float32(monitorHeight)},
|
||||
Window: g.Rect{X: 0, Y: 0, Width: float32(windowWidth), Height: float32(windowHeight)},
|
||||
Controls: g.Rect{X: 0, Y: 0, Width: float32(controlsWidth), Height: float32(windowHeight)},
|
||||
Viewport: g.Rect{X: float32(controlsWidth), Y: 0, Width: float32(viewportWidth), Height: float32(windowHeight)},
|
||||
Graphics: g.Rect{X: 0, Y: 0, Width: float32(graphicsWidth), Height: float32(graphicsHeight)},
|
||||
layout := sg.Layout {
|
||||
Monitor: sg.Rect{X: 0, Y: 0, Width: float32(monitorWidth), Height: float32(monitorHeight)},
|
||||
Window: sg.Rect{X: 0, Y: 0, Width: float32(windowWidth), Height: float32(windowHeight)},
|
||||
Controls: sg.Rect{X: 0, Y: 0, Width: float32(controlsWidth), Height: float32(windowHeight)},
|
||||
Viewport: sg.Rect{X: float32(controlsWidth), Y: 0, Width: float32(viewportWidth), Height: float32(windowHeight)},
|
||||
Graphics: sg.Rect{X: 0, Y: 0, Width: float32(graphicsWidth), Height: float32(graphicsHeight)},
|
||||
}
|
||||
|
||||
//rl.SetConfigFlags(rl.FlagMsaa4xHint)
|
||||
rl.InitWindow(int32(layout.Window.Width), int32(layout.Window.Height), "sumi sierpinski arrow")
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
return sg.Graphics {
|
||||
Layout: layout,
|
||||
Style: sg.Style {
|
||||
Fill: false,
|
||||
FillColor: rl.RayWhite,
|
||||
Stroke: true,
|
||||
StrokeColor: rl.Black,
|
||||
StrokeWeight: 1.0,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,15 +103,11 @@ func main() {
|
||||
|
||||
log := log.New(os.Stdout, "", log.Ldate|log.Ltime|log.Lshortfile)
|
||||
|
||||
layout := Bootstrap()
|
||||
|
||||
//rl.SetConfigFlags(rl.FlagMsaa4xHint)
|
||||
rl.InitWindow(int32(layout.Window.Width), int32(layout.Window.Height), "sumi sierpinski arrow")
|
||||
g := Bootstrap()
|
||||
|
||||
// reproducable flourescent color cycle
|
||||
colorCycle := g.NewFixedColorCycle(g.FlourescentColors).Shuffle(0)
|
||||
colorCycle := sg.NewFixedColorCycle(sg.FlourescentColors).Shuffle(0)
|
||||
|
||||
rl.SetTargetFPS(60)
|
||||
t0 := time.Now()
|
||||
|
||||
rng := rand.New(rand.NewSource(0))
|
||||
@@ -108,8 +120,8 @@ func main() {
|
||||
//imageField := NewImageField("/home/d/Dropbox/art/data/moses_statue.jpg")
|
||||
field :=
|
||||
&TranslateField{
|
||||
x: -float32(layout.Graphics.Width / 2.0),
|
||||
y: -float32(layout.Graphics.Height / 2.0),
|
||||
x: -float32(g.Layout.Graphics.Width / 2.0),
|
||||
y: -float32(g.Layout.Graphics.Height / 2.0),
|
||||
field: &ScaleField{
|
||||
scale: 100.0,
|
||||
field: &AdderField{
|
||||
@@ -123,7 +135,7 @@ func main() {
|
||||
|
||||
//sierpinskiLayer := &SierpinskiArrow { dirty: true }
|
||||
|
||||
sketch := NewSketch(int32(layout.Graphics.Width), int32(layout.Graphics.Height))
|
||||
sketch := NewSketch(&g)
|
||||
|
||||
fieldColor := colorCycle.Next()
|
||||
fmt.Printf("field color = %v\n", fieldColor)
|
||||
@@ -138,12 +150,14 @@ func main() {
|
||||
hsv := rl.ColorToHSV(actorColor)
|
||||
hsv.Z *= 0.7
|
||||
actorColor = rl.ColorFromHSV(hsv.X, hsv.Y, hsv.Z)
|
||||
actorColor = g.Clamp(actorColor, 10, 255)
|
||||
actorColor = sg.Clamp(actorColor, 10, 255)
|
||||
actorColor.A = 10
|
||||
|
||||
actorSGColor := sg.Color { R: actorColor.R, G: actorColor.G, B: actorColor.B, A: actorColor.A }
|
||||
//NewColor(11, 35, 176, 50),
|
||||
|
||||
//r
|
||||
contourLayer := NewContourLayer(&sketch, rng, field, actorColor, -25*math.Pi, 25*math.Pi)
|
||||
contourLayer := NewContourLayer(&sketch, rng, field, actorSGColor, -25*math.Pi, 25*math.Pi)
|
||||
sketch.AddLayer("contours", contourLayer)
|
||||
//sketch.AddLayer("sierpinski-arrowhead", sierpinskiLayer)
|
||||
// aurora := NewImageLayer("/home/d/Dropbox/photos/Events/2025/Aurora/Photo Nov 11 2025, 9 52 03 PM.jpg")
|
||||
@@ -175,15 +189,13 @@ func main() {
|
||||
t := time.Since(t0).Seconds()
|
||||
|
||||
// set up RenderCtx
|
||||
renderCtx := &RenderCtx {
|
||||
TargetBounds: layout.Viewport,
|
||||
SourceWidth: int32(layout.Graphics.Width),
|
||||
SourceHeight: int32(layout.Graphics.Height),
|
||||
env := &Env {
|
||||
Graphics: g,
|
||||
Time: t,
|
||||
Ports: ports.Eval(t),
|
||||
}
|
||||
|
||||
sketch.Update(renderCtx)
|
||||
sketch.Update(env)
|
||||
|
||||
/**
|
||||
* MAIN DRAWING
|
||||
@@ -191,7 +203,7 @@ func main() {
|
||||
rl.BeginDrawing()
|
||||
rl.ClearBackground(rl.GetColor(uint(gui.GetStyle(gui.DEFAULT, gui.BACKGROUND_COLOR))))
|
||||
|
||||
sketch.Draw(renderCtx)
|
||||
sketch.Draw(env)
|
||||
|
||||
gui.SetStyle(gui.DEFAULT, gui.BACKGROUND_COLOR, 0x181818FF)
|
||||
gui.SetStyle(gui.DEFAULT, gui.BASE_COLOR_NORMAL, 0x2A2A2AFF)
|
||||
@@ -204,7 +216,7 @@ func main() {
|
||||
y := float32(10)
|
||||
|
||||
minX := float32(60)
|
||||
maxX := float32(layout.Controls.X + layout.Controls.Width - 20)
|
||||
maxX := float32(g.Layout.Controls.X + g.Layout.Controls.Width - 20)
|
||||
sliderWidth := maxX - minX - 20
|
||||
controlRowHeight := 20
|
||||
for _, layerTools := range sketch.layerToolsOrdered {
|
||||
@@ -246,7 +258,6 @@ func main() {
|
||||
*/
|
||||
|
||||
y += float32(controlRowHeight + 10)
|
||||
|
||||
}
|
||||
|
||||
rl.EndDrawing()
|
||||
|
||||
Reference in New Issue
Block a user