diff --git a/contour_layer.go b/contour_layer.go new file mode 100644 index 0000000..fbf8c73 --- /dev/null +++ b/contour_layer.go @@ -0,0 +1,120 @@ +package main + +import ( + "math" + "math/rand" + "github.com/gen2brain/raylib-go/raylib" +) + +type ContourLayer struct { + field Field + actors []*Actor + rng *rand.Rand +} + +func NewContourLayer(sketch *Sketch, rng *rand.Rand, field Field) ContourLayer { + + actors := make([]*Actor, 0) + + layer := ContourLayer { + rng: rng, + field: field, + actors: actors, + } + + layer.AddActors(1, sketch.sourceWidth, sketch.sourceHeight) + + return layer +} + +func (s *ContourLayer) AddActors(n, sourceWidth, sourceHeight int32) { + for range n { + x := s.rng.Int31() % sourceWidth + y := s.rng.Int31() % sourceHeight + newActor := + &Actor { + position: rl.Vector2{X: float32(x), Y: float32(y)}, + field: s.field, + stepSize: 1, + color: rl.NewColor(11, 35, 176, 20), + } + s.actors = append(s.actors, newActor) + } +} + +func (s *ContourLayer) Update(ctx *RenderCtx) { + s.AddActors(100, ctx.SourceWidth, ctx.SourceHeight) +} + +func (s *ContourLayer) Draw(ctx *RenderCtx) { + rl.BeginBlendMode(rl.BlendAdditive) + for _, actor := range s.actors { + actor.Draw() + } + rl.EndBlendMode() +} + +func (s *ContourLayer) IsDirty() bool { + return true +} + +type Actor struct { + position rl.Vector2 + field Field + stepSize float32 + color rl.Color +} + +func (a *Actor) Draw() { + v := a.field.Get(a.position.X, a.position.Y) + rad := rl.Remap(v, 0, 1, 0, 3*math.Pi) + nextPosition := rl.Vector2{X: a.position.X + a.stepSize*float32(math.Cos(float64(rad))), Y: a.position.Y + a.stepSize*float32(math.Sin(float64(rad)))} + rl.DrawLineV(a.position, nextPosition, a.color) + //fmt.Printf("position %v -> nextPosition %v \n", a.position, nextPosition) + a.position = nextPosition +} + +func RandRadialVec(rng *rand.Rand, minRadius float32, maxRadius float32, loAngle float32, hiAngle float32) rl.Vector2 { + r := float64(rl.Remap(rng.Float32(), 0, 1, minRadius, maxRadius)) + deg := float64(rl.Remap(rng.Float32(), 0, 1, loAngle, hiAngle)) + rad := rl.Deg2rad * deg + return rl.Vector2{X: float32(r * math.Cos(rad)), Y: float32(r * math.Sin(rad))} +} + +type Worm struct { + position rl.Vector2 + angles []float32 + angleIndex int + stepSize int + renderPct float32 +} + +func (w *Worm) Draw(ctx *RenderCtx) { + rl.PushMatrix() + rl.Translatef(w.position.X, w.position.Y, 0) + lastAngle := float32(0.0) + stepCount := 0 + nudged := false + for i := range w.angles { + ii := (i + w.angleIndex) % len(w.angles) + angle := w.angles[ii] + deltaAngle := angle - lastAngle + if !nudged { + rad := float64(deltaAngle * math.Pi / 180.0) + nudge := rl.Vector2{X: float32(w.stepSize) * float32(math.Cos(rad)), Y: float32(w.stepSize) * float32(math.Sin(rad))} + w.position = rl.Vector2Add(w.position, nudge) + nudged = true + } + rl.Rotatef(deltaAngle, 0, 0, 1) + rl.DrawLine(0, 0, int32(w.stepSize), 0, rl.NewColor(184, 187, 38, 50)) + rl.Translatef(float32(w.stepSize), 0, 0) + lastAngle = angle + stepCount++ + if stepCount > int(float32(len(w.angles))*w.renderPct) { + break + } + } + rl.PopMatrix() + w.angleIndex = (w.angleIndex + 1) % len(w.angles) +} + diff --git a/flake.lock b/flake.lock index 5a7111f..f8cbb6e 100644 --- a/flake.lock +++ b/flake.lock @@ -20,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1765363881, - "narHash": "sha256-3C3xWn8/2Zzr7sxVBmpc1H1QfxjNfta5IMFe3O9ZEPw=", + "lastModified": 1766014764, + "narHash": "sha256-+73VffE5GP5fvbib6Hs1Su6LehG+9UV1Kzs90T2gBLA=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "d2b1213bf5ec5e62d96b003ab4b5cbc42abfc0d0", + "rev": "2b0d2b456e4e8452cf1c16d00118d145f31160f9", "type": "github" }, "original": { diff --git a/main.go b/main.go index fb77604..183ff39 100644 --- a/main.go +++ b/main.go @@ -3,7 +3,6 @@ package main import ( "fmt" "log" - "math" "math/rand" "os" "time" @@ -19,13 +18,6 @@ const ( snapshotsDir = "snapshots" ) -type TextureCam struct { - SourceWidth int32 - SourceHeight int32 - LookAt rl.Vector2 - Zoom float32 -} - func main() { sourceWidth := int32(sourceScale * targetWidth) @@ -42,15 +34,6 @@ func main() { rl.SetConfigFlags(rl.FlagMsaa4xHint) rl.InitWindow(targetWidth, targetHeight, "sumi sierpinski arrow") - // point at source center - // put source center at center of screen - var camera = TextureCam{ - LookAt: rl.Vector2{X: float32(sourceWidth) / 2.0, Y: float32(sourceHeight) / 2.0}, - Zoom: 1.0, - SourceWidth: sourceWidth, - SourceHeight: sourceHeight, - } - rl.SetTargetFPS(60) t0 := time.Now() @@ -70,16 +53,17 @@ func main() { } rng := rand.New(rand.NewSource(0)) - contourLayer := NewContourLayer(rng, &field, sourceWidth, sourceHeight) sketch := NewSketch(sourceWidth, sourceHeight) + + 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, int32(sourceWidth), int32(sourceHeight)) + sketch.CreateLayer("contours", &contourLayer) ports := MakePorts() - ports["sierpinskiArrowAngle"] = Sine{ + ports["sierpinskiArrowAngle"] = Sine { Amp: 120, Bias: 100, Freq: 0.1, @@ -98,7 +82,6 @@ func main() { SourceHeight: int32(sourceHeight), Time: t, Ports: ports.Eval(t), - Cam: &camera, } sketch.Update(renderCtx) @@ -125,10 +108,10 @@ func main() { for ch := rl.GetCharPressed(); ch != 0; ch = rl.GetCharPressed() { c := rune(ch) if c == 'c' { - resetCamera(&camera) + sketch.ResetCamera() } else if c >= '1' && c <= '9' { zoom := 1 << int(ch-'0') - camera.Zoom = float32(zoom) + sketch.cam.Zoom = float32(zoom) } } @@ -140,11 +123,6 @@ func main() { rl.CloseWindow() } -func resetCamera(cam *TextureCam) { - cam.LookAt = rl.Vector2{X: float32(cam.SourceWidth) / 2.0, Y: float32(cam.SourceHeight) / 2.0} - cam.Zoom = 1.0 -} - type FieldLayer struct { field Field dirty bool @@ -169,122 +147,6 @@ func (s *FieldLayer) IsDirty() bool { return s.dirty } -type ContourLayer struct { - field Field - actors []*Actor - rng *rand.Rand - sourceWidth int32 - sourceHeight int32 -} - -func NewContourLayer(rng *rand.Rand, field Field, sourceWidth int32, sourceHeight int32) ContourLayer { - - actors := make([]*Actor, 0) - - layer := ContourLayer { - rng: rng, - 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.Int31() % s.sourceWidth - y := s.rng.Int31() % s.sourceHeight - newActor := - &Actor { - position: rl.Vector2{X: float32(x), Y: float32(y)}, - field: s.field, - stepSize: 1, - color: rl.NewColor(11, 35, 176, 20), - } - s.actors = append(s.actors, newActor) - } -} - -func (s *ContourLayer) Update(ctx *RenderCtx) { - s.AddActors(100) // parameterize -} - -func (s *ContourLayer) Draw(ctx *RenderCtx) { - rl.BeginBlendMode(rl.BlendAdditive) - for _, actor := range s.actors { - actor.Draw() - } - rl.EndBlendMode() -} - -func (s *ContourLayer) IsDirty() bool { - return true -} - -type Actor struct { - position rl.Vector2 - field Field - stepSize float32 - color rl.Color -} - -func (a *Actor) Draw() { - v := a.field.Get(a.position.X, a.position.Y) - rad := rl.Remap(v, 0, 1, 0, 3*math.Pi) - nextPosition := rl.Vector2{X: a.position.X + a.stepSize*float32(math.Cos(float64(rad))), Y: a.position.Y + a.stepSize*float32(math.Sin(float64(rad)))} - rl.DrawLineV(a.position, nextPosition, a.color) - //fmt.Printf("position %v -> nextPosition %v \n", a.position, nextPosition) - a.position = nextPosition -} - -func RandRadialVec(rng *rand.Rand, minRadius float32, maxRadius float32, loAngle float32, hiAngle float32) rl.Vector2 { - r := float64(rl.Remap(rng.Float32(), 0, 1, minRadius, maxRadius)) - deg := float64(rl.Remap(rng.Float32(), 0, 1, loAngle, hiAngle)) - rad := rl.Deg2rad * deg - return rl.Vector2{X: float32(r * math.Cos(rad)), Y: float32(r * math.Sin(rad))} -} - -type Worm struct { - position rl.Vector2 - angles []float32 - angleIndex int - stepSize int - renderPct float32 -} - -func (w *Worm) Draw(ctx *RenderCtx) { - rl.PushMatrix() - rl.Translatef(w.position.X, w.position.Y, 0) - lastAngle := float32(0.0) - stepCount := 0 - nudged := false - for i := range w.angles { - ii := (i + w.angleIndex) % len(w.angles) - angle := w.angles[ii] - deltaAngle := angle - lastAngle - if !nudged { - rad := float64(deltaAngle * math.Pi / 180.0) - nudge := rl.Vector2{X: float32(w.stepSize) * float32(math.Cos(rad)), Y: float32(w.stepSize) * float32(math.Sin(rad))} - w.position = rl.Vector2Add(w.position, nudge) - nudged = true - } - rl.Rotatef(deltaAngle, 0, 0, 1) - rl.DrawLine(0, 0, int32(w.stepSize), 0, rl.NewColor(184, 187, 38, 50)) - rl.Translatef(float32(w.stepSize), 0, 0) - lastAngle = angle - stepCount++ - if stepCount > int(float32(len(w.angles))*w.renderPct) { - break - } - } - rl.PopMatrix() - w.angleIndex = (w.angleIndex + 1) % len(w.angles) -} - type SierpinskiArrow struct{} func (s *SierpinskiArrow) Draw(ctx *RenderCtx) { diff --git a/rguistyler_v6.0_linux_x64.zip b/rguistyler_v6.0_linux_x64.zip new file mode 100644 index 0000000..7161a1f Binary files /dev/null and b/rguistyler_v6.0_linux_x64.zip differ diff --git a/rguistyler_v6.0_linux_x64/LICENSE b/rguistyler_v6.0_linux_x64/LICENSE new file mode 100644 index 0000000..31e82a6 --- /dev/null +++ b/rguistyler_v6.0_linux_x64/LICENSE @@ -0,0 +1,18 @@ +zlib License + +Copyright (c) 2015-2024 raylib technologies (@raylibtech) / Ramon Santamaria (@raysan5) + +This software is provided "as-is", without any express or implied warranty. In no event +will the authors be held liable for any damages arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, including commercial +applications, and to alter it and redistribute it freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not claim that you + wrote the original software. If you use this software in a product, an acknowledgment + in the product documentation would be appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be misrepresented + as being the original software. + + 3. This notice may not be removed or altered from any source distribution. diff --git a/rguistyler_v6.0_linux_x64/README.md b/rguistyler_v6.0_linux_x64/README.md new file mode 100644 index 0000000..0b35684 --- /dev/null +++ b/rguistyler_v6.0_linux_x64/README.md @@ -0,0 +1,58 @@ +# `rGuiStyler` + +A simple and easy-to-use [raygui](https://github.com/raysan5/raygui) styles editor. + +Useful for tools style customization. The best tool companion for [rGuiLayout](https://raylibtech.itch.io/rguilayout) and [rGuiIcons](https://raylibtech.itch.io/rguiicons). + +`rGuiStyler` can be used for free as a [WebAssembly online tool](https://raylibtech.itch.io/rguistyler) and it can also be downloaded as a **standalone tool** for `Windows`, `Linux` and `macOS` with some extra features. + +**NOTE: Latest `rGuiStyler 6.0` release is intended to be used with [`raygui 4.5+`](https://github.com/raysan5/raygui) release.** + +## Features + + - **Global and control specific styles edition** + - **Style preview** in real time with individual test controls + - **Style templates** available to start customizing new styles + - Selectable controls state: **NORMAL, FOCUSED, PRESSED, DISABLED** + - Save and load as binary style file `.rgs` (with font embedded!) + - Export style as an embeddable **code file** (`.h`) (with font embedded!) + - Export style as a `.png` **controls table image** for showcase + - Embed style as png image chunk: `rGSf` (rgs file data) + - Import, configure and preview **style fonts** (`.ttf`/`.otf`) + - Load custom font charset for the style (Unicode codepoints) + - Color palette for quick color save/selection + - **+14 custom style examples** included for reference + - Command-line support for `.rgs`/`.h`/`.png` batch conversion + - **Free and open source** + +## Screenshot + +![rGuiStyler](screenshots/rguistyler_v600_shot01.png) + +## Usage + +The tool is quite intuitive, the expected steps to follow are: + 1. Choose the control to edit from the Controls ListView (`DEFAULT` referes to global style for all controls) + 2. Choose the property to edit from Properties ListView + 3. Select a value for that property (color, number...) on Control Property Edit window + 4. Font can be loaded and atlas generated automatically + +NOTE: Changes are previewed in real time in the same tool! + +Once the desired style has been created, press the `Export Style` button to save it as a `.rgs`**binary style file**. Style can also be exported as an embeddable `.h` **code file** or a `.png` **controls table image** (intended for preview and style showcase) + +`rGuiStyler Standalone` comes with command-line support for batch conversion. For usage help: + + > rguistyler.exe --help + +## License + +`rGuiStyler` source code is distributed as **open source**, licensed under an unmodified [zlib/libpng license](LICENSE). + +`rGuiStyler` binaries are completely free for anyone willing to compile them directly from source. + +`rGuiStyler Standalone` desktop tool is distributed as freeware. + +In any case, consider some donation to help the author keep working on software for games development. + +*Copyright (c) 2017-2025 raylib technologies ([@raylibtech](https://twitter.com/raylibtech)) / Ramon Santamaria ([@raysan5](https://twitter.com/raysan5))* diff --git a/rguistyler_v6.0_linux_x64/resources/resources/2a03.ttf b/rguistyler_v6.0_linux_x64/resources/resources/2a03.ttf new file mode 100644 index 0000000..71f6e9d Binary files /dev/null and b/rguistyler_v6.0_linux_x64/resources/resources/2a03.ttf differ diff --git a/rguistyler_v6.0_linux_x64/resources/resources/Cartridge.ttf b/rguistyler_v6.0_linux_x64/resources/resources/Cartridge.ttf new file mode 100644 index 0000000..19d7280 Binary files /dev/null and b/rguistyler_v6.0_linux_x64/resources/resources/Cartridge.ttf differ diff --git a/rguistyler_v6.0_linux_x64/resources/resources/CozetteVector.otf b/rguistyler_v6.0_linux_x64/resources/resources/CozetteVector.otf new file mode 100644 index 0000000..62beedb Binary files /dev/null and b/rguistyler_v6.0_linux_x64/resources/resources/CozetteVector.otf differ diff --git a/rguistyler_v6.0_linux_x64/resources/resources/Fairfax.ttf b/rguistyler_v6.0_linux_x64/resources/resources/Fairfax.ttf new file mode 100644 index 0000000..86cd9b3 Binary files /dev/null and b/rguistyler_v6.0_linux_x64/resources/resources/Fairfax.ttf differ diff --git a/rguistyler_v6.0_linux_x64/resources/resources/GMSN.ttf b/rguistyler_v6.0_linux_x64/resources/resources/GMSN.ttf new file mode 100644 index 0000000..777a528 Binary files /dev/null and b/rguistyler_v6.0_linux_x64/resources/resources/GMSN.ttf differ diff --git a/rguistyler_v6.0_linux_x64/resources/resources/Kyrou7Wide.ttf b/rguistyler_v6.0_linux_x64/resources/resources/Kyrou7Wide.ttf new file mode 100644 index 0000000..165c3e7 Binary files /dev/null and b/rguistyler_v6.0_linux_x64/resources/resources/Kyrou7Wide.ttf differ diff --git a/rguistyler_v6.0_linux_x64/resources/resources/LICENSES.md b/rguistyler_v6.0_linux_x64/resources/resources/LICENSES.md new file mode 100644 index 0000000..9c23258 --- /dev/null +++ b/rguistyler_v6.0_linux_x64/resources/resources/LICENSES.md @@ -0,0 +1,23 @@ +## Fonts licenses + +All included fonts are licensed under a permissive license, usually free to use for personal use and in most cases also for commercial use. In any case, individual licenses should be carefully reviewed and it's recommended to contact creators in case of doubts. + +| Font Name | File Name | License Type | Creator | More details | +|-----------------------|----------------------|------------------------------------------|--------------------------------|-------------------------------------| +| 2A03 | `2a03.ttf` | Free for Personal & Commercial Use | memesbruh03 | https://www.dafont.com/2a03.font | +| Cartridge | `Cartridge.ttf` | [Creative Commons BY 4.0](https://creativecommons.org/licenses/by/4.0/) | jeti | https://www.dafont.com/cartridge.font | +| CozetteVector | `CozetteVector.otf` | [MIT License](https://github.com/slavfox/Cozette/blob/main/LICENSE) | [Slavfox](https://github.com/slavfox) | https://github.com/slavfox/Cozette | +| Fairfax | `Fairfax.ttf` | [SIL Open Font License 1.1](https://github.com/kreativekorp/open-relay/blob/master/Fairfax/OFL.txt) | Kreative Korp | https://github.com/kreativekorp/open-relay | +| Generic Mobile System Nuevo | `GMSN.ttf` | [Creative Commons Zero (CC0) 1.0](https://creativecommons.org/licenses/zero/1.0/) | Jayvee Enaguas (HarvettFox96) | https://www.dafont.com/generic-mobile-system.font | +| Hello World Regular | `hello-world.ttf` | SIL Open Font License | Anthony Gross | https://www.dafont.com/hello-world.font | +| Homespun TT BRK | `homespun.ttf` | Free for Personal Use | AEnigma (Brian Kent) | https://www.dafont.com/homespun-brk.font | +| Grixel Kyrou 7 Wide | `Kyrou7Wide.ttf` | [Creative Commons BY-ND 2.5](http://creativecommons.org/licenses/by-nd/2.5/) | Nikos Giannakopoulos | https://www.dafont.com/grixel-kyrou-7-wide.font +| Mecha | `Mecha.ttf` | Free for Personal Use | Captain Falcon | https://www.dafont.com/mecha-cf.font | +| OwreKynge | `OwreKynge.ttf` | [Creative Commons BY 4.0](https://creativecommons.org/licenses/by/4.0/) | jeti | https://www.dafont.com/owrekynge.font | +| Pixel Intv | `PixelIntv.otf` | Free for Personal Use | Pixel Sagas (Neale Davidson) | https://www.dafont.com/pixel-intv.font | +| Pixel Operator | `PixelOperator.ttf` | [Creative Commons Zero (CC0) 1.0](https://creativecommons.org/licenses/zero/1.0/) | Jayvee Enaguas (HarvettFox96) | https://www.dafont.com/pixel-operator.font | +| V5 Eastergothic | `v5easter.ttf` | Free, use at will | Roberto Christen | https://www.dafont.com/v5eastergothic.font | +| V5 Loxical Lixera | `v5loxical.ttf` | Free, use at will | Roberto Christen | https://www.dafont.com/v5loxica-lixera.font | +| Westington | `Westington.ttf` | Free use for anything, personal or otherwise | Hazel Abbiati | https://www.dafont.com/westington.font | + +Enjoy it! \ No newline at end of file diff --git a/rguistyler_v6.0_linux_x64/resources/resources/Mecha.ttf b/rguistyler_v6.0_linux_x64/resources/resources/Mecha.ttf new file mode 100644 index 0000000..928f63a Binary files /dev/null and b/rguistyler_v6.0_linux_x64/resources/resources/Mecha.ttf differ diff --git a/rguistyler_v6.0_linux_x64/resources/resources/OwreKynge.ttf b/rguistyler_v6.0_linux_x64/resources/resources/OwreKynge.ttf new file mode 100644 index 0000000..6a0dc64 Binary files /dev/null and b/rguistyler_v6.0_linux_x64/resources/resources/OwreKynge.ttf differ diff --git a/rguistyler_v6.0_linux_x64/resources/resources/PixelIntv.otf b/rguistyler_v6.0_linux_x64/resources/resources/PixelIntv.otf new file mode 100644 index 0000000..e8c54a7 Binary files /dev/null and b/rguistyler_v6.0_linux_x64/resources/resources/PixelIntv.otf differ diff --git a/rguistyler_v6.0_linux_x64/resources/resources/PixelOperator.ttf b/rguistyler_v6.0_linux_x64/resources/resources/PixelOperator.ttf new file mode 100644 index 0000000..34fe947 Binary files /dev/null and b/rguistyler_v6.0_linux_x64/resources/resources/PixelOperator.ttf differ diff --git a/rguistyler_v6.0_linux_x64/resources/resources/Westington.ttf b/rguistyler_v6.0_linux_x64/resources/resources/Westington.ttf new file mode 100644 index 0000000..68efae8 Binary files /dev/null and b/rguistyler_v6.0_linux_x64/resources/resources/Westington.ttf differ diff --git a/rguistyler_v6.0_linux_x64/resources/resources/hello-world.ttf b/rguistyler_v6.0_linux_x64/resources/resources/hello-world.ttf new file mode 100644 index 0000000..7d190b8 Binary files /dev/null and b/rguistyler_v6.0_linux_x64/resources/resources/hello-world.ttf differ diff --git a/rguistyler_v6.0_linux_x64/resources/resources/homespun.ttf b/rguistyler_v6.0_linux_x64/resources/resources/homespun.ttf new file mode 100644 index 0000000..45c23e0 Binary files /dev/null and b/rguistyler_v6.0_linux_x64/resources/resources/homespun.ttf differ diff --git a/rguistyler_v6.0_linux_x64/resources/resources/v5easter.ttf b/rguistyler_v6.0_linux_x64/resources/resources/v5easter.ttf new file mode 100644 index 0000000..77a911a Binary files /dev/null and b/rguistyler_v6.0_linux_x64/resources/resources/v5easter.ttf differ diff --git a/rguistyler_v6.0_linux_x64/resources/resources/v5loxical.ttf b/rguistyler_v6.0_linux_x64/resources/resources/v5loxical.ttf new file mode 100644 index 0000000..61501cb Binary files /dev/null and b/rguistyler_v6.0_linux_x64/resources/resources/v5loxical.ttf differ diff --git a/rguistyler_v6.0_linux_x64/rguistyler b/rguistyler_v6.0_linux_x64/rguistyler new file mode 100755 index 0000000..86c3706 Binary files /dev/null and b/rguistyler_v6.0_linux_x64/rguistyler differ diff --git a/rguistyler_v6.0_linux_x64/styles/styles/style_amber.rgs b/rguistyler_v6.0_linux_x64/styles/styles/style_amber.rgs new file mode 100644 index 0000000..44d806e Binary files /dev/null and b/rguistyler_v6.0_linux_x64/styles/styles/style_amber.rgs differ diff --git a/rguistyler_v6.0_linux_x64/styles/styles/style_ashes.rgs b/rguistyler_v6.0_linux_x64/styles/styles/style_ashes.rgs new file mode 100644 index 0000000..56fb93b Binary files /dev/null and b/rguistyler_v6.0_linux_x64/styles/styles/style_ashes.rgs differ diff --git a/rguistyler_v6.0_linux_x64/styles/styles/style_bluish.rgs b/rguistyler_v6.0_linux_x64/styles/styles/style_bluish.rgs new file mode 100644 index 0000000..5a27c6e Binary files /dev/null and b/rguistyler_v6.0_linux_x64/styles/styles/style_bluish.rgs differ diff --git a/rguistyler_v6.0_linux_x64/styles/styles/style_candy.rgs b/rguistyler_v6.0_linux_x64/styles/styles/style_candy.rgs new file mode 100644 index 0000000..f016522 Binary files /dev/null and b/rguistyler_v6.0_linux_x64/styles/styles/style_candy.rgs differ diff --git a/rguistyler_v6.0_linux_x64/styles/styles/style_cherry.rgs b/rguistyler_v6.0_linux_x64/styles/styles/style_cherry.rgs new file mode 100644 index 0000000..7ef11a2 Binary files /dev/null and b/rguistyler_v6.0_linux_x64/styles/styles/style_cherry.rgs differ diff --git a/rguistyler_v6.0_linux_x64/styles/styles/style_cyber.rgs b/rguistyler_v6.0_linux_x64/styles/styles/style_cyber.rgs new file mode 100644 index 0000000..142aeee Binary files /dev/null and b/rguistyler_v6.0_linux_x64/styles/styles/style_cyber.rgs differ diff --git a/rguistyler_v6.0_linux_x64/styles/styles/style_dark.rgs b/rguistyler_v6.0_linux_x64/styles/styles/style_dark.rgs new file mode 100644 index 0000000..1e965d9 Binary files /dev/null and b/rguistyler_v6.0_linux_x64/styles/styles/style_dark.rgs differ diff --git a/rguistyler_v6.0_linux_x64/styles/styles/style_enefete.rgs b/rguistyler_v6.0_linux_x64/styles/styles/style_enefete.rgs new file mode 100644 index 0000000..7eea922 Binary files /dev/null and b/rguistyler_v6.0_linux_x64/styles/styles/style_enefete.rgs differ diff --git a/rguistyler_v6.0_linux_x64/styles/styles/style_genesis.rgs b/rguistyler_v6.0_linux_x64/styles/styles/style_genesis.rgs new file mode 100644 index 0000000..1d12f67 Binary files /dev/null and b/rguistyler_v6.0_linux_x64/styles/styles/style_genesis.rgs differ diff --git a/rguistyler_v6.0_linux_x64/styles/styles/style_jungle.rgs b/rguistyler_v6.0_linux_x64/styles/styles/style_jungle.rgs new file mode 100644 index 0000000..843867c Binary files /dev/null and b/rguistyler_v6.0_linux_x64/styles/styles/style_jungle.rgs differ diff --git a/rguistyler_v6.0_linux_x64/styles/styles/style_lavanda.rgs b/rguistyler_v6.0_linux_x64/styles/styles/style_lavanda.rgs new file mode 100644 index 0000000..1a28c1c Binary files /dev/null and b/rguistyler_v6.0_linux_x64/styles/styles/style_lavanda.rgs differ diff --git a/rguistyler_v6.0_linux_x64/styles/styles/style_rltech.rgs b/rguistyler_v6.0_linux_x64/styles/styles/style_rltech.rgs new file mode 100644 index 0000000..576d1ac Binary files /dev/null and b/rguistyler_v6.0_linux_x64/styles/styles/style_rltech.rgs differ diff --git a/rguistyler_v6.0_linux_x64/styles/styles/style_sunny.rgs b/rguistyler_v6.0_linux_x64/styles/styles/style_sunny.rgs new file mode 100644 index 0000000..5a53c50 Binary files /dev/null and b/rguistyler_v6.0_linux_x64/styles/styles/style_sunny.rgs differ diff --git a/rguistyler_v6.0_linux_x64/styles/styles/style_terminal.rgs b/rguistyler_v6.0_linux_x64/styles/styles/style_terminal.rgs new file mode 100644 index 0000000..6cea868 Binary files /dev/null and b/rguistyler_v6.0_linux_x64/styles/styles/style_terminal.rgs differ diff --git a/sketch.go b/sketch.go index 056e6ea..845b476 100644 --- a/sketch.go +++ b/sketch.go @@ -8,23 +8,39 @@ import ( type Sketch struct { sourceWidth int32 sourceHeight int32 + cam *TextureCam layerTools map[string]LayerTools layerToolsOrdered []LayerTools composite rl.RenderTexture2D } +type TextureCam struct { + LookAt rl.Vector2 + Zoom float32 +} + + func NewSketch(sourceWidth, sourceHeight int32) Sketch { + + // point at source center + // put source center at center of screen + var camera = TextureCam { + LookAt: rl.Vector2{X: float32(sourceWidth) / 2.0, Y: float32(sourceHeight) / 2.0}, + Zoom: 1.0, + } + return Sketch { sourceWidth: sourceWidth, sourceHeight: sourceHeight, layerTools: make(map[string]LayerTools), layerToolsOrdered: []LayerTools {}, composite: rl.LoadRenderTexture(sourceWidth, sourceHeight), + cam: &camera, } } -func (s *Sketch) CreateLayer(name string, layer Layer, sourceWidth int32, sourceHeight int32) { - texture := rl.LoadRenderTexture(sourceWidth, sourceHeight) +func (s *Sketch) CreateLayer(name string, layer Layer) { + texture := rl.LoadRenderTexture(s.sourceWidth, s.sourceHeight) layerTools := LayerTools { name: name, texture: &texture, @@ -80,44 +96,49 @@ func (s *Sketch) Draw(ctx *RenderCtx) { } func (s *Sketch) CalcViewport(ctx *RenderCtx) rl.Rectangle { - viewportWidth := rl.Clamp(float32(ctx.SourceWidth) / ctx.Cam.Zoom, 0, float32(ctx.SourceWidth)) - viewportHeight := rl.Clamp(float32(ctx.SourceHeight) / ctx.Cam.Zoom, 0, float32(ctx.SourceHeight)) + viewportWidth := rl.Clamp(float32(ctx.SourceWidth) / s.cam.Zoom, 0, float32(ctx.SourceWidth)) + viewportHeight := rl.Clamp(float32(ctx.SourceHeight) / s.cam.Zoom, 0, float32(ctx.SourceHeight)) return rl.Rectangle{ - X: rl.Clamp(ctx.Cam.LookAt.X - viewportWidth/2.0, 0, float32(ctx.SourceWidth)-viewportWidth), - Y: rl.Clamp(ctx.Cam.LookAt.Y - viewportHeight/2.0, 0, float32(ctx.SourceHeight)-viewportHeight), + X: rl.Clamp(s.cam.LookAt.X - viewportWidth/2.0, 0, float32(ctx.SourceWidth)-viewportWidth), + Y: rl.Clamp(s.cam.LookAt.Y - viewportHeight/2.0, 0, float32(ctx.SourceHeight)-viewportHeight), Width: float32(viewportWidth), Height: -float32(viewportHeight), } } func (s *Sketch) Update(ctx *RenderCtx) { + if rl.IsMouseButtonDown(rl.MouseRightButton) { // get mouse delta from last frame delta := rl.GetMouseDelta() // compute the amount to move scaled by the camera zoom - delta = rl.Vector2Scale(delta, -sourceScale/ctx.Cam.Zoom) + delta = rl.Vector2Scale(delta, -sourceScale/s.cam.Zoom) delta.Y = -delta.Y - ctx.Cam.LookAt = rl.Vector2Add(ctx.Cam.LookAt, delta) + s.cam.LookAt = rl.Vector2Add(s.cam.LookAt, delta) } // clamp LookAt to be somewhere on the texture - ctx.Cam.LookAt.X = rl.Clamp(ctx.Cam.LookAt.X, 0, float32(ctx.SourceWidth-1)) - ctx.Cam.LookAt.Y = rl.Clamp(ctx.Cam.LookAt.Y, 0, float32(ctx.SourceHeight-1)) + s.cam.LookAt.X = rl.Clamp(s.cam.LookAt.X, 0, float32(ctx.SourceWidth-1)) + s.cam.LookAt.Y = rl.Clamp(s.cam.LookAt.Y, 0, float32(ctx.SourceHeight-1)) // Zoom based on mouse wheel wheel := rl.GetMouseWheelMove() if wheel != 0 { const zoomIncrement float32 = 0.05 if wheel > 0 { - ctx.Cam.Zoom *= 1+zoomIncrement + s.cam.Zoom *= 1+zoomIncrement } else { - ctx.Cam.Zoom *= 1-zoomIncrement + s.cam.Zoom *= 1-zoomIncrement } } // clamp zoom to > 1 so we don't ever zoom out more than necessary - ctx.Cam.Zoom = rl.Clamp(ctx.Cam.Zoom, 1, math.MaxInt64) + s.cam.Zoom = rl.Clamp(s.cam.Zoom, 1, math.MaxInt64) +} +func (s *Sketch) ResetCamera() { + s.cam.LookAt = rl.Vector2{X: float32(s.sourceWidth) / 2.0, Y: float32(s.sourceHeight) / 2.0} + s.cam.Zoom = 1.0 } type SketchCapture struct { @@ -218,5 +239,4 @@ type RenderCtx struct { SourceHeight int32 Time float64 Ports map[string]float64 - Cam *TextureCam }