This commit is contained in:
Konstantin8105 2022-11-23 12:35:50 +03:00
parent 7a467d5aae
commit f19f61b778
19 changed files with 1202 additions and 37 deletions

23
raygui/progressbar.go Normal file
View file

@ -0,0 +1,23 @@
package raygui
import "github.com/gen2brain/raylib-go/raylib"
// ProgressBar - Progress Bar element, shows current progress value
func ProgressBar(bounds rl.Rectangle, value float32) {
b := bounds.ToInt32()
if value > 1.0 {
value = 1.0
} else if value < 0.0 {
value = 0.0
}
borderWidth := GetStyle32(ProgressbarBorderWidth)
progressBar := InsetRectangle(b, borderWidth) // backing rectangle
progressWidth := int32(value * float32(progressBar.Width)) // how much should be replaced with progress
progressValue := rl.RectangleInt32{progressBar.X, progressBar.Y, progressWidth, progressBar.Height}
// Draw control
rl.DrawRectangle(b.X, b.Y, b.Width, b.Height, GetStyleColor(ProgressbarBorderColor))
rl.DrawRectangle(progressBar.X, progressBar.Y, progressBar.Width, progressBar.Height, GetStyleColor(ProgressbarInsideColor))
rl.DrawRectangle(progressValue.X, progressValue.Y, progressValue.Width, progressValue.Height, GetStyleColor(ProgressbarProgressColor))
}