automated snapshot
This commit is contained in:
120
contour_layer.go
Normal file
120
contour_layer.go
Normal file
@@ -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)
|
||||||
|
}
|
||||||
|
|
||||||
6
flake.lock
generated
6
flake.lock
generated
@@ -20,11 +20,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1765363881,
|
"lastModified": 1766014764,
|
||||||
"narHash": "sha256-3C3xWn8/2Zzr7sxVBmpc1H1QfxjNfta5IMFe3O9ZEPw=",
|
"narHash": "sha256-+73VffE5GP5fvbib6Hs1Su6LehG+9UV1Kzs90T2gBLA=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "d2b1213bf5ec5e62d96b003ab4b5cbc42abfc0d0",
|
"rev": "2b0d2b456e4e8452cf1c16d00118d145f31160f9",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|||||||
150
main.go
150
main.go
@@ -3,7 +3,6 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"math"
|
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
@@ -19,13 +18,6 @@ const (
|
|||||||
snapshotsDir = "snapshots"
|
snapshotsDir = "snapshots"
|
||||||
)
|
)
|
||||||
|
|
||||||
type TextureCam struct {
|
|
||||||
SourceWidth int32
|
|
||||||
SourceHeight int32
|
|
||||||
LookAt rl.Vector2
|
|
||||||
Zoom float32
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
sourceWidth := int32(sourceScale * targetWidth)
|
sourceWidth := int32(sourceScale * targetWidth)
|
||||||
@@ -42,15 +34,6 @@ func main() {
|
|||||||
rl.SetConfigFlags(rl.FlagMsaa4xHint)
|
rl.SetConfigFlags(rl.FlagMsaa4xHint)
|
||||||
rl.InitWindow(targetWidth, targetHeight, "sumi sierpinski arrow")
|
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)
|
rl.SetTargetFPS(60)
|
||||||
t0 := time.Now()
|
t0 := time.Now()
|
||||||
|
|
||||||
@@ -70,16 +53,17 @@ func main() {
|
|||||||
}
|
}
|
||||||
rng := rand.New(rand.NewSource(0))
|
rng := rand.New(rand.NewSource(0))
|
||||||
|
|
||||||
contourLayer := NewContourLayer(rng, &field, sourceWidth, sourceHeight)
|
|
||||||
|
|
||||||
sketch := NewSketch(sourceWidth, sourceHeight)
|
sketch := NewSketch(sourceWidth, sourceHeight)
|
||||||
|
|
||||||
|
contourLayer := NewContourLayer(&sketch, rng, &field)
|
||||||
//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)
|
||||||
|
|
||||||
ports := MakePorts()
|
ports := MakePorts()
|
||||||
ports["sierpinskiArrowAngle"] = Sine{
|
ports["sierpinskiArrowAngle"] = Sine {
|
||||||
Amp: 120,
|
Amp: 120,
|
||||||
Bias: 100,
|
Bias: 100,
|
||||||
Freq: 0.1,
|
Freq: 0.1,
|
||||||
@@ -98,7 +82,6 @@ func main() {
|
|||||||
SourceHeight: int32(sourceHeight),
|
SourceHeight: int32(sourceHeight),
|
||||||
Time: t,
|
Time: t,
|
||||||
Ports: ports.Eval(t),
|
Ports: ports.Eval(t),
|
||||||
Cam: &camera,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sketch.Update(renderCtx)
|
sketch.Update(renderCtx)
|
||||||
@@ -125,10 +108,10 @@ func main() {
|
|||||||
for ch := rl.GetCharPressed(); ch != 0; ch = rl.GetCharPressed() {
|
for ch := rl.GetCharPressed(); ch != 0; ch = rl.GetCharPressed() {
|
||||||
c := rune(ch)
|
c := rune(ch)
|
||||||
if c == 'c' {
|
if c == 'c' {
|
||||||
resetCamera(&camera)
|
sketch.ResetCamera()
|
||||||
} 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)
|
sketch.cam.Zoom = float32(zoom)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,11 +123,6 @@ func main() {
|
|||||||
rl.CloseWindow()
|
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 {
|
type FieldLayer struct {
|
||||||
field Field
|
field Field
|
||||||
dirty bool
|
dirty bool
|
||||||
@@ -169,122 +147,6 @@ func (s *FieldLayer) IsDirty() bool {
|
|||||||
return s.dirty
|
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{}
|
type SierpinskiArrow struct{}
|
||||||
|
|
||||||
func (s *SierpinskiArrow) Draw(ctx *RenderCtx) {
|
func (s *SierpinskiArrow) Draw(ctx *RenderCtx) {
|
||||||
|
|||||||
BIN
rguistyler_v6.0_linux_x64.zip
Normal file
BIN
rguistyler_v6.0_linux_x64.zip
Normal file
Binary file not shown.
18
rguistyler_v6.0_linux_x64/LICENSE
Normal file
18
rguistyler_v6.0_linux_x64/LICENSE
Normal file
@@ -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.
|
||||||
58
rguistyler_v6.0_linux_x64/README.md
Normal file
58
rguistyler_v6.0_linux_x64/README.md
Normal file
@@ -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
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## 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))*
|
||||||
BIN
rguistyler_v6.0_linux_x64/resources/resources/2a03.ttf
Normal file
BIN
rguistyler_v6.0_linux_x64/resources/resources/2a03.ttf
Normal file
Binary file not shown.
BIN
rguistyler_v6.0_linux_x64/resources/resources/Cartridge.ttf
Normal file
BIN
rguistyler_v6.0_linux_x64/resources/resources/Cartridge.ttf
Normal file
Binary file not shown.
BIN
rguistyler_v6.0_linux_x64/resources/resources/CozetteVector.otf
Normal file
BIN
rguistyler_v6.0_linux_x64/resources/resources/CozetteVector.otf
Normal file
Binary file not shown.
BIN
rguistyler_v6.0_linux_x64/resources/resources/Fairfax.ttf
Normal file
BIN
rguistyler_v6.0_linux_x64/resources/resources/Fairfax.ttf
Normal file
Binary file not shown.
BIN
rguistyler_v6.0_linux_x64/resources/resources/GMSN.ttf
Normal file
BIN
rguistyler_v6.0_linux_x64/resources/resources/GMSN.ttf
Normal file
Binary file not shown.
BIN
rguistyler_v6.0_linux_x64/resources/resources/Kyrou7Wide.ttf
Normal file
BIN
rguistyler_v6.0_linux_x64/resources/resources/Kyrou7Wide.ttf
Normal file
Binary file not shown.
23
rguistyler_v6.0_linux_x64/resources/resources/LICENSES.md
Normal file
23
rguistyler_v6.0_linux_x64/resources/resources/LICENSES.md
Normal file
@@ -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!
|
||||||
BIN
rguistyler_v6.0_linux_x64/resources/resources/Mecha.ttf
Normal file
BIN
rguistyler_v6.0_linux_x64/resources/resources/Mecha.ttf
Normal file
Binary file not shown.
BIN
rguistyler_v6.0_linux_x64/resources/resources/OwreKynge.ttf
Normal file
BIN
rguistyler_v6.0_linux_x64/resources/resources/OwreKynge.ttf
Normal file
Binary file not shown.
BIN
rguistyler_v6.0_linux_x64/resources/resources/PixelIntv.otf
Normal file
BIN
rguistyler_v6.0_linux_x64/resources/resources/PixelIntv.otf
Normal file
Binary file not shown.
BIN
rguistyler_v6.0_linux_x64/resources/resources/PixelOperator.ttf
Normal file
BIN
rguistyler_v6.0_linux_x64/resources/resources/PixelOperator.ttf
Normal file
Binary file not shown.
BIN
rguistyler_v6.0_linux_x64/resources/resources/Westington.ttf
Normal file
BIN
rguistyler_v6.0_linux_x64/resources/resources/Westington.ttf
Normal file
Binary file not shown.
BIN
rguistyler_v6.0_linux_x64/resources/resources/hello-world.ttf
Normal file
BIN
rguistyler_v6.0_linux_x64/resources/resources/hello-world.ttf
Normal file
Binary file not shown.
BIN
rguistyler_v6.0_linux_x64/resources/resources/homespun.ttf
Normal file
BIN
rguistyler_v6.0_linux_x64/resources/resources/homespun.ttf
Normal file
Binary file not shown.
BIN
rguistyler_v6.0_linux_x64/resources/resources/v5easter.ttf
Normal file
BIN
rguistyler_v6.0_linux_x64/resources/resources/v5easter.ttf
Normal file
Binary file not shown.
BIN
rguistyler_v6.0_linux_x64/resources/resources/v5loxical.ttf
Normal file
BIN
rguistyler_v6.0_linux_x64/resources/resources/v5loxical.ttf
Normal file
Binary file not shown.
BIN
rguistyler_v6.0_linux_x64/rguistyler
Executable file
BIN
rguistyler_v6.0_linux_x64/rguistyler
Executable file
Binary file not shown.
BIN
rguistyler_v6.0_linux_x64/styles/styles/style_amber.rgs
Normal file
BIN
rguistyler_v6.0_linux_x64/styles/styles/style_amber.rgs
Normal file
Binary file not shown.
BIN
rguistyler_v6.0_linux_x64/styles/styles/style_ashes.rgs
Normal file
BIN
rguistyler_v6.0_linux_x64/styles/styles/style_ashes.rgs
Normal file
Binary file not shown.
BIN
rguistyler_v6.0_linux_x64/styles/styles/style_bluish.rgs
Normal file
BIN
rguistyler_v6.0_linux_x64/styles/styles/style_bluish.rgs
Normal file
Binary file not shown.
BIN
rguistyler_v6.0_linux_x64/styles/styles/style_candy.rgs
Normal file
BIN
rguistyler_v6.0_linux_x64/styles/styles/style_candy.rgs
Normal file
Binary file not shown.
BIN
rguistyler_v6.0_linux_x64/styles/styles/style_cherry.rgs
Normal file
BIN
rguistyler_v6.0_linux_x64/styles/styles/style_cherry.rgs
Normal file
Binary file not shown.
BIN
rguistyler_v6.0_linux_x64/styles/styles/style_cyber.rgs
Normal file
BIN
rguistyler_v6.0_linux_x64/styles/styles/style_cyber.rgs
Normal file
Binary file not shown.
BIN
rguistyler_v6.0_linux_x64/styles/styles/style_dark.rgs
Normal file
BIN
rguistyler_v6.0_linux_x64/styles/styles/style_dark.rgs
Normal file
Binary file not shown.
BIN
rguistyler_v6.0_linux_x64/styles/styles/style_enefete.rgs
Normal file
BIN
rguistyler_v6.0_linux_x64/styles/styles/style_enefete.rgs
Normal file
Binary file not shown.
BIN
rguistyler_v6.0_linux_x64/styles/styles/style_genesis.rgs
Normal file
BIN
rguistyler_v6.0_linux_x64/styles/styles/style_genesis.rgs
Normal file
Binary file not shown.
BIN
rguistyler_v6.0_linux_x64/styles/styles/style_jungle.rgs
Normal file
BIN
rguistyler_v6.0_linux_x64/styles/styles/style_jungle.rgs
Normal file
Binary file not shown.
BIN
rguistyler_v6.0_linux_x64/styles/styles/style_lavanda.rgs
Normal file
BIN
rguistyler_v6.0_linux_x64/styles/styles/style_lavanda.rgs
Normal file
Binary file not shown.
BIN
rguistyler_v6.0_linux_x64/styles/styles/style_rltech.rgs
Normal file
BIN
rguistyler_v6.0_linux_x64/styles/styles/style_rltech.rgs
Normal file
Binary file not shown.
BIN
rguistyler_v6.0_linux_x64/styles/styles/style_sunny.rgs
Normal file
BIN
rguistyler_v6.0_linux_x64/styles/styles/style_sunny.rgs
Normal file
Binary file not shown.
BIN
rguistyler_v6.0_linux_x64/styles/styles/style_terminal.rgs
Normal file
BIN
rguistyler_v6.0_linux_x64/styles/styles/style_terminal.rgs
Normal file
Binary file not shown.
48
sketch.go
48
sketch.go
@@ -8,23 +8,39 @@ import (
|
|||||||
type Sketch struct {
|
type Sketch struct {
|
||||||
sourceWidth int32
|
sourceWidth int32
|
||||||
sourceHeight int32
|
sourceHeight int32
|
||||||
|
cam *TextureCam
|
||||||
layerTools map[string]LayerTools
|
layerTools map[string]LayerTools
|
||||||
layerToolsOrdered []LayerTools
|
layerToolsOrdered []LayerTools
|
||||||
composite rl.RenderTexture2D
|
composite rl.RenderTexture2D
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type TextureCam struct {
|
||||||
|
LookAt rl.Vector2
|
||||||
|
Zoom float32
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
func NewSketch(sourceWidth, sourceHeight int32) Sketch {
|
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 {
|
return Sketch {
|
||||||
sourceWidth: sourceWidth,
|
sourceWidth: sourceWidth,
|
||||||
sourceHeight: sourceHeight,
|
sourceHeight: sourceHeight,
|
||||||
layerTools: make(map[string]LayerTools),
|
layerTools: make(map[string]LayerTools),
|
||||||
layerToolsOrdered: []LayerTools {},
|
layerToolsOrdered: []LayerTools {},
|
||||||
composite: rl.LoadRenderTexture(sourceWidth, sourceHeight),
|
composite: rl.LoadRenderTexture(sourceWidth, sourceHeight),
|
||||||
|
cam: &camera,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Sketch) CreateLayer(name string, layer Layer, sourceWidth int32, sourceHeight int32) {
|
func (s *Sketch) CreateLayer(name string, layer Layer) {
|
||||||
texture := rl.LoadRenderTexture(sourceWidth, sourceHeight)
|
texture := rl.LoadRenderTexture(s.sourceWidth, s.sourceHeight)
|
||||||
layerTools := LayerTools {
|
layerTools := LayerTools {
|
||||||
name: name,
|
name: name,
|
||||||
texture: &texture,
|
texture: &texture,
|
||||||
@@ -80,44 +96,49 @@ func (s *Sketch) Draw(ctx *RenderCtx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Sketch) CalcViewport(ctx *RenderCtx) rl.Rectangle {
|
func (s *Sketch) CalcViewport(ctx *RenderCtx) rl.Rectangle {
|
||||||
viewportWidth := rl.Clamp(float32(ctx.SourceWidth) / ctx.Cam.Zoom, 0, float32(ctx.SourceWidth))
|
viewportWidth := rl.Clamp(float32(ctx.SourceWidth) / s.cam.Zoom, 0, float32(ctx.SourceWidth))
|
||||||
viewportHeight := rl.Clamp(float32(ctx.SourceHeight) / ctx.Cam.Zoom, 0, float32(ctx.SourceHeight))
|
viewportHeight := rl.Clamp(float32(ctx.SourceHeight) / s.cam.Zoom, 0, float32(ctx.SourceHeight))
|
||||||
return rl.Rectangle{
|
return rl.Rectangle{
|
||||||
X: rl.Clamp(ctx.Cam.LookAt.X - viewportWidth/2.0, 0, float32(ctx.SourceWidth)-viewportWidth),
|
X: rl.Clamp(s.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),
|
Y: rl.Clamp(s.cam.LookAt.Y - viewportHeight/2.0, 0, float32(ctx.SourceHeight)-viewportHeight),
|
||||||
Width: float32(viewportWidth),
|
Width: float32(viewportWidth),
|
||||||
Height: -float32(viewportHeight),
|
Height: -float32(viewportHeight),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Sketch) Update(ctx *RenderCtx) {
|
func (s *Sketch) Update(ctx *RenderCtx) {
|
||||||
|
|
||||||
if rl.IsMouseButtonDown(rl.MouseRightButton) {
|
if rl.IsMouseButtonDown(rl.MouseRightButton) {
|
||||||
// get mouse delta from last frame
|
// get mouse delta from last frame
|
||||||
delta := rl.GetMouseDelta()
|
delta := rl.GetMouseDelta()
|
||||||
// compute the amount to move scaled by the camera zoom
|
// 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
|
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
|
// clamp LookAt to be somewhere on the texture
|
||||||
ctx.Cam.LookAt.X = rl.Clamp(ctx.Cam.LookAt.X, 0, float32(ctx.SourceWidth-1))
|
s.cam.LookAt.X = rl.Clamp(s.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.Y = rl.Clamp(s.cam.LookAt.Y, 0, float32(ctx.SourceHeight-1))
|
||||||
|
|
||||||
// Zoom based on mouse wheel
|
// Zoom based on mouse wheel
|
||||||
wheel := rl.GetMouseWheelMove()
|
wheel := rl.GetMouseWheelMove()
|
||||||
if wheel != 0 {
|
if wheel != 0 {
|
||||||
const zoomIncrement float32 = 0.05
|
const zoomIncrement float32 = 0.05
|
||||||
if wheel > 0 {
|
if wheel > 0 {
|
||||||
ctx.Cam.Zoom *= 1+zoomIncrement
|
s.cam.Zoom *= 1+zoomIncrement
|
||||||
} else {
|
} 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
|
// 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 {
|
type SketchCapture struct {
|
||||||
@@ -218,5 +239,4 @@ type RenderCtx struct {
|
|||||||
SourceHeight int32
|
SourceHeight int32
|
||||||
Time float64
|
Time float64
|
||||||
Ports map[string]float64
|
Ports map[string]float64
|
||||||
Cam *TextureCam
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user