Golint
This commit is contained in:
parent
0682698f0b
commit
969ba1dc21
8 changed files with 125 additions and 81 deletions
|
@ -9,119 +9,138 @@ import (
|
||||||
|
|
||||||
// Linear Easing functions
|
// Linear Easing functions
|
||||||
|
|
||||||
|
// Linear None
|
||||||
func LinearNone(t, b, c, d float32) float32 {
|
func LinearNone(t, b, c, d float32) float32 {
|
||||||
return c*t/d + b
|
return c*t/d + b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Linear In
|
||||||
func LinearIn(t, b, c, d float32) float32 {
|
func LinearIn(t, b, c, d float32) float32 {
|
||||||
return c*t/d + b
|
return c*t/d + b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Linear Out
|
||||||
func LinearOut(t, b, c, d float32) float32 {
|
func LinearOut(t, b, c, d float32) float32 {
|
||||||
return c*t/d + b
|
return c*t/d + b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Linear In Out
|
||||||
func LinearInOut(t, b, c, d float32) float32 {
|
func LinearInOut(t, b, c, d float32) float32 {
|
||||||
return c*t/d + b
|
return c*t/d + b
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sine Easing functions
|
// Sine Easing functions
|
||||||
|
|
||||||
|
// Sine In
|
||||||
func SineIn(t, b, c, d float32) float32 {
|
func SineIn(t, b, c, d float32) float32 {
|
||||||
return -c*float32(math.Cos(float64(t/d)*(math.Pi/2))) + c + b
|
return -c*float32(math.Cos(float64(t/d)*(math.Pi/2))) + c + b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sine Out
|
||||||
func SineOut(t, b, c, d float32) float32 {
|
func SineOut(t, b, c, d float32) float32 {
|
||||||
return c*float32(math.Sin(float64(t/d)*(math.Pi/2))) + b
|
return c*float32(math.Sin(float64(t/d)*(math.Pi/2))) + b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sine In Out
|
||||||
func SineInOut(t, b, c, d float32) float32 {
|
func SineInOut(t, b, c, d float32) float32 {
|
||||||
return -c/2*(float32(math.Cos(math.Pi*float64(t/d)))-1) + b
|
return -c/2*(float32(math.Cos(math.Pi*float64(t/d)))-1) + b
|
||||||
}
|
}
|
||||||
|
|
||||||
// Circular Easing functions
|
// Circular Easing functions
|
||||||
|
|
||||||
|
// Circ In
|
||||||
func CircIn(t, b, c, d float32) float32 {
|
func CircIn(t, b, c, d float32) float32 {
|
||||||
t = t / d
|
t = t / d
|
||||||
return -c*(float32(math.Sqrt(float64(1-t*t)))-1) + b
|
return -c*(float32(math.Sqrt(float64(1-t*t)))-1) + b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Circ Out
|
||||||
func CircOut(t, b, c, d float32) float32 {
|
func CircOut(t, b, c, d float32) float32 {
|
||||||
return c*float32(math.Sqrt(1-float64((t/d-1)*t))) + b
|
return c*float32(math.Sqrt(1-float64((t/d-1)*t))) + b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Circ In Out
|
||||||
func CircInOut(t, b, c, d float32) float32 {
|
func CircInOut(t, b, c, d float32) float32 {
|
||||||
t = t / d * 2
|
t = t / d * 2
|
||||||
|
|
||||||
if t < 1 {
|
if t < 1 {
|
||||||
return -c/2*(float32(math.Sqrt(float64(1-t*t)))-1) + b
|
return -c/2*(float32(math.Sqrt(float64(1-t*t)))-1) + b
|
||||||
} else {
|
}
|
||||||
|
|
||||||
t = t - 2
|
t = t - 2
|
||||||
return c/2*(float32(math.Sqrt(1-float64(t*t)))+1) + b
|
return c/2*(float32(math.Sqrt(1-float64(t*t)))+1) + b
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cubic Easing functions
|
// Cubic Easing functions
|
||||||
|
|
||||||
|
// Cubic In
|
||||||
func CubicIn(t, b, c, d float32) float32 {
|
func CubicIn(t, b, c, d float32) float32 {
|
||||||
t = t / d
|
t = t / d
|
||||||
return c*t*t*t + b
|
return c*t*t*t + b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cubic Out
|
||||||
func CubicOut(t, b, c, d float32) float32 {
|
func CubicOut(t, b, c, d float32) float32 {
|
||||||
t = t/d - 1
|
t = t/d - 1
|
||||||
return c*(t*t*t+1) + b
|
return c*(t*t*t+1) + b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cubic In Out
|
||||||
func CubicInOut(t, b, c, d float32) float32 {
|
func CubicInOut(t, b, c, d float32) float32 {
|
||||||
t = t / d * 2
|
t = t / d * 2
|
||||||
if t < 1 {
|
if t < 1 {
|
||||||
return (c/2*t*t*t + b)
|
return (c/2*t*t*t + b)
|
||||||
} else {
|
}
|
||||||
|
|
||||||
t = t - 2
|
t = t - 2
|
||||||
return c/2*(t*t*t+2) + b
|
return c/2*(t*t*t+2) + b
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Quadratic Easing functions
|
// Quadratic Easing functions
|
||||||
|
|
||||||
|
// Quad In
|
||||||
func QuadIn(t, b, c, d float32) float32 {
|
func QuadIn(t, b, c, d float32) float32 {
|
||||||
t = t / d
|
t = t / d
|
||||||
return c*t*t + b
|
return c*t*t + b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Quad Out
|
||||||
func QuadOut(t, b, c, d float32) float32 {
|
func QuadOut(t, b, c, d float32) float32 {
|
||||||
t = t / d
|
t = t / d
|
||||||
return (-c*t*(t-2) + b)
|
return (-c*t*(t-2) + b)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Quad In Out
|
||||||
func QuadInOut(t, b, c, d float32) float32 {
|
func QuadInOut(t, b, c, d float32) float32 {
|
||||||
t = t / d * 2
|
t = t / d * 2
|
||||||
if t < 1 {
|
if t < 1 {
|
||||||
return ((c / 2) * (t * t)) + b
|
return ((c / 2) * (t * t)) + b
|
||||||
} else {
|
|
||||||
return -c/2*((t-1)*(t-3)-1) + b
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return -c/2*((t-1)*(t-3)-1) + b
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exponential Easing functions
|
// Exponential Easing functions
|
||||||
|
|
||||||
|
// Expo In
|
||||||
func ExpoIn(t, b, c, d float32) float32 {
|
func ExpoIn(t, b, c, d float32) float32 {
|
||||||
if t == 0 {
|
if t == 0 {
|
||||||
return b
|
return b
|
||||||
} else {
|
|
||||||
return (c*float32(math.Pow(2, 10*float64(t/d-1))) + b)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return (c*float32(math.Pow(2, 10*float64(t/d-1))) + b)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Expo Out
|
||||||
func ExpoOut(t, b, c, d float32) float32 {
|
func ExpoOut(t, b, c, d float32) float32 {
|
||||||
if t == d {
|
if t == d {
|
||||||
return (b + c)
|
return (b + c)
|
||||||
} else {
|
|
||||||
return c*(-float32(math.Pow(2, -10*float64(t/d)))+1) + b
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return c*(-float32(math.Pow(2, -10*float64(t/d)))+1) + b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Expo In Out
|
||||||
func ExpoInOut(t, b, c, d float32) float32 {
|
func ExpoInOut(t, b, c, d float32) float32 {
|
||||||
if t == 0 {
|
if t == 0 {
|
||||||
return b
|
return b
|
||||||
|
@ -134,26 +153,29 @@ func ExpoInOut(t, b, c, d float32) float32 {
|
||||||
|
|
||||||
if t < 1 {
|
if t < 1 {
|
||||||
return (c/2*float32(math.Pow(2, 10*float64(t-1))) + b)
|
return (c/2*float32(math.Pow(2, 10*float64(t-1))) + b)
|
||||||
} else {
|
}
|
||||||
|
|
||||||
t = t - 1
|
t = t - 1
|
||||||
return (c/2*(-float32(math.Pow(2, -10*float64(t)))+2) + b)
|
return (c/2*(-float32(math.Pow(2, -10*float64(t)))+2) + b)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Back Easing functions
|
// Back Easing functions
|
||||||
|
|
||||||
|
// Back In
|
||||||
func BackIn(t, b, c, d float32) float32 {
|
func BackIn(t, b, c, d float32) float32 {
|
||||||
s := float32(1.70158)
|
s := float32(1.70158)
|
||||||
t = t / d
|
t = t / d
|
||||||
return c*t*t*((s+1)*t-s) + b
|
return c*t*t*((s+1)*t-s) + b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Back Out
|
||||||
func BackOut(t, b, c, d float32) float32 {
|
func BackOut(t, b, c, d float32) float32 {
|
||||||
s := float32(1.70158)
|
s := float32(1.70158)
|
||||||
t = t/d - 1
|
t = t/d - 1
|
||||||
return c*(t*t*((s+1)*t+s)+1) + b
|
return c*(t*t*((s+1)*t+s)+1) + b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Back In Out
|
||||||
func BackInOut(t, b, c, d float32) float32 {
|
func BackInOut(t, b, c, d float32) float32 {
|
||||||
s := float32(1.70158)
|
s := float32(1.70158)
|
||||||
s = s * 1.525
|
s = s * 1.525
|
||||||
|
@ -161,18 +183,20 @@ func BackInOut(t, b, c, d float32) float32 {
|
||||||
|
|
||||||
if t < 1 {
|
if t < 1 {
|
||||||
return c/2*(t*t*((s+1)*t-s)) + b
|
return c/2*(t*t*((s+1)*t-s)) + b
|
||||||
} else {
|
}
|
||||||
|
|
||||||
t = t - 2
|
t = t - 2
|
||||||
return c/2*(t*t*((s+1)*t+s)+2) + b
|
return c/2*(t*t*((s+1)*t+s)+2) + b
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bounce Easing functions
|
// Bounce Easing functions
|
||||||
|
|
||||||
|
// Bounce In
|
||||||
func BounceIn(t, b, c, d float32) float32 {
|
func BounceIn(t, b, c, d float32) float32 {
|
||||||
return (c - BounceOut(d-t, 0, c, d) + b)
|
return (c - BounceOut(d-t, 0, c, d) + b)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Bounce Out
|
||||||
func BounceOut(t, b, c, d float32) float32 {
|
func BounceOut(t, b, c, d float32) float32 {
|
||||||
t = t / d
|
t = t / d
|
||||||
if t < (1 / 2.75) {
|
if t < (1 / 2.75) {
|
||||||
|
@ -183,22 +207,24 @@ func BounceOut(t, b, c, d float32) float32 {
|
||||||
} else if t < (2.5 / 2.75) {
|
} else if t < (2.5 / 2.75) {
|
||||||
t = t - (2.25 / 2.75)
|
t = t - (2.25 / 2.75)
|
||||||
return c*(7.5625*t*t+0.9375) + b
|
return c*(7.5625*t*t+0.9375) + b
|
||||||
} else {
|
}
|
||||||
|
|
||||||
t = t - (2.625 / 2.75)
|
t = t - (2.625 / 2.75)
|
||||||
return c*(7.5625*t*t+0.984375) + b
|
return c*(7.5625*t*t+0.984375) + b
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Bounce In Out
|
||||||
func BounceInOut(t, b, c, d float32) float32 {
|
func BounceInOut(t, b, c, d float32) float32 {
|
||||||
if t < d/2 {
|
if t < d/2 {
|
||||||
return BounceIn(t*2, 0, c, d)*0.5 + b
|
return BounceIn(t*2, 0, c, d)*0.5 + b
|
||||||
} else {
|
|
||||||
return BounceOut(t*2-d, 0, c, d)*0.5 + c*0.5 + b
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return BounceOut(t*2-d, 0, c, d)*0.5 + c*0.5 + b
|
||||||
}
|
}
|
||||||
|
|
||||||
// Elastic Easing functions
|
// Elastic Easing functions
|
||||||
|
|
||||||
|
// Elastic In
|
||||||
func ElasticIn(t, b, c, d float32) float32 {
|
func ElasticIn(t, b, c, d float32) float32 {
|
||||||
if t == 0 {
|
if t == 0 {
|
||||||
return b
|
return b
|
||||||
|
@ -218,6 +244,7 @@ func ElasticIn(t, b, c, d float32) float32 {
|
||||||
return -(postFix * float32(math.Sin(float64(t*d-s)*(2*math.Pi)/float64(p)))) + b
|
return -(postFix * float32(math.Sin(float64(t*d-s)*(2*math.Pi)/float64(p)))) + b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Elastic Out
|
||||||
func ElasticOut(t, b, c, d float32) float32 {
|
func ElasticOut(t, b, c, d float32) float32 {
|
||||||
if t == 0 {
|
if t == 0 {
|
||||||
return b
|
return b
|
||||||
|
@ -236,6 +263,7 @@ func ElasticOut(t, b, c, d float32) float32 {
|
||||||
return a*float32(math.Pow(2, -10*float64(t)))*float32(math.Sin(float64(t*d-s)*(2*math.Pi)/float64(p))) + c + b
|
return a*float32(math.Pow(2, -10*float64(t)))*float32(math.Sin(float64(t*d-s)*(2*math.Pi)/float64(p))) + c + b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Elastic In Out
|
||||||
func ElasticInOut(t, b, c, d float32) float32 {
|
func ElasticInOut(t, b, c, d float32) float32 {
|
||||||
if t == 0 {
|
if t == 0 {
|
||||||
return b
|
return b
|
||||||
|
@ -255,9 +283,9 @@ func ElasticInOut(t, b, c, d float32) float32 {
|
||||||
t = t - 1
|
t = t - 1
|
||||||
postFix := a * float32(math.Pow(2, 10*float64(t)))
|
postFix := a * float32(math.Pow(2, 10*float64(t)))
|
||||||
return -0.5*(postFix*float32(math.Sin(float64(t*d-s)*(2*math.Pi)/float64(p)))) + b
|
return -0.5*(postFix*float32(math.Sin(float64(t*d-s)*(2*math.Pi)/float64(p)))) + b
|
||||||
} else {
|
}
|
||||||
|
|
||||||
t = t - 1
|
t = t - 1
|
||||||
postFix := a * float32(math.Pow(2, -10*(float64(t))))
|
postFix := a * float32(math.Pow(2, -10*(float64(t))))
|
||||||
return postFix*float32(math.Sin(float64(t*d-s)*(2*math.Pi)/float64(p)))*0.5 + c + b
|
return postFix*float32(math.Sin(float64(t*d-s)*(2*math.Pi)/float64(p)))*0.5 + c + b
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,7 +119,6 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
// GUI elements states
|
// GUI elements states
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ButtonDefault = iota
|
ButtonDefault = iota
|
||||||
ButtonHover
|
ButtonHover
|
||||||
|
@ -127,6 +126,7 @@ const (
|
||||||
ButtonClicked
|
ButtonClicked
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// GUI elements states
|
||||||
const (
|
const (
|
||||||
ToggleUnactive = iota
|
ToggleUnactive = iota
|
||||||
ToggleHover
|
ToggleHover
|
||||||
|
@ -134,6 +134,7 @@ const (
|
||||||
ToggleActive
|
ToggleActive
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// GUI elements states
|
||||||
const (
|
const (
|
||||||
ComboboxUnactive = iota
|
ComboboxUnactive = iota
|
||||||
ComboboxHover
|
ComboboxHover
|
||||||
|
@ -141,18 +142,21 @@ const (
|
||||||
ComboboxActive
|
ComboboxActive
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// GUI elements states
|
||||||
const (
|
const (
|
||||||
SpinnerDefault = iota
|
SpinnerDefault = iota
|
||||||
SpinnerHover
|
SpinnerHover
|
||||||
SpinnerPressed
|
SpinnerPressed
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// GUI elements states
|
||||||
const (
|
const (
|
||||||
CheckboxStatus = iota
|
CheckboxStatus = iota
|
||||||
CheckboxHover
|
CheckboxHover
|
||||||
CheckboxPressed
|
CheckboxPressed
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// GUI elements states
|
||||||
const (
|
const (
|
||||||
SliderDefault = iota
|
SliderDefault = iota
|
||||||
SliderHover
|
SliderHover
|
||||||
|
@ -160,7 +164,7 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
// Current GUI style (default light)
|
// Current GUI style (default light)
|
||||||
var style []int = []int{
|
var style = []int{
|
||||||
0xf5f5f5ff, // GLOBAL_BASE_COLOR
|
0xf5f5f5ff, // GLOBAL_BASE_COLOR
|
||||||
0xf5f5f5ff, // GLOBAL_BORDER_COLOR
|
0xf5f5f5ff, // GLOBAL_BORDER_COLOR
|
||||||
0xf5f5f5ff, // GLOBAL_TEXT_COLOR
|
0xf5f5f5ff, // GLOBAL_TEXT_COLOR
|
||||||
|
@ -263,7 +267,7 @@ var style []int = []int{
|
||||||
}
|
}
|
||||||
|
|
||||||
// GUI property names (to read/write style text files)
|
// GUI property names (to read/write style text files)
|
||||||
var propertyName []string = []string{
|
var propertyName = []string{
|
||||||
"GLOBAL_BASE_COLOR",
|
"GLOBAL_BASE_COLOR",
|
||||||
"GLOBAL_BORDER_COLOR",
|
"GLOBAL_BORDER_COLOR",
|
||||||
"GLOBAL_TEXT_COLOR",
|
"GLOBAL_TEXT_COLOR",
|
||||||
|
@ -457,9 +461,9 @@ func Button(bounds raylib.Rectangle, text string) bool {
|
||||||
|
|
||||||
if buttonState == ButtonClicked {
|
if buttonState == ButtonClicked {
|
||||||
return true
|
return true
|
||||||
} else {
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// Toggle Button element, returns true when active
|
// Toggle Button element, returns true when active
|
||||||
|
@ -624,7 +628,7 @@ func ComboBox(bounds raylib.Rectangle, comboText []string, comboActive int) int
|
||||||
|
|
||||||
if raylib.CheckCollisionPointRec(raylib.GetMousePosition(), bounds) || raylib.CheckCollisionPointRec(raylib.GetMousePosition(), click) {
|
if raylib.CheckCollisionPointRec(raylib.GetMousePosition(), bounds) || raylib.CheckCollisionPointRec(raylib.GetMousePosition(), click) {
|
||||||
if raylib.IsMouseButtonPressed(raylib.MouseLeftButton) {
|
if raylib.IsMouseButtonPressed(raylib.MouseLeftButton) {
|
||||||
comboActive += 1
|
comboActive++
|
||||||
if comboActive >= comboNum {
|
if comboActive >= comboNum {
|
||||||
comboActive = 0
|
comboActive = 0
|
||||||
}
|
}
|
||||||
|
@ -852,8 +856,8 @@ func Spinner(bounds raylib.Rectangle, value, minValue, maxValue int) int {
|
||||||
|
|
||||||
buttonSide := 0
|
buttonSide := 0
|
||||||
|
|
||||||
framesCounter := 0
|
var framesCounter int
|
||||||
valueSpeed := false
|
var valueSpeed bool
|
||||||
|
|
||||||
// Update control
|
// Update control
|
||||||
if raylib.CheckCollisionPointRec(mousePoint, leftButtonBound) || raylib.CheckCollisionPointRec(mousePoint, rightButtonBound) || raylib.CheckCollisionPointRec(mousePoint, labelBoxBound) {
|
if raylib.CheckCollisionPointRec(mousePoint, leftButtonBound) || raylib.CheckCollisionPointRec(mousePoint, rightButtonBound) || raylib.CheckCollisionPointRec(mousePoint, labelBoxBound) {
|
||||||
|
@ -862,14 +866,14 @@ func Spinner(bounds raylib.Rectangle, value, minValue, maxValue int) int {
|
||||||
buttonSide = 1
|
buttonSide = 1
|
||||||
|
|
||||||
if value > minValue {
|
if value > minValue {
|
||||||
value -= 1
|
value--
|
||||||
}
|
}
|
||||||
} else if raylib.IsKeyDown(raylib.KeyRight) {
|
} else if raylib.IsKeyDown(raylib.KeyRight) {
|
||||||
spinnerState = SpinnerPressed
|
spinnerState = SpinnerPressed
|
||||||
buttonSide = 2
|
buttonSide = 2
|
||||||
|
|
||||||
if value < maxValue {
|
if value < maxValue {
|
||||||
value += 1
|
value++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -892,7 +896,7 @@ func Spinner(bounds raylib.Rectangle, value, minValue, maxValue int) int {
|
||||||
|
|
||||||
if value > minValue {
|
if value > minValue {
|
||||||
if framesCounter >= 30 {
|
if framesCounter >= 30 {
|
||||||
value -= 1
|
value--
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -914,7 +918,7 @@ func Spinner(bounds raylib.Rectangle, value, minValue, maxValue int) int {
|
||||||
|
|
||||||
if value < maxValue {
|
if value < maxValue {
|
||||||
if framesCounter >= 30 {
|
if framesCounter >= 30 {
|
||||||
value += 1
|
value++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,8 @@ import "C"
|
||||||
import "unsafe"
|
import "unsafe"
|
||||||
import "reflect"
|
import "reflect"
|
||||||
|
|
||||||
|
// Some basic Defines
|
||||||
const (
|
const (
|
||||||
// Some basic Defines
|
|
||||||
Pi = 3.1415927
|
Pi = 3.1415927
|
||||||
Deg2rad = 0.017453292
|
Deg2rad = 0.017453292
|
||||||
Rad2deg = 57.295776
|
Rad2deg = 57.295776
|
||||||
|
@ -168,6 +168,7 @@ const (
|
||||||
GamepadXboxAxisRt = 5
|
GamepadXboxAxisRt = 5
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Gestures
|
||||||
type Gestures int32
|
type Gestures int32
|
||||||
|
|
||||||
// Gestures type
|
// Gestures type
|
||||||
|
@ -186,6 +187,7 @@ const (
|
||||||
GesturePinchOut Gestures = C.GESTURE_PINCH_OUT
|
GesturePinchOut Gestures = C.GESTURE_PINCH_OUT
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Camera mode
|
||||||
type CameraMode int32
|
type CameraMode int32
|
||||||
|
|
||||||
// Camera system modes
|
// Camera system modes
|
||||||
|
@ -201,57 +203,57 @@ const (
|
||||||
// NOTE: Custom raylib color palette for amazing visuals on WHITE background
|
// NOTE: Custom raylib color palette for amazing visuals on WHITE background
|
||||||
var (
|
var (
|
||||||
// Light Gray
|
// Light Gray
|
||||||
LightGray Color = NewColor(200, 200, 200, 255)
|
LightGray = NewColor(200, 200, 200, 255)
|
||||||
// Gray
|
// Gray
|
||||||
Gray Color = NewColor(130, 130, 130, 255)
|
Gray = NewColor(130, 130, 130, 255)
|
||||||
// Dark Gray
|
// Dark Gray
|
||||||
DarkGray Color = NewColor(80, 80, 80, 255)
|
DarkGray = NewColor(80, 80, 80, 255)
|
||||||
// Yellow
|
// Yellow
|
||||||
Yellow Color = NewColor(253, 249, 0, 255)
|
Yellow = NewColor(253, 249, 0, 255)
|
||||||
// Gold
|
// Gold
|
||||||
Gold Color = NewColor(255, 203, 0, 255)
|
Gold = NewColor(255, 203, 0, 255)
|
||||||
// Orange
|
// Orange
|
||||||
Orange Color = NewColor(255, 161, 0, 255)
|
Orange = NewColor(255, 161, 0, 255)
|
||||||
// Pink
|
// Pink
|
||||||
Pink Color = NewColor(255, 109, 194, 255)
|
Pink = NewColor(255, 109, 194, 255)
|
||||||
// Red
|
// Red
|
||||||
Red Color = NewColor(230, 41, 55, 255)
|
Red = NewColor(230, 41, 55, 255)
|
||||||
// Maroon
|
// Maroon
|
||||||
Maroon Color = NewColor(190, 33, 55, 255)
|
Maroon = NewColor(190, 33, 55, 255)
|
||||||
// Green
|
// Green
|
||||||
Green Color = NewColor(0, 228, 48, 255)
|
Green = NewColor(0, 228, 48, 255)
|
||||||
// Lime
|
// Lime
|
||||||
Lime Color = NewColor(0, 158, 47, 255)
|
Lime = NewColor(0, 158, 47, 255)
|
||||||
// Dark Green
|
// Dark Green
|
||||||
DarkGreen Color = NewColor(0, 117, 44, 255)
|
DarkGreen = NewColor(0, 117, 44, 255)
|
||||||
// Sky Blue
|
// Sky Blue
|
||||||
SkyBlue Color = NewColor(102, 191, 255, 255)
|
SkyBlue = NewColor(102, 191, 255, 255)
|
||||||
// Blue
|
// Blue
|
||||||
Blue Color = NewColor(0, 121, 241, 255)
|
Blue = NewColor(0, 121, 241, 255)
|
||||||
// Dark Blue
|
// Dark Blue
|
||||||
DarkBlue Color = NewColor(0, 82, 172, 255)
|
DarkBlue = NewColor(0, 82, 172, 255)
|
||||||
// Purple
|
// Purple
|
||||||
Purple Color = NewColor(200, 122, 255, 255)
|
Purple = NewColor(200, 122, 255, 255)
|
||||||
// Violet
|
// Violet
|
||||||
Violet Color = NewColor(135, 60, 190, 255)
|
Violet = NewColor(135, 60, 190, 255)
|
||||||
// Dark Purple
|
// Dark Purple
|
||||||
DarkPurple Color = NewColor(112, 31, 126, 255)
|
DarkPurple = NewColor(112, 31, 126, 255)
|
||||||
// Beige
|
// Beige
|
||||||
Beige Color = NewColor(211, 176, 131, 255)
|
Beige = NewColor(211, 176, 131, 255)
|
||||||
// Brown
|
// Brown
|
||||||
Brown Color = NewColor(127, 106, 79, 255)
|
Brown = NewColor(127, 106, 79, 255)
|
||||||
// Dark Brown
|
// Dark Brown
|
||||||
DarkBrown Color = NewColor(76, 63, 47, 255)
|
DarkBrown = NewColor(76, 63, 47, 255)
|
||||||
// White
|
// White
|
||||||
White Color = NewColor(255, 255, 255, 255)
|
White = NewColor(255, 255, 255, 255)
|
||||||
// Black
|
// Black
|
||||||
Black Color = NewColor(0, 0, 0, 255)
|
Black = NewColor(0, 0, 0, 255)
|
||||||
// Blank (Transparent)
|
// Blank (Transparent)
|
||||||
Blank Color = NewColor(0, 0, 0, 0)
|
Blank = NewColor(0, 0, 0, 0)
|
||||||
// Magenta
|
// Magenta
|
||||||
Magenta Color = NewColor(255, 0, 255, 255)
|
Magenta = NewColor(255, 0, 255, 255)
|
||||||
// Ray White (RayLib Logo White)
|
// Ray White (RayLib Logo White)
|
||||||
RayWhite Color = NewColor(245, 245, 245, 255)
|
RayWhite = NewColor(245, 245, 245, 255)
|
||||||
)
|
)
|
||||||
|
|
||||||
// Vector2 type
|
// Vector2 type
|
||||||
|
|
|
@ -28,9 +28,9 @@ type Mesh struct {
|
||||||
// Vertex indices (in case vertex data comes indexed)
|
// Vertex indices (in case vertex data comes indexed)
|
||||||
Indices *uint16
|
Indices *uint16
|
||||||
// OpenGL Vertex Array Object id
|
// OpenGL Vertex Array Object id
|
||||||
VaoId uint32
|
VaoID uint32
|
||||||
// OpenGL Vertex Buffer Objects id (7 types of vertex data)
|
// OpenGL Vertex Buffer Objects id (7 types of vertex data)
|
||||||
VboId [7]uint32
|
VboID [7]uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Mesh) cptr() *C.Mesh {
|
func (m *Mesh) cptr() *C.Mesh {
|
||||||
|
@ -38,8 +38,8 @@ func (m *Mesh) cptr() *C.Mesh {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns new Mesh
|
// Returns new Mesh
|
||||||
func NewMesh(vertexCount, triangleCount int32, vertices, texcoords, texcoords2, normals, tangents *float32, colors *uint8, indices *uint16, vaoId uint32, vboId [7]uint32) Mesh {
|
func NewMesh(vertexCount, triangleCount int32, vertices, texcoords, texcoords2, normals, tangents *float32, colors *uint8, indices *uint16, vaoID uint32, vboID [7]uint32) Mesh {
|
||||||
return Mesh{vertexCount, triangleCount, vertices, texcoords, texcoords2, normals, tangents, colors, indices, vaoId, vboId}
|
return Mesh{vertexCount, triangleCount, vertices, texcoords, texcoords2, normals, tangents, colors, indices, vaoID, vboID}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns new Mesh from pointer
|
// Returns new Mesh from pointer
|
||||||
|
|
|
@ -12,7 +12,7 @@ import (
|
||||||
// rRES file header (8 byte)
|
// rRES file header (8 byte)
|
||||||
type RRESFileHeader struct {
|
type RRESFileHeader struct {
|
||||||
// File identifier: rRES (4 byte)
|
// File identifier: rRES (4 byte)
|
||||||
Id [4]int8
|
ID [4]int8
|
||||||
// File version and subversion (2 byte)
|
// File version and subversion (2 byte)
|
||||||
Version uint16
|
Version uint16
|
||||||
// Number of resources in this file (2 byte)
|
// Number of resources in this file (2 byte)
|
||||||
|
@ -22,7 +22,7 @@ type RRESFileHeader struct {
|
||||||
// rRES info header, every resource includes this header (16 byte + 16 byte)
|
// rRES info header, every resource includes this header (16 byte + 16 byte)
|
||||||
type RRESInfoHeader struct {
|
type RRESInfoHeader struct {
|
||||||
// Resource unique identifier (4 byte)
|
// Resource unique identifier (4 byte)
|
||||||
Id uint32
|
ID uint32
|
||||||
// Resource data type (1 byte)
|
// Resource data type (1 byte)
|
||||||
DataType uint8
|
DataType uint8
|
||||||
// Resource data compression type (1 byte)
|
// Resource data compression type (1 byte)
|
||||||
|
@ -71,6 +71,7 @@ const (
|
||||||
RRESCompBrotli
|
RRESCompBrotli
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Image formats
|
||||||
const (
|
const (
|
||||||
// 8 bit per pixel (no alpha)
|
// 8 bit per pixel (no alpha)
|
||||||
RRESImUncompGrayscale = iota + 1
|
RRESImUncompGrayscale = iota + 1
|
||||||
|
@ -110,6 +111,7 @@ const (
|
||||||
RRESImCompAstc8x8Rgba
|
RRESImCompAstc8x8Rgba
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// RRESVert
|
||||||
const (
|
const (
|
||||||
RRESVertPosition = iota
|
RRESVertPosition = iota
|
||||||
RRESVertTexcoord1
|
RRESVertTexcoord1
|
||||||
|
@ -122,6 +124,7 @@ const (
|
||||||
RRESVertIndex
|
RRESVertIndex
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// RRESVert
|
||||||
const (
|
const (
|
||||||
RRESVertByte = iota
|
RRESVertByte = iota
|
||||||
RRESVertShort
|
RRESVertShort
|
||||||
|
@ -133,12 +136,12 @@ const (
|
||||||
// Load resource from file (only one)
|
// Load resource from file (only one)
|
||||||
// NOTE: Returns uncompressed data with parameters, only first resource found
|
// NOTE: Returns uncompressed data with parameters, only first resource found
|
||||||
func LoadResource(fileName string) []byte {
|
func LoadResource(fileName string) []byte {
|
||||||
return LoadResourceById(fileName, 0)
|
return LoadResourceByID(fileName, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load resource from file by id
|
// Load resource from file by id
|
||||||
// NOTE: Returns uncompressed data with parameters, search resource by id
|
// NOTE: Returns uncompressed data with parameters, search resource by id
|
||||||
func LoadResourceById(fileName string, rresId int) (data []byte) {
|
func LoadResourceByID(fileName string, rresID int) (data []byte) {
|
||||||
file, err := os.Open(fileName)
|
file, err := os.Open(fileName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
TraceLog(LogWarning, "[%s] rRES raylib resource file could not be opened", fileName)
|
TraceLog(LogWarning, "[%s] rRES raylib resource file could not be opened", fileName)
|
||||||
|
@ -159,7 +162,7 @@ func LoadResourceById(fileName string, rresId int) (data []byte) {
|
||||||
//fmt.Printf("%+v\n", fileHeader)
|
//fmt.Printf("%+v\n", fileHeader)
|
||||||
|
|
||||||
// Verify "rRES" identifier
|
// Verify "rRES" identifier
|
||||||
id := fmt.Sprintf("%c", fileHeader.Id)
|
id := fmt.Sprintf("%c", fileHeader.ID)
|
||||||
if id != "[r R E S]" {
|
if id != "[r R E S]" {
|
||||||
TraceLog(LogWarning, "[%s] This is not a valid raylib resource file", fileName)
|
TraceLog(LogWarning, "[%s] This is not a valid raylib resource file", fileName)
|
||||||
return
|
return
|
||||||
|
@ -179,7 +182,7 @@ func LoadResourceById(fileName string, rresId int) (data []byte) {
|
||||||
|
|
||||||
file.Seek(int64(unsafe.Sizeof(infoHeader)), os.SEEK_CUR)
|
file.Seek(int64(unsafe.Sizeof(infoHeader)), os.SEEK_CUR)
|
||||||
|
|
||||||
if int(infoHeader.Id) == rresId {
|
if int(infoHeader.ID) == rresID {
|
||||||
// Read resource data block
|
// Read resource data block
|
||||||
data = make([]byte, infoHeader.DataSize)
|
data = make([]byte, infoHeader.DataSize)
|
||||||
file.Read(data)
|
file.Read(data)
|
||||||
|
@ -194,7 +197,7 @@ func LoadResourceById(fileName string, rresId int) (data []byte) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(data) > 0 {
|
if len(data) > 0 {
|
||||||
TraceLog(LogInfo, "[%s][ID %d] Resource data loaded successfully", fileName, infoHeader.Id)
|
TraceLog(LogInfo, "[%s][ID %d] Resource data loaded successfully", fileName, infoHeader.ID)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Skip required data to read next resource infoHeader
|
// Skip required data to read next resource infoHeader
|
||||||
|
@ -203,7 +206,7 @@ func LoadResourceById(fileName string, rresId int) (data []byte) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(data) == 0 {
|
if len(data) == 0 {
|
||||||
TraceLog(LogInfo, "[%s][ID %d] Requested resource could not be found", fileName, rresId)
|
TraceLog(LogInfo, "[%s][ID %d] Requested resource could not be found", fileName, rresID)
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
|
@ -8,6 +8,7 @@ import "C"
|
||||||
import "unsafe"
|
import "unsafe"
|
||||||
import "reflect"
|
import "reflect"
|
||||||
|
|
||||||
|
// Vr device
|
||||||
type VrDevice int32
|
type VrDevice int32
|
||||||
|
|
||||||
// Head Mounted Display devices
|
// Head Mounted Display devices
|
||||||
|
@ -23,6 +24,7 @@ const (
|
||||||
HmdFoveVr VrDevice = C.HMD_FOVE_VR
|
HmdFoveVr VrDevice = C.HMD_FOVE_VR
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Blend mode
|
||||||
type BlendMode int32
|
type BlendMode int32
|
||||||
|
|
||||||
// Color blending modes (pre-defined)
|
// Color blending modes (pre-defined)
|
||||||
|
@ -35,7 +37,7 @@ const (
|
||||||
// Shader type (generic shader)
|
// Shader type (generic shader)
|
||||||
type Shader struct {
|
type Shader struct {
|
||||||
// Shader program id
|
// Shader program id
|
||||||
Id uint32
|
ID uint32
|
||||||
// Vertex attribute location point (default-location = 0)
|
// Vertex attribute location point (default-location = 0)
|
||||||
VertexLoc int32
|
VertexLoc int32
|
||||||
// Texcoord attribute location point (default-location = 1)
|
// Texcoord attribute location point (default-location = 1)
|
||||||
|
|
|
@ -7,6 +7,7 @@ package raylib
|
||||||
import "C"
|
import "C"
|
||||||
import "unsafe"
|
import "unsafe"
|
||||||
|
|
||||||
|
// Texture format
|
||||||
type TextureFormat int32
|
type TextureFormat int32
|
||||||
|
|
||||||
// Texture formats
|
// Texture formats
|
||||||
|
@ -50,6 +51,7 @@ const (
|
||||||
CompressedAstc8x8Rgba TextureFormat = C.COMPRESSED_ASTC_8x8_RGBA
|
CompressedAstc8x8Rgba TextureFormat = C.COMPRESSED_ASTC_8x8_RGBA
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Texture filter mode
|
||||||
type TextureFilterMode int32
|
type TextureFilterMode int32
|
||||||
|
|
||||||
// Texture parameters: filter mode
|
// Texture parameters: filter mode
|
||||||
|
@ -70,6 +72,7 @@ const (
|
||||||
FilterAnisotropic16x TextureFilterMode = C.FILTER_ANISOTROPIC_16X
|
FilterAnisotropic16x TextureFilterMode = C.FILTER_ANISOTROPIC_16X
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Texture wrap mode
|
||||||
type TextureWrapMode int32
|
type TextureWrapMode int32
|
||||||
|
|
||||||
// Texture parameters: wrap mode
|
// Texture parameters: wrap mode
|
||||||
|
@ -112,7 +115,7 @@ func NewImageFromPointer(ptr unsafe.Pointer) *Image {
|
||||||
// NOTE: Data stored in GPU memory
|
// NOTE: Data stored in GPU memory
|
||||||
type Texture2D struct {
|
type Texture2D struct {
|
||||||
// OpenGL texture id
|
// OpenGL texture id
|
||||||
Id uint32
|
ID uint32
|
||||||
// Texture base width
|
// Texture base width
|
||||||
Width int32
|
Width int32
|
||||||
// Texture base height
|
// Texture base height
|
||||||
|
@ -140,7 +143,7 @@ func NewTexture2DFromPointer(ptr unsafe.Pointer) Texture2D {
|
||||||
// RenderTexture2D type, for texture rendering
|
// RenderTexture2D type, for texture rendering
|
||||||
type RenderTexture2D struct {
|
type RenderTexture2D struct {
|
||||||
// Render texture (fbo) id
|
// Render texture (fbo) id
|
||||||
Id uint32
|
ID uint32
|
||||||
// Color buffer attachment texture
|
// Color buffer attachment texture
|
||||||
Texture Texture2D
|
Texture Texture2D
|
||||||
// Depth buffer attachment texture
|
// Depth buffer attachment texture
|
||||||
|
|
|
@ -17,6 +17,7 @@ const (
|
||||||
|
|
||||||
var traceDebugMsgs = false
|
var traceDebugMsgs = false
|
||||||
|
|
||||||
|
// Trace log
|
||||||
func TraceLog(msgType int, text string, v ...interface{}) {
|
func TraceLog(msgType int, text string, v ...interface{}) {
|
||||||
switch msgType {
|
switch msgType {
|
||||||
case LogInfo:
|
case LogInfo:
|
||||||
|
@ -33,6 +34,7 @@ func TraceLog(msgType int, text string, v ...interface{}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set debug messages
|
||||||
func SetDebug(enabled bool) {
|
func SetDebug(enabled bool) {
|
||||||
traceDebugMsgs = enabled
|
traceDebugMsgs = enabled
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue