mirror of
https://github.com/Fluffy-Bean/ColouringApp.git
synced 2025-05-14 07:32:16 +00:00
urgh
This commit is contained in:
parent
a2c0d9d825
commit
be4c6c7fcf
6 changed files with 143 additions and 75 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -4,3 +4,5 @@
|
||||||
|
|
||||||
# Remove Enviroment Variables
|
# Remove Enviroment Variables
|
||||||
.env
|
.env
|
||||||
|
|
||||||
|
userData
|
|
@ -21,6 +21,8 @@ type Toast struct {
|
||||||
func AddToast(text string) {
|
func AddToast(text string) {
|
||||||
toast := Toast{Text: text, Age: time.Now()}
|
toast := Toast{Text: text, Age: time.Now()}
|
||||||
toasts = append(toasts, toast)
|
toasts = append(toasts, toast)
|
||||||
|
|
||||||
|
fmt.Printf("Added Toast: '%s'\n", text)
|
||||||
}
|
}
|
||||||
|
|
||||||
func UpdateToasts() {
|
func UpdateToasts() {
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -5,9 +5,11 @@ go 1.21.5
|
||||||
require (
|
require (
|
||||||
github.com/gen2brain/raylib-go/raygui v0.0.0-20240110102818-483e94e4d92e
|
github.com/gen2brain/raylib-go/raygui v0.0.0-20240110102818-483e94e4d92e
|
||||||
github.com/gen2brain/raylib-go/raylib v0.0.0-20240110102818-483e94e4d92e
|
github.com/gen2brain/raylib-go/raylib v0.0.0-20240110102818-483e94e4d92e
|
||||||
|
github.com/huandu/go-sqlbuilder v1.25.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/ebitengine/purego v0.6.0-alpha.1.0.20231122024802-192c5e846faa // indirect
|
github.com/ebitengine/purego v0.6.0-alpha.1.0.20231122024802-192c5e846faa // indirect
|
||||||
|
github.com/huandu/xstrings v1.3.2 // indirect
|
||||||
golang.org/x/sys v0.14.0 // indirect
|
golang.org/x/sys v0.14.0 // indirect
|
||||||
)
|
)
|
||||||
|
|
14
go.sum
14
go.sum
|
@ -1,8 +1,22 @@
|
||||||
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/ebitengine/purego v0.6.0-alpha.1.0.20231122024802-192c5e846faa h1:Ik7QikRgeH+bFOfAcMpttCbs6XxWXxCLXMm4awxtOXk=
|
github.com/ebitengine/purego v0.6.0-alpha.1.0.20231122024802-192c5e846faa h1:Ik7QikRgeH+bFOfAcMpttCbs6XxWXxCLXMm4awxtOXk=
|
||||||
github.com/ebitengine/purego v0.6.0-alpha.1.0.20231122024802-192c5e846faa/go.mod h1:ah1In8AOtksoNK6yk5z1HTJeUkC1Ez4Wk2idgGslMwQ=
|
github.com/ebitengine/purego v0.6.0-alpha.1.0.20231122024802-192c5e846faa/go.mod h1:ah1In8AOtksoNK6yk5z1HTJeUkC1Ez4Wk2idgGslMwQ=
|
||||||
github.com/gen2brain/raylib-go/raygui v0.0.0-20240110102818-483e94e4d92e h1:rbZ3Fy7hRHL/GLcm9sCt3N2tjTPGT9EwGwvVHTuVnJQ=
|
github.com/gen2brain/raylib-go/raygui v0.0.0-20240110102818-483e94e4d92e h1:rbZ3Fy7hRHL/GLcm9sCt3N2tjTPGT9EwGwvVHTuVnJQ=
|
||||||
github.com/gen2brain/raylib-go/raygui v0.0.0-20240110102818-483e94e4d92e/go.mod h1:Ra1zgJP7vnGst+STvzPPiVJhjicklFWONCz5nu6MnOM=
|
github.com/gen2brain/raylib-go/raygui v0.0.0-20240110102818-483e94e4d92e/go.mod h1:Ra1zgJP7vnGst+STvzPPiVJhjicklFWONCz5nu6MnOM=
|
||||||
github.com/gen2brain/raylib-go/raylib v0.0.0-20240110102818-483e94e4d92e h1:t/kVA/quBlzLB+43QzIsHkFQrZs2ii79rk9NOofbQxs=
|
github.com/gen2brain/raylib-go/raylib v0.0.0-20240110102818-483e94e4d92e h1:t/kVA/quBlzLB+43QzIsHkFQrZs2ii79rk9NOofbQxs=
|
||||||
github.com/gen2brain/raylib-go/raylib v0.0.0-20240110102818-483e94e4d92e/go.mod h1:P/hDjVwz/9fhR0ww3+umzDpDA7Bf7Tce4xNChHIEFqE=
|
github.com/gen2brain/raylib-go/raylib v0.0.0-20240110102818-483e94e4d92e/go.mod h1:P/hDjVwz/9fhR0ww3+umzDpDA7Bf7Tce4xNChHIEFqE=
|
||||||
|
github.com/huandu/go-assert v1.1.5 h1:fjemmA7sSfYHJD7CUqs9qTwwfdNAx7/j2/ZlHXzNB3c=
|
||||||
|
github.com/huandu/go-assert v1.1.5/go.mod h1:yOLvuqZwmcHIC5rIzrBhT7D3Q9c3GFnd0JrPVhn/06U=
|
||||||
|
github.com/huandu/go-sqlbuilder v1.25.0 h1:h1l+6CqeCviPJCnkEZoRGNdfZ5RO9BKMvG3A+1VuKNM=
|
||||||
|
github.com/huandu/go-sqlbuilder v1.25.0/go.mod h1:nUVmMitjOmn/zacMLXT0d3Yd3RHoO2K+vy906JzqxMI=
|
||||||
|
github.com/huandu/xstrings v1.3.2 h1:L18LIDzqlW6xN2rEkpdV8+oL/IXWJ1APd+vsdYy4Wdw=
|
||||||
|
github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||||
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
|
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
|
||||||
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
|
|
@ -12,18 +12,27 @@ const (
|
||||||
ModeLine
|
ModeLine
|
||||||
)
|
)
|
||||||
|
|
||||||
type stroke struct {
|
type freeHand struct {
|
||||||
Color raylib.Color
|
Color raylib.Color
|
||||||
Size float32
|
Size float32
|
||||||
Points []raylib.Vector2
|
Opacity float32
|
||||||
|
Points []raylib.Vector2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//type line struct {
|
||||||
|
// Color raylib.Color
|
||||||
|
// Size float32
|
||||||
|
// Start raylib.Vector2
|
||||||
|
// End raylib.Vector2
|
||||||
|
//}
|
||||||
|
|
||||||
func Drawing() {
|
func Drawing() {
|
||||||
var (
|
var (
|
||||||
camera = raylib.NewCamera2D(raylib.NewVector2(0, 0), raylib.NewVector2(0, 0), 0, 1)
|
camera = raylib.NewCamera2D(raylib.NewVector2(0, 0), raylib.NewVector2(0, 0), 0, 1)
|
||||||
//cameraMoveOffset = raylib.NewVector2(10, 10)
|
//cameraMoveOffset = raylib.NewVector2(10, 10)
|
||||||
|
|
||||||
canvasSize = raylib.NewVector2(500, 430)
|
canvasSize = raylib.NewVector2(500, 430)
|
||||||
|
canvasScale = float32(1)
|
||||||
canvas = raylib.LoadRenderTexture(int32(canvasSize.X), int32(canvasSize.Y))
|
canvas = raylib.LoadRenderTexture(int32(canvasSize.X), int32(canvasSize.Y))
|
||||||
canvasRefresh = true
|
canvasRefresh = true
|
||||||
|
|
||||||
|
@ -33,19 +42,23 @@ func Drawing() {
|
||||||
drawing = false
|
drawing = false
|
||||||
//drawingMode = ModeDrawing
|
//drawingMode = ModeDrawing
|
||||||
|
|
||||||
currentStroke = stroke{}
|
currentStroke = freeHand{}
|
||||||
strokes = []stroke{currentStroke}
|
strokes = []freeHand{currentStroke}
|
||||||
undoneStrokes = []stroke{}
|
undoneStrokes = []freeHand{}
|
||||||
|
|
||||||
colourPickerVal = raylib.Orange
|
colourPickerVal = raylib.Orange
|
||||||
colourPickerHeight = float32(200)
|
colourPickerHeight = float32(200)
|
||||||
|
|
||||||
brushSize = float32(10)
|
brushSize = float32(10)
|
||||||
|
brushOpacity = float32(1)
|
||||||
|
|
||||||
fileName = "NewProject"
|
fileName = "NewProject"
|
||||||
fileNameEditing = false
|
fileNameEditing = false
|
||||||
)
|
)
|
||||||
|
|
||||||
|
application.WindowWidth = int32(raylib.GetScreenWidth())
|
||||||
|
application.WindowHeight = int32(raylib.GetScreenHeight())
|
||||||
|
|
||||||
refreshCanvas := func() {
|
refreshCanvas := func() {
|
||||||
raylib.BeginTextureMode(canvas)
|
raylib.BeginTextureMode(canvas)
|
||||||
raylib.ClearBackground(raylib.White)
|
raylib.ClearBackground(raylib.White)
|
||||||
|
@ -54,34 +67,32 @@ func Drawing() {
|
||||||
for j := 1; j < len(strokes[i].Points); j++ {
|
for j := 1; j < len(strokes[i].Points); j++ {
|
||||||
startPos := raylib.Vector2Subtract(strokes[i].Points[j-1], raylib.NewVector2(10, 10))
|
startPos := raylib.Vector2Subtract(strokes[i].Points[j-1], raylib.NewVector2(10, 10))
|
||||||
endPos := raylib.Vector2Subtract(strokes[i].Points[j], raylib.NewVector2(10, 10))
|
endPos := raylib.Vector2Subtract(strokes[i].Points[j], raylib.NewVector2(10, 10))
|
||||||
raylib.DrawLineEx(startPos, endPos, strokes[i].Size, strokes[i].Color)
|
raylib.DrawLineEx(startPos, endPos, strokes[i].Size, raylib.Fade(strokes[i].Color, strokes[i].Opacity))
|
||||||
raylib.DrawCircle(int32(endPos.X), int32(endPos.Y), strokes[i].Size/2, strokes[i].Color)
|
raylib.DrawCircle(int32(endPos.X), int32(endPos.Y), strokes[i].Size/2, raylib.Fade(strokes[i].Color, strokes[i].Opacity))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
raylib.EndTextureMode()
|
raylib.EndTextureMode()
|
||||||
}
|
}
|
||||||
|
|
||||||
undoStroke := func() {
|
redoStroke := func() {
|
||||||
fmt.Println("Undo")
|
|
||||||
|
|
||||||
if len(undoneStrokes) > 0 {
|
if len(undoneStrokes) > 0 {
|
||||||
strokes = append(strokes, undoneStrokes[len(undoneStrokes)-1])
|
strokes = append(strokes, undoneStrokes[len(undoneStrokes)-1])
|
||||||
undoneStrokes = undoneStrokes[:len(undoneStrokes)-1]
|
undoneStrokes = undoneStrokes[:len(undoneStrokes)-1]
|
||||||
|
|
||||||
|
application.AddToast("Redo")
|
||||||
|
canvasRefresh = true
|
||||||
}
|
}
|
||||||
|
|
||||||
canvasRefresh = true
|
|
||||||
}
|
}
|
||||||
redoStroke := func() {
|
undoStroke := func() {
|
||||||
fmt.Println("Redo")
|
|
||||||
|
|
||||||
// 1 because I dont know why
|
// 1 because I dont know why
|
||||||
if len(strokes) > 1 {
|
if len(strokes) > 1 {
|
||||||
undoneStrokes = append(undoneStrokes, strokes[len(strokes)-1])
|
undoneStrokes = append(undoneStrokes, strokes[len(strokes)-1])
|
||||||
strokes = strokes[:len(strokes)-1]
|
strokes = strokes[:len(strokes)-1]
|
||||||
}
|
|
||||||
|
|
||||||
canvasRefresh = true
|
canvasRefresh = true
|
||||||
|
application.AddToast("Undo")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
saveImage := func() {
|
saveImage := func() {
|
||||||
|
@ -116,9 +127,9 @@ func Drawing() {
|
||||||
|
|
||||||
// INPUT
|
// INPUT
|
||||||
{
|
{
|
||||||
//if raylib.GetMouseWheelMove() != 0 {
|
if raylib.GetMouseWheelMove() != 0 && !drawing {
|
||||||
// camera.Zoom += float32(raylib.GetMouseWheelMove()) * 0.05
|
canvasScale += float32(raylib.GetMouseWheelMove()) * 0.05
|
||||||
//}
|
}
|
||||||
//if raylib.IsMouseButtonPressed(raylib.MouseMiddleButton) {
|
//if raylib.IsMouseButtonPressed(raylib.MouseMiddleButton) {
|
||||||
// cameraMoveOffset = raylib.Vector2Subtract(camera.Target, raylib.GetMousePosition())
|
// cameraMoveOffset = raylib.Vector2Subtract(camera.Target, raylib.GetMousePosition())
|
||||||
//}
|
//}
|
||||||
|
@ -135,9 +146,10 @@ func Drawing() {
|
||||||
drawing = false
|
drawing = false
|
||||||
} else if raylib.CheckCollisionPointRec(raylib.GetMousePosition(), raylib.NewRectangle(10, 10, canvasSize.X, canvasSize.Y)) {
|
} else if raylib.CheckCollisionPointRec(raylib.GetMousePosition(), raylib.NewRectangle(10, 10, canvasSize.X, canvasSize.Y)) {
|
||||||
drawing = true
|
drawing = true
|
||||||
currentStroke = stroke{
|
currentStroke = freeHand{
|
||||||
Color: colourPickerVal,
|
Color: colourPickerVal,
|
||||||
Size: brushSize,
|
Size: brushSize,
|
||||||
|
Opacity: 1,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -151,19 +163,18 @@ func Drawing() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if raylib.IsMouseButtonReleased(raylib.MouseLeftButton) && currentStroke.Points != nil {
|
if raylib.IsMouseButtonReleased(raylib.MouseLeftButton) && currentStroke.Points != nil {
|
||||||
drawing = false
|
|
||||||
|
|
||||||
strokes = append(strokes, currentStroke)
|
strokes = append(strokes, currentStroke)
|
||||||
currentStroke = stroke{}
|
currentStroke = freeHand{}
|
||||||
undoneStrokes = []stroke{}
|
undoneStrokes = []freeHand{}
|
||||||
|
|
||||||
|
drawing = false
|
||||||
canvasRefresh = true
|
canvasRefresh = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if raylib.IsKeyDown(raylib.KeyLeftControl) && raylib.IsKeyDown(raylib.KeyLeftShift) && raylib.IsKeyPressed(raylib.KeyZ) {
|
if raylib.IsKeyDown(raylib.KeyLeftControl) && raylib.IsKeyDown(raylib.KeyLeftShift) && raylib.IsKeyPressed(raylib.KeyZ) {
|
||||||
undoStroke()
|
|
||||||
} else if raylib.IsKeyDown(raylib.KeyLeftControl) && raylib.IsKeyPressed(raylib.KeyZ) {
|
|
||||||
redoStroke()
|
redoStroke()
|
||||||
|
} else if raylib.IsKeyDown(raylib.KeyLeftControl) && raylib.IsKeyPressed(raylib.KeyZ) {
|
||||||
|
undoStroke()
|
||||||
} else if raylib.IsKeyDown(raylib.KeyLeftControl) && raylib.IsKeyPressed(raylib.KeyS) {
|
} else if raylib.IsKeyDown(raylib.KeyLeftControl) && raylib.IsKeyPressed(raylib.KeyS) {
|
||||||
saveImage()
|
saveImage()
|
||||||
}
|
}
|
||||||
|
@ -197,20 +208,20 @@ func Drawing() {
|
||||||
raylib.DrawRectangle(20, 20, int32(canvasSize.X), int32(canvasSize.Y), raylib.Fade(raylib.Black, 0.3))
|
raylib.DrawRectangle(20, 20, int32(canvasSize.X), int32(canvasSize.Y), raylib.Fade(raylib.Black, 0.3))
|
||||||
raylib.DrawTexturePro(canvas.Texture, raylib.NewRectangle(0, 0, float32(canvas.Texture.Width), float32(-canvas.Texture.Height)), raylib.NewRectangle(10, 10, canvasSize.X, canvasSize.Y), raylib.Vector2{}, 0, raylib.White)
|
raylib.DrawTexturePro(canvas.Texture, raylib.NewRectangle(0, 0, float32(canvas.Texture.Width), float32(-canvas.Texture.Height)), raylib.NewRectangle(10, 10, canvasSize.X, canvasSize.Y), raylib.Vector2{}, 0, raylib.White)
|
||||||
|
|
||||||
|
//raylib.BeginScissorMode(10, 10, int32(canvasSize.X), int32(canvasSize.Y))
|
||||||
|
for i := 1; i < len(currentStroke.Points); i++ {
|
||||||
|
raylib.DrawLineEx(currentStroke.Points[i-1], currentStroke.Points[i], currentStroke.Size, raylib.Fade(currentStroke.Color, currentStroke.Opacity))
|
||||||
|
raylib.DrawCircle(int32(currentStroke.Points[i].X), int32(currentStroke.Points[i].Y), currentStroke.Size/2, raylib.Fade(currentStroke.Color, currentStroke.Opacity))
|
||||||
|
}
|
||||||
|
//raylib.EndScissorMode()
|
||||||
|
|
||||||
if drawing {
|
if drawing {
|
||||||
raylib.DrawRectangleLines(10, 10, int32(canvasSize.X), int32(canvasSize.Y), raylib.DarkGray)
|
raylib.DrawRectangleLines(10, 10, int32(canvasSize.X), int32(canvasSize.Y), raylib.DarkGray)
|
||||||
|
raylib.DrawCircleLines(int32(raylib.GetMousePosition().X), int32(raylib.GetMousePosition().Y), brushSize/2, raylib.Black)
|
||||||
} else {
|
} else {
|
||||||
raylib.DrawRectangleLines(10, 10, int32(canvasSize.X), int32(canvasSize.Y), raylib.Gray)
|
raylib.DrawRectangleLines(10, 10, int32(canvasSize.X), int32(canvasSize.Y), raylib.Gray)
|
||||||
|
raylib.DrawCircleLines(int32(raylib.GetMousePosition().X), int32(raylib.GetMousePosition().Y), brushSize/2, raylib.Black)
|
||||||
}
|
}
|
||||||
|
|
||||||
raylib.BeginScissorMode(10, 10, int32(canvasSize.X), int32(canvasSize.Y))
|
|
||||||
for i := 1; i < len(currentStroke.Points); i++ {
|
|
||||||
raylib.DrawLineEx(currentStroke.Points[i-1], currentStroke.Points[i], currentStroke.Size, currentStroke.Color)
|
|
||||||
raylib.DrawCircle(int32(currentStroke.Points[i].X), int32(currentStroke.Points[i].Y), currentStroke.Size/2, currentStroke.Color)
|
|
||||||
}
|
|
||||||
raylib.EndScissorMode()
|
|
||||||
|
|
||||||
raylib.DrawCircleLines(int32(raylib.GetMousePosition().X), int32(raylib.GetMousePosition().Y), brushSize/2, raylib.Black)
|
|
||||||
}
|
}
|
||||||
raylib.EndMode2D()
|
raylib.EndMode2D()
|
||||||
|
|
||||||
|
@ -226,21 +237,23 @@ func Drawing() {
|
||||||
saveImage()
|
saveImage()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stupid arrows are inverted
|
|
||||||
if gui.Button(raylib.NewRectangle(float32(application.WindowWidth-70), 10, 25, 25), gui.IconText(gui.ICON_UNDO, "")) {
|
if gui.Button(raylib.NewRectangle(float32(application.WindowWidth-70), 10, 25, 25), gui.IconText(gui.ICON_UNDO, "")) {
|
||||||
redoStroke()
|
|
||||||
}
|
|
||||||
if gui.Button(raylib.NewRectangle(float32(application.WindowWidth-35), 10, 25, 25), gui.IconText(gui.ICON_REDO, "")) {
|
|
||||||
undoStroke()
|
undoStroke()
|
||||||
}
|
}
|
||||||
|
if gui.Button(raylib.NewRectangle(float32(application.WindowWidth-35), 10, 25, 25), gui.IconText(gui.ICON_REDO, "")) {
|
||||||
|
redoStroke()
|
||||||
|
}
|
||||||
|
|
||||||
colourPickerVal = gui.ColorPicker(raylib.NewRectangle(float32(sidePanelRelativeX+10), 45, sidePanelWidth-40, colourPickerHeight), "Color", colourPickerVal)
|
colourPickerVal = gui.ColorPicker(raylib.NewRectangle(float32(sidePanelRelativeX+10), 45, sidePanelWidth-45, colourPickerHeight), "Color", colourPickerVal)
|
||||||
|
|
||||||
gui.Label(raylib.NewRectangle(float32(sidePanelRelativeX+10), 55+colourPickerHeight, 200, 20), "Brush Size")
|
gui.Label(raylib.NewRectangle(float32(sidePanelRelativeX+10), 55+colourPickerHeight, 60, 20), "Brush Size")
|
||||||
brushSize = gui.Slider(raylib.NewRectangle(float32(sidePanelRelativeX+78), 55+colourPickerHeight, 215, 20), "", "", brushSize, 1, 100)
|
brushSize = gui.Slider(raylib.NewRectangle(float32(sidePanelRelativeX+80), 55+colourPickerHeight, sidePanelWidth-90, 20), "", "", brushSize, 1, 100)
|
||||||
|
|
||||||
gui.Label(raylib.NewRectangle(float32(sidePanelRelativeX+10), 85+colourPickerHeight, 200, 20), "File Name")
|
gui.Label(raylib.NewRectangle(float32(sidePanelRelativeX+10), 85+colourPickerHeight, 60, 20), "Brush Opacity")
|
||||||
if gui.TextBox(raylib.NewRectangle(float32(sidePanelRelativeX+78), 85+colourPickerHeight, 215, 20), &fileName, 40, fileNameEditing) {
|
brushOpacity = gui.Slider(raylib.NewRectangle(float32(sidePanelRelativeX+80), 85+colourPickerHeight, sidePanelWidth-90, 20), "", "", brushOpacity, 0, 1)
|
||||||
|
|
||||||
|
gui.Label(raylib.NewRectangle(float32(sidePanelRelativeX+10), 115+colourPickerHeight, 60, 20), "File Name")
|
||||||
|
if gui.TextBox(raylib.NewRectangle(float32(sidePanelRelativeX+80), 115+colourPickerHeight, sidePanelWidth-90, 20), &fileName, 40, fileNameEditing) {
|
||||||
fileNameEditing = !fileNameEditing
|
fileNameEditing = !fileNameEditing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -251,10 +264,10 @@ func Drawing() {
|
||||||
{
|
{
|
||||||
var text string
|
var text string
|
||||||
|
|
||||||
text = fmt.Sprintf("Strokes: %d | Stroke Points: %d", len(strokes), len(currentStroke.Points))
|
text = fmt.Sprintf("Strokes: %d | Points: %d", len(strokes), len(currentStroke.Points))
|
||||||
gui.StatusBar(raylib.NewRectangle(0, float32(application.WindowHeight-20), 200, 20), text)
|
gui.StatusBar(raylib.NewRectangle(0, float32(application.WindowHeight-20), 200, 20), text)
|
||||||
|
|
||||||
text = fmt.Sprintf("Canvas Size: %dx%d", int32(canvasSize.X), int32(canvasSize.Y))
|
text = fmt.Sprintf("Canvas Size: %dx%d | Scale: %v", int32(canvasSize.X), int32(canvasSize.Y), canvasScale)
|
||||||
gui.StatusBar(raylib.NewRectangle(199, float32(application.WindowHeight-20), 200, 20), text)
|
gui.StatusBar(raylib.NewRectangle(199, float32(application.WindowHeight-20), 200, 20), text)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ package scenes
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"ColouringApp/application"
|
"ColouringApp/application"
|
||||||
|
"os"
|
||||||
|
|
||||||
gui "github.com/gen2brain/raylib-go/raygui"
|
gui "github.com/gen2brain/raylib-go/raygui"
|
||||||
raylib "github.com/gen2brain/raylib-go/raylib"
|
raylib "github.com/gen2brain/raylib-go/raylib"
|
||||||
|
@ -10,39 +11,73 @@ import (
|
||||||
func Title() {
|
func Title() {
|
||||||
var (
|
var (
|
||||||
titleText = application.WindowTitle
|
titleText = application.WindowTitle
|
||||||
|
gallery []raylib.Texture2D
|
||||||
)
|
)
|
||||||
|
|
||||||
|
application.WindowWidth = int32(raylib.GetScreenWidth())
|
||||||
|
application.WindowHeight = int32(raylib.GetScreenHeight())
|
||||||
|
|
||||||
|
// Load gallery here
|
||||||
|
files, err := os.ReadDir(application.DirUserData)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, file := range files {
|
||||||
|
if file.IsDir() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
gallery = append(gallery, raylib.LoadTexture(application.DirUserData+file.Name()))
|
||||||
|
}
|
||||||
|
|
||||||
for !application.ShouldQuit {
|
for !application.ShouldQuit {
|
||||||
application.ShouldQuit = raylib.WindowShouldClose()
|
// DEFAULT
|
||||||
if application.CurrentScene != application.SceneTitle {
|
{
|
||||||
break
|
application.ShouldQuit = raylib.WindowShouldClose()
|
||||||
|
if application.CurrentScene != application.SceneTitle {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if raylib.IsWindowResized() {
|
||||||
|
application.WindowWidth = int32(raylib.GetScreenWidth())
|
||||||
|
application.WindowHeight = int32(raylib.GetScreenHeight())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToDo: Remove this
|
// INPUT
|
||||||
application.CurrentScene = application.SceneDrawing
|
|
||||||
|
|
||||||
if raylib.IsWindowResized() {
|
// UPDATE
|
||||||
application.WindowWidth = int32(raylib.GetScreenWidth())
|
{
|
||||||
application.WindowHeight = int32(raylib.GetScreenHeight())
|
application.UpdateToasts()
|
||||||
}
|
}
|
||||||
|
|
||||||
raylib.BeginDrawing()
|
// DRAW
|
||||||
raylib.ClearBackground(raylib.White)
|
{
|
||||||
|
raylib.BeginDrawing()
|
||||||
|
raylib.ClearBackground(raylib.White)
|
||||||
|
|
||||||
if gui.Button(raylib.NewRectangle(10, 10, 40, 40), gui.IconText(gui.ICON_CROSS, "")) {
|
if gui.Button(raylib.NewRectangle(10, 10, 40, 40), gui.IconText(gui.ICON_CROSS, "")) {
|
||||||
application.ShouldQuit = true
|
application.ShouldQuit = true
|
||||||
}
|
}
|
||||||
raylib.DrawText(titleText, (application.WindowWidth-raylib.MeasureText(titleText, 20))/2, 20, 20, raylib.Black)
|
raylib.DrawText(titleText, (application.WindowWidth-raylib.MeasureText(titleText, 20))/2, 20, 20, raylib.Black)
|
||||||
if gui.Button(raylib.NewRectangle(float32(application.WindowWidth-50), 10, 40, 40), gui.IconText(gui.ICON_GEAR, "")) {
|
if gui.Button(raylib.NewRectangle(float32(application.WindowWidth-50), 10, 40, 40), gui.IconText(gui.ICON_GEAR, "")) {
|
||||||
application.CurrentScene = application.SceneOptions
|
application.CurrentScene = application.SceneOptions
|
||||||
|
}
|
||||||
|
|
||||||
|
for i := 0; i < len(gallery); i++ {
|
||||||
|
raylib.DrawTexturePro(gallery[i], raylib.NewRectangle(0, 0, float32(gallery[i].Width), float32(-gallery[i].Height)), raylib.NewRectangle(float32(10+(i%5)*100), float32(70+(i/5)*100), 100, 100), raylib.Vector2{}, 0, raylib.White)
|
||||||
|
}
|
||||||
|
|
||||||
|
if gui.Button(raylib.NewRectangle(float32((application.WindowWidth-100)/2), float32(application.WindowHeight-70), 100, 40), "Start") {
|
||||||
|
application.CurrentScene = application.SceneDrawing
|
||||||
|
}
|
||||||
|
|
||||||
|
application.DrawToasts()
|
||||||
|
|
||||||
|
raylib.EndDrawing()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
raylib.EndScissorMode()
|
for i := 0; i < len(gallery); i++ {
|
||||||
|
raylib.UnloadTexture(gallery[i])
|
||||||
if gui.Button(raylib.NewRectangle(float32((application.WindowWidth-100)/2), float32(application.WindowHeight-70), 100, 40), "Start") {
|
|
||||||
application.CurrentScene = application.SceneDrawing
|
|
||||||
}
|
|
||||||
|
|
||||||
raylib.EndDrawing()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue