progress using my own graphics interface
This commit is contained in:
106
main.go
106
main.go
@@ -19,18 +19,10 @@ import (
|
||||
|
||||
var (
|
||||
snapshotsPath string
|
||||
storage *Storage
|
||||
storage *Storage
|
||||
)
|
||||
|
||||
type Layout struct {
|
||||
monitor rl.RectangleInt32
|
||||
window rl.RectangleInt32
|
||||
controls rl.RectangleInt32
|
||||
viewport rl.RectangleInt32
|
||||
graphics rl.RectangleInt32
|
||||
}
|
||||
|
||||
func bootstrap() Layout {
|
||||
func Bootstrap() g.Layout {
|
||||
|
||||
rl.InitWindow(800, 600, "bootstrap")
|
||||
|
||||
@@ -49,16 +41,16 @@ func bootstrap() Layout {
|
||||
|
||||
// set controls to use 1/6th of the width
|
||||
controlsRelWidth := 1.0 / 12.0
|
||||
|
||||
defaultGraphicsWidth := 5*int((float64(defaultWindowWidth)*(1.0-controlsRelWidth)))
|
||||
defaultGraphicsHeight := 5*defaultWindowHeight
|
||||
|
||||
defaultGraphicsWidth := 5 * int((float64(defaultWindowWidth) * (1.0 - controlsRelWidth)))
|
||||
defaultGraphicsHeight := 5 * defaultWindowHeight
|
||||
graphicsWidth := defaultGraphicsWidth
|
||||
graphicsHeight := defaultGraphicsHeight
|
||||
|
||||
fmt.Printf("monitor : %d x %d / window : %d x %d / buffer : %d x %d",
|
||||
monitorWidth, monitorHeight,
|
||||
defaultWindowWidth, defaultWindowHeight,
|
||||
defaultGraphicsWidth, defaultWindowHeight)
|
||||
monitorWidth, monitorHeight,
|
||||
defaultWindowWidth, defaultWindowHeight,
|
||||
defaultGraphicsWidth, defaultWindowHeight)
|
||||
|
||||
flag.StringVar(&snapshotsPath, "path", "snapshots", "Path to snapshots and db")
|
||||
flag.IntVar(&graphicsWidth, "gw", defaultGraphicsWidth, "Width of the internal graphics buffer. Can be much larger than the screen.")
|
||||
@@ -82,12 +74,12 @@ func bootstrap() Layout {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
return Layout {
|
||||
monitor: rl.RectangleInt32{ X: 0, Y: 0, Width: int32(monitorWidth), Height: int32(monitorHeight) },
|
||||
window: rl.RectangleInt32{ X: 0, Y: 0, Width: int32(windowWidth), Height: int32(windowHeight) },
|
||||
controls: rl.RectangleInt32{ X: 0, Y: 0, Width: int32(controlsWidth), Height: int32(windowHeight) },
|
||||
viewport: rl.RectangleInt32{ X: int32(controlsWidth), Y: 0, Width: int32(viewportWidth), Height: int32(windowHeight) },
|
||||
graphics: rl.RectangleInt32{ X: 0, Y: 0, Width: int32(graphicsWidth), Height: int32(graphicsHeight) },
|
||||
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)},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,10 +87,10 @@ func main() {
|
||||
|
||||
log := log.New(os.Stdout, "", log.Ldate|log.Ltime|log.Lshortfile)
|
||||
|
||||
layout := bootstrap()
|
||||
layout := Bootstrap()
|
||||
|
||||
//rl.SetConfigFlags(rl.FlagMsaa4xHint)
|
||||
rl.InitWindow(layout.window.Width, layout.window.Height, "sumi sierpinski arrow")
|
||||
rl.InitWindow(int32(layout.Window.Width), int32(layout.Window.Height), "sumi sierpinski arrow")
|
||||
|
||||
// reproducable flourescent color cycle
|
||||
colorCycle := g.NewFixedColorCycle(g.FlourescentColors).Shuffle(0)
|
||||
@@ -108,21 +100,21 @@ func main() {
|
||||
|
||||
rng := rand.New(rand.NewSource(0))
|
||||
//imageField := NewImageField("/home/d/Dropbox/art/data/david.png")
|
||||
noiseField := &SimplexNoiseField { Noise: opensimplex.New32(0) }
|
||||
sinXYField := &SinXYField { }
|
||||
noiseField := &SimplexNoiseField{Noise: opensimplex.New32(0)}
|
||||
sinXYField := &SinXYField{}
|
||||
//imageField := NewImageField("/home/d/Dropbox/art/data/ramstatue.png")
|
||||
//imageField := NewImageField("/home/d/Dropbox/art/data/bassrockastro/Photo Dec 24 2025, 5 58 23 PM.jpg")
|
||||
//imageField := NewImageField("/home/d/Dropbox/art/data/bassrockastro/andromeda.jpg")
|
||||
//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),
|
||||
&TranslateField{
|
||||
x: -float32(layout.Graphics.Width / 2.0),
|
||||
y: -float32(layout.Graphics.Height / 2.0),
|
||||
field: &ScaleField{
|
||||
scale: 100.0,
|
||||
field: &AdderField {
|
||||
fields: []Field {
|
||||
&ScaleField { scale: 10,field: noiseField },
|
||||
field: &AdderField{
|
||||
fields: []Field{
|
||||
&ScaleField{scale: 10, field: noiseField},
|
||||
sinXYField,
|
||||
},
|
||||
},
|
||||
@@ -131,12 +123,11 @@ func main() {
|
||||
|
||||
//sierpinskiLayer := &SierpinskiArrow { dirty: true }
|
||||
|
||||
sketch := NewSketch(layout.graphics.Width, layout.graphics.Height)
|
||||
sketch := NewSketch(int32(layout.Graphics.Width), int32(layout.Graphics.Height))
|
||||
|
||||
fieldColor := colorCycle.Next()
|
||||
fmt.Printf("field color = %v\n", fieldColor)
|
||||
|
||||
|
||||
sketch.AddColorLayer("background-magenta", rl.Magenta)
|
||||
sketch.AddColorLayer("background-black", rl.Black)
|
||||
//sketch.AddLayer("field", &FieldLayer{field: field, loColor: rl.NewColor(0, 0, 0, 0), hiColor: fieldColor, dirty: true})
|
||||
@@ -144,7 +135,7 @@ func main() {
|
||||
|
||||
fmt.Printf("actor color = %v\n", actorColor)
|
||||
|
||||
hsv := rl.ColorToHSV(actorColor);
|
||||
hsv := rl.ColorToHSV(actorColor)
|
||||
hsv.Z *= 0.7
|
||||
actorColor = rl.ColorFromHSV(hsv.X, hsv.Y, hsv.Z)
|
||||
actorColor = g.Clamp(actorColor, 10, 255)
|
||||
@@ -155,40 +146,39 @@ func main() {
|
||||
contourLayer := NewContourLayer(&sketch, rng, field, actorColor, -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")
|
||||
// sketch.AddLayer("aurora", aurora)
|
||||
// cave := NewImageLayer("/home/d/Dropbox/photos/Events/2025/ Chelsea and James visit Lindell/Photo Nov 29 2025, 5 26 40 PM (29).jpg")
|
||||
// sketch.AddLayer("cave", cave)
|
||||
// aurora := NewImageLayer("/home/d/Dropbox/photos/Events/2025/Aurora/Photo Nov 11 2025, 9 52 03 PM.jpg")
|
||||
// sketch.AddLayer("aurora", aurora)
|
||||
// cave := NewImageLayer("/home/d/Dropbox/photos/Events/2025/ Chelsea and James visit Lindell/Photo Nov 29 2025, 5 26 40 PM (29).jpg")
|
||||
// sketch.AddLayer("cave", cave)
|
||||
|
||||
ports := MakePorts()
|
||||
ports["sierpinskiArrowAngle"] =
|
||||
Sine {
|
||||
Amp: 5,
|
||||
Sine{
|
||||
Amp: 5,
|
||||
Freq: 0.1,
|
||||
Bias: 60,
|
||||
}
|
||||
|
||||
ports["sierpinskiArrowDepth"] =
|
||||
Const {
|
||||
Const{
|
||||
V: 6,
|
||||
}
|
||||
|
||||
ports["sierpinskiArrowLength"] =
|
||||
Const {
|
||||
Const{
|
||||
V: 8000,
|
||||
}
|
||||
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
|
||||
// begin drawing
|
||||
t := time.Since(t0).Seconds()
|
||||
|
||||
// set up RenderCtx
|
||||
renderCtx := &RenderCtx{
|
||||
TargetBounds: layout.viewport,
|
||||
SourceWidth: layout.graphics.Width,
|
||||
SourceHeight: layout.graphics.Height,
|
||||
renderCtx := &RenderCtx {
|
||||
TargetBounds: layout.Viewport,
|
||||
SourceWidth: int32(layout.Graphics.Width),
|
||||
SourceHeight: int32(layout.Graphics.Height),
|
||||
Time: t,
|
||||
Ports: ports.Eval(t),
|
||||
}
|
||||
@@ -214,13 +204,15 @@ func main() {
|
||||
y := float32(10)
|
||||
|
||||
minX := float32(60)
|
||||
maxX := float32(layout.controls.X + layout.controls.Width - 20)
|
||||
maxX := float32(layout.Controls.X + layout.Controls.Width - 20)
|
||||
sliderWidth := maxX - minX - 20
|
||||
controlRowHeight := 20
|
||||
for _, layerTools := range sketch.layerToolsOrdered {
|
||||
|
||||
config := layerTools.config
|
||||
|
||||
//layerTools.texture.Texture
|
||||
|
||||
gui.Label(rl.Rectangle{X: minX, Y: y, Width: 120, Height: 24}, layerTools.name)
|
||||
|
||||
y += float32(controlRowHeight + 10)
|
||||
@@ -243,15 +235,14 @@ func main() {
|
||||
config.bVisible = gui.Toggle(rl.Rectangle{X: minX, Y: y, Width: 16, Height: 16}, "B", config.bVisible)
|
||||
config.b = uint8(gui.Slider(rl.Rectangle{X: minX + 20, Y: y, Width: sliderWidth, Height: 16}, "", "", float32(config.b), 0, 255))
|
||||
|
||||
|
||||
/*
|
||||
// don't do anything with saturation / k values yet
|
||||
y += float32(controlRowHeight)
|
||||
config.desaturate = !gui.Toggle(rl.Rectangle{X: minX, Y: y, Width: 16, Height: 16}, "S", !config.desaturate)
|
||||
config.saturation = gui.Slider(rl.Rectangle{X: minX + 20, Y: y, Width: sliderWidth, Height: 16}, "", "", config.saturation, 0, 100)
|
||||
y += float32(controlRowHeight)
|
||||
gui.Label(rl.Rectangle{X: minX, Y: y, Width: 16, Height: 16}, "K")
|
||||
config.kValue = gui.Slider(rl.Rectangle{X: minX + 20, Y: y, Width: sliderWidth, Height: 16}, "", "", config.kValue, 0, 2)
|
||||
// don't do anything with saturation / k values yet
|
||||
y += float32(controlRowHeight)
|
||||
config.desaturate = !gui.Toggle(rl.Rectangle{X: minX, Y: y, Width: 16, Height: 16}, "S", !config.desaturate)
|
||||
config.saturation = gui.Slider(rl.Rectangle{X: minX + 20, Y: y, Width: sliderWidth, Height: 16}, "", "", config.saturation, 0, 100)
|
||||
y += float32(controlRowHeight)
|
||||
gui.Label(rl.Rectangle{X: minX, Y: y, Width: 16, Height: 16}, "K")
|
||||
config.kValue = gui.Slider(rl.Rectangle{X: minX + 20, Y: y, Width: sliderWidth, Height: 16}, "", "", config.kValue, 0, 2)
|
||||
*/
|
||||
|
||||
y += float32(controlRowHeight + 10)
|
||||
@@ -284,4 +275,3 @@ func main() {
|
||||
|
||||
rl.CloseWindow()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user