automated snapshot
This commit is contained in:
143
main.go
143
main.go
@@ -1,14 +1,15 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
// "fmt"
|
||||
"log"
|
||||
"math/rand"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
"github.com/ojrac/opensimplex-go"
|
||||
gui "github.com/gen2brain/raylib-go/raygui"
|
||||
rl "github.com/gen2brain/raylib-go/raylib"
|
||||
//"github.com/ojrac/opensimplex-go"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -34,6 +35,31 @@ func main() {
|
||||
rl.SetConfigFlags(rl.FlagMsaa4xHint)
|
||||
rl.InitWindow(targetWidth, targetHeight, "sumi sierpinski arrow")
|
||||
|
||||
// layout_name: controls initialization
|
||||
var ControlScrollPaneScrollView rl.Rectangle
|
||||
var ControlScrollPaneScrollOffset rl.Vector2
|
||||
//var ControlScrollPaneBoundsOffset rl.Vector2
|
||||
|
||||
BlendModeToggleGroupActive := int32(0)
|
||||
|
||||
Slider003Value := float32(0.0)
|
||||
|
||||
RTogglePressed := false
|
||||
GTogglePressed := false
|
||||
BTogglePressed := false
|
||||
|
||||
Slider008Value := float32(0.0)
|
||||
Slider009Value := float32(0.0)
|
||||
Slider010Value := float32(0.0)
|
||||
|
||||
ATogglePressed := false
|
||||
SaturationTogglePressed := false
|
||||
|
||||
SaturationSliderValue := float32(0.0)
|
||||
KSliderValue := float32(0.0)
|
||||
KTogglePressed := false
|
||||
// end layout vars
|
||||
|
||||
rl.SetTargetFPS(60)
|
||||
t0 := time.Now()
|
||||
|
||||
@@ -96,8 +122,69 @@ func main() {
|
||||
* MAIN DRAWING
|
||||
*/
|
||||
rl.BeginDrawing()
|
||||
rl.ClearBackground(rl.Blank)
|
||||
rl.ClearBackground(rl.GetColor(uint(gui.GetStyle(gui.DEFAULT, gui.BACKGROUND_COLOR))))
|
||||
|
||||
sketch.Draw(renderCtx)
|
||||
|
||||
//gui.LoadStyle("styles/dark.rgs")
|
||||
gui.SetStyle(gui.DEFAULT, gui.BACKGROUND_COLOR, 0x181818FF)
|
||||
gui.SetStyle(gui.DEFAULT, gui.BASE_COLOR_NORMAL, 0x2A2A2AFF)
|
||||
gui.SetStyle(gui.DEFAULT, gui.BASE_COLOR_FOCUSED, 0x3A3A3AFF)
|
||||
gui.SetStyle(gui.DEFAULT, gui.BASE_COLOR_PRESSED, 0x4A4A4AFF)
|
||||
gui.SetStyle(gui.DEFAULT, gui.TEXT_COLOR_NORMAL, 0xE0E0E0FF)
|
||||
gui.SetStyle(gui.DEFAULT, gui.TEXT_COLOR_FOCUSED, 0xFFFFFFFF)
|
||||
gui.SetStyle(gui.DEFAULT, gui.BORDER_COLOR_NORMAL, 0x404040FF)
|
||||
|
||||
controlPanelWidth := float32(targetWidth) / 4.0
|
||||
controlPanelHeight := float32(targetHeight)
|
||||
|
||||
// add gui layout controls
|
||||
// raygui: controls drawing
|
||||
gui.ScrollPanel(
|
||||
rl.Rectangle{
|
||||
X: 10,
|
||||
Y: 10,
|
||||
Width: controlPanelWidth - 20,
|
||||
Height: controlPanelHeight - 20,
|
||||
},
|
||||
"",
|
||||
rl.Rectangle{X: 10, Y: 10, Width: controlPanelWidth, Height: controlPanelHeight },
|
||||
&ControlScrollPaneScrollOffset,
|
||||
&ControlScrollPaneScrollView,
|
||||
)
|
||||
|
||||
gui.GroupBox(rl.Rectangle{X: 20, Y: 20, Width: controlPanelWidth - 50, Height: 60 }, "Blending")
|
||||
BlendModeToggleGroupActive = gui.ToggleGroup(rl.Rectangle{X: 30, Y: 40, Width: (controlPanelWidth - 70) / 3.0, Height: 24}, "ONE;TWO;THREE", BlendModeToggleGroupActive)
|
||||
|
||||
gui.Label(rl.Rectangle{X: 20, Y: 90, Width: 120, Height: 24}, "Contour Layer")
|
||||
|
||||
ATogglePressed = gui.LabelButton(rl.Rectangle{X: 40, Y: 136, Width: 16, Height: 16}, "A")
|
||||
Slider003Value = gui.Slider(rl.Rectangle{X: 64, Y: 136, Width: 264, Height: 16}, "", "", Slider003Value, 0, 255)
|
||||
|
||||
RTogglePressed = gui.LabelButton(rl.Rectangle{X: 40, Y: 160, Width: 16, Height: 16}, "R")
|
||||
Slider008Value = gui.Slider(rl.Rectangle{X: 64, Y: 160, Width: 264, Height: 16}, "", "", Slider008Value, 0, 100)
|
||||
|
||||
GTogglePressed = gui.LabelButton(rl.Rectangle{X: 40, Y: 184, Width: 16, Height: 16}, "G")
|
||||
Slider009Value = gui.Slider(rl.Rectangle{X: 64, Y: 184, Width: 264, Height: 16}, "", "", Slider009Value, 0, 100)
|
||||
|
||||
BTogglePressed = gui.LabelButton(rl.Rectangle{X: 40, Y: 208, Width: 16, Height: 16}, "B")
|
||||
Slider010Value = gui.Slider(rl.Rectangle{X: 64, Y: 208, Width: 264, Height: 16}, "", "", Slider010Value, 0, 100)
|
||||
|
||||
SaturationTogglePressed = gui.LabelButton(rl.Rectangle{X: 40, Y: 232, Width: 16, Height: 16}, "S")
|
||||
|
||||
gui.Slider(rl.Rectangle{X: 64, Y: 232, Width: 264, Height: 16}, "", "", SaturationSliderValue, 0, 100)
|
||||
gui.Slider(rl.Rectangle{X: 64, Y: 256, Width: 264, Height: 16}, "", "", KSliderValue, 0, 100)
|
||||
|
||||
KTogglePressed = gui.LabelButton(rl.Rectangle{X: 40, Y: 256, Width: 16, Height: 16}, "K")
|
||||
|
||||
// NOTE: LabelButton returns "pressed this frame" bool, so these are edge-triggered.
|
||||
_ = RTogglePressed
|
||||
_ = GTogglePressed
|
||||
_ = BTogglePressed
|
||||
_ = ATogglePressed
|
||||
_ = SaturationTogglePressed
|
||||
_ = KTogglePressed
|
||||
|
||||
rl.EndDrawing()
|
||||
|
||||
if rl.IsKeyDown(rl.KeySpace) {
|
||||
@@ -149,51 +236,3 @@ func (s *FieldLayer) IsDirty() bool {
|
||||
return s.dirty
|
||||
}
|
||||
|
||||
type SierpinskiArrow struct{}
|
||||
|
||||
func (s *SierpinskiArrow) Draw(ctx *RenderCtx) {
|
||||
sierpinskiArrow(ctx, int(ctx.Ports["sierpinskiArrowDepth"]), ctx.Ports["sierpinskiArrowLength"])
|
||||
}
|
||||
|
||||
func sierpinskiArrow(ctx *RenderCtx, order int, length float64) {
|
||||
if order == 0 {
|
||||
curve(ctx, order, length, ctx.Ports["sierpinskiArrowAngle"])
|
||||
} else {
|
||||
rl.Rotatef(float32(ctx.Ports["sierpinskiArrowAngle"]), 0, 0, 1)
|
||||
curve(ctx, order, length, -ctx.Ports["sierpinskiArrowAngle"])
|
||||
}
|
||||
}
|
||||
|
||||
func curve(ctx *RenderCtx, order int, length float64, angle float64) {
|
||||
if order == 0 {
|
||||
len := int32(length)
|
||||
rl.DrawLine(0, 0, len, 0, rl.Black)
|
||||
rl.Translatef(float32(length), 0, 0)
|
||||
} else {
|
||||
curve(ctx, order-1, length/2, -angle)
|
||||
rl.Rotatef(float32(angle), 0, 0, 1)
|
||||
curve(ctx, order-1, length/2, angle)
|
||||
rl.Rotatef(float32(angle), 0, 0, 1)
|
||||
curve(ctx, order-1, length/2, -angle)
|
||||
}
|
||||
}
|
||||
|
||||
func main2() {
|
||||
angles := make([]float32, 1000)
|
||||
noise := opensimplex.NewNormalized(0)
|
||||
for i := range len(angles) {
|
||||
angles[i] = float32(noise.Eval2(float64(i)*0.05, 0.00))*0.1 - 0.05
|
||||
}
|
||||
frameNum := 0
|
||||
for !rl.WindowShouldClose() {
|
||||
frameNum++
|
||||
// initial transform by halfway again through angle array
|
||||
angleIndex := (frameNum / 10) % len(angles)
|
||||
angle := angles[angleIndex]
|
||||
initAngle := angles[(angleIndex+len(angles)/2)%len(angles)]
|
||||
rl.Rotatef(2500*initAngle, 0, 0, 1)
|
||||
rl.Translatef(100*initAngle, 100*initAngle, 0)
|
||||
fmt.Printf("%.3f", angle)
|
||||
rl.EndMode2D()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user