Update/add Go functions
This commit is contained in:
parent
607adace28
commit
2013bc4628
17 changed files with 268 additions and 211 deletions
|
@ -4,7 +4,7 @@ import rl "github.com/gen2brain/raylib-go/raylib"
|
|||
|
||||
// Label - Label element, show text
|
||||
func Label(bounds rl.Rectangle, text string) {
|
||||
LabelEx(bounds, text, rl.GetColor(int32(style[LabelTextColor])), rl.NewColor(0, 0, 0, 0), rl.NewColor(0, 0, 0, 0))
|
||||
LabelEx(bounds, text, rl.GetColor(uint(style[LabelTextColor])), rl.NewColor(0, 0, 0, 0), rl.NewColor(0, 0, 0, 0))
|
||||
}
|
||||
|
||||
// LabelEx - Label element extended, configurable colors
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package raygui
|
||||
|
||||
import "github.com/gen2brain/raylib-go/raylib"
|
||||
import rl "github.com/gen2brain/raylib-go/raylib"
|
||||
|
||||
// Slider - Slider element, returns selected value
|
||||
func Slider(bounds rl.Rectangle, value, minValue, maxValue float32) float32 {
|
||||
|
@ -55,18 +55,18 @@ func Slider(bounds rl.Rectangle, value, minValue, maxValue float32) float32 {
|
|||
}
|
||||
|
||||
// Draw control
|
||||
rl.DrawRectangle(b.X, b.Y, b.Width, b.Height, rl.GetColor(int32(style[SliderBorderColor])))
|
||||
rl.DrawRectangle(b.X+int32(style[SliderBorderWidth]), b.Y+int32(style[SliderBorderWidth]), b.Width-(2*int32(style[SliderBorderWidth])), b.Height-(2*int32(style[SliderBorderWidth])), rl.GetColor(int32(style[SliderInsideColor])))
|
||||
rl.DrawRectangle(b.X, b.Y, b.Width, b.Height, rl.GetColor(uint(style[SliderBorderColor])))
|
||||
rl.DrawRectangle(b.X+int32(style[SliderBorderWidth]), b.Y+int32(style[SliderBorderWidth]), b.Width-(2*int32(style[SliderBorderWidth])), b.Height-(2*int32(style[SliderBorderWidth])), rl.GetColor(uint(style[SliderInsideColor])))
|
||||
|
||||
switch state {
|
||||
case Normal:
|
||||
rl.DrawRectangle(sliderButton.X, sliderButton.Y, sliderButton.Width, sliderButton.Height, rl.GetColor(int32(style[SliderDefaultColor])))
|
||||
rl.DrawRectangle(sliderButton.X, sliderButton.Y, sliderButton.Width, sliderButton.Height, rl.GetColor(uint(style[SliderDefaultColor])))
|
||||
break
|
||||
case Focused:
|
||||
rl.DrawRectangle(sliderButton.X, sliderButton.Y, sliderButton.Width, sliderButton.Height, rl.GetColor(int32(style[SliderHoverColor])))
|
||||
rl.DrawRectangle(sliderButton.X, sliderButton.Y, sliderButton.Width, sliderButton.Height, rl.GetColor(uint(style[SliderHoverColor])))
|
||||
break
|
||||
case Pressed:
|
||||
rl.DrawRectangle(sliderButton.X, sliderButton.Y, sliderButton.Width, sliderButton.Height, rl.GetColor(int32(style[SliderActiveColor])))
|
||||
rl.DrawRectangle(sliderButton.X, sliderButton.Y, sliderButton.Width, sliderButton.Height, rl.GetColor(uint(style[SliderActiveColor])))
|
||||
break
|
||||
default:
|
||||
break
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package raygui
|
||||
|
||||
import "github.com/gen2brain/raylib-go/raylib"
|
||||
import rl "github.com/gen2brain/raylib-go/raylib"
|
||||
|
||||
// SliderBar - Slider Bar element, returns selected value
|
||||
func SliderBar(bounds rl.Rectangle, value, minValue, maxValue float32) float32 {
|
||||
|
@ -51,25 +51,25 @@ func SliderBar(bounds rl.Rectangle, value, minValue, maxValue float32) float32 {
|
|||
fixedValue = (float32(sliderBar.Width) * (maxValue - fixedMinValue)) / (float32(b.Width) - 2*float32(style[SliderBorderWidth]))
|
||||
|
||||
// Draw control
|
||||
rl.DrawRectangle(b.X, b.Y, b.Width, b.Height, rl.GetColor(int32(style[SliderbarBorderColor])))
|
||||
rl.DrawRectangle(b.X+int32(style[SliderBorderWidth]), b.Y+int32(style[SliderBorderWidth]), b.Width-(2*int32(style[SliderBorderWidth])), b.Height-(2*int32(style[SliderBorderWidth])), rl.GetColor(int32(style[SliderbarInsideColor])))
|
||||
rl.DrawRectangle(b.X, b.Y, b.Width, b.Height, rl.GetColor(uint(style[SliderbarBorderColor])))
|
||||
rl.DrawRectangle(b.X+int32(style[SliderBorderWidth]), b.Y+int32(style[SliderBorderWidth]), b.Width-(2*int32(style[SliderBorderWidth])), b.Height-(2*int32(style[SliderBorderWidth])), rl.GetColor(uint(style[SliderbarInsideColor])))
|
||||
|
||||
switch state {
|
||||
case Normal:
|
||||
rl.DrawRectangle(sliderBar.X, sliderBar.Y, sliderBar.Width, sliderBar.Height, rl.GetColor(int32(style[SliderbarDefaultColor])))
|
||||
rl.DrawRectangle(sliderBar.X, sliderBar.Y, sliderBar.Width, sliderBar.Height, rl.GetColor(uint(style[SliderbarDefaultColor])))
|
||||
break
|
||||
case Focused:
|
||||
rl.DrawRectangle(sliderBar.X, sliderBar.Y, sliderBar.Width, sliderBar.Height, rl.GetColor(int32(style[SliderbarHoverColor])))
|
||||
rl.DrawRectangle(sliderBar.X, sliderBar.Y, sliderBar.Width, sliderBar.Height, rl.GetColor(uint(style[SliderbarHoverColor])))
|
||||
break
|
||||
case Pressed:
|
||||
rl.DrawRectangle(sliderBar.X, sliderBar.Y, sliderBar.Width, sliderBar.Height, rl.GetColor(int32(style[SliderbarActiveColor])))
|
||||
rl.DrawRectangle(sliderBar.X, sliderBar.Y, sliderBar.Width, sliderBar.Height, rl.GetColor(uint(style[SliderbarActiveColor])))
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
||||
if minValue < 0 && maxValue > 0 {
|
||||
rl.DrawRectangle((b.X+int32(style[SliderBorderWidth]))-int32(minValue*(float32(b.Width-(int32(style[SliderBorderWidth])*2))/maxValue)), sliderBar.Y, 1, sliderBar.Height, rl.GetColor(int32(style[SliderbarZeroLineColor])))
|
||||
rl.DrawRectangle((b.X+int32(style[SliderBorderWidth]))-int32(minValue*(float32(b.Width-(int32(style[SliderBorderWidth])*2))/maxValue)), sliderBar.Y, 1, sliderBar.Height, rl.GetColor(uint(style[SliderbarZeroLineColor])))
|
||||
}
|
||||
|
||||
return fixedValue + minValue
|
||||
|
|
|
@ -2,7 +2,8 @@ package raygui
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
|
||||
rl "github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
// For spinner
|
||||
|
@ -102,71 +103,71 @@ func Spinner(bounds rl.Rectangle, value, minValue, maxValue int) int {
|
|||
// Draw control
|
||||
switch state {
|
||||
case Normal:
|
||||
rl.DrawRectangle(leftButtonBound.X, leftButtonBound.Y, leftButtonBound.Width, leftButtonBound.Height, rl.GetColor(int32(style[SpinnerDefaultButtonBorderColor])))
|
||||
rl.DrawRectangle(leftButtonBound.X+2, leftButtonBound.Y+2, leftButtonBound.Width-4, leftButtonBound.Height-4, rl.GetColor(int32(style[SpinnerDefaultButtonInsideColor])))
|
||||
rl.DrawRectangle(leftButtonBound.X, leftButtonBound.Y, leftButtonBound.Width, leftButtonBound.Height, rl.GetColor(uint(style[SpinnerDefaultButtonBorderColor])))
|
||||
rl.DrawRectangle(leftButtonBound.X+2, leftButtonBound.Y+2, leftButtonBound.Width-4, leftButtonBound.Height-4, rl.GetColor(uint(style[SpinnerDefaultButtonInsideColor])))
|
||||
|
||||
rl.DrawRectangle(rightButtonBound.X, rightButtonBound.Y, rightButtonBound.Width, rightButtonBound.Height, rl.GetColor(int32(style[SpinnerDefaultButtonBorderColor])))
|
||||
rl.DrawRectangle(rightButtonBound.X+2, rightButtonBound.Y+2, rightButtonBound.Width-4, rightButtonBound.Height-4, rl.GetColor(int32(style[SpinnerDefaultButtonInsideColor])))
|
||||
rl.DrawRectangle(rightButtonBound.X, rightButtonBound.Y, rightButtonBound.Width, rightButtonBound.Height, rl.GetColor(uint(style[SpinnerDefaultButtonBorderColor])))
|
||||
rl.DrawRectangle(rightButtonBound.X+2, rightButtonBound.Y+2, rightButtonBound.Width-4, rightButtonBound.Height-4, rl.GetColor(uint(style[SpinnerDefaultButtonInsideColor])))
|
||||
|
||||
rl.DrawText("-", leftButtonBound.X+(leftButtonBound.Width/2-(rl.MeasureText("+", textHeight))/2), leftButtonBound.Y+(leftButtonBound.Height/2-(textHeight/2)), textHeight, rl.GetColor(int32(style[SpinnerDefaultSymbolColor])))
|
||||
rl.DrawText("+", rightButtonBound.X+(rightButtonBound.Width/2-(rl.MeasureText("-", textHeight))/2), rightButtonBound.Y+(rightButtonBound.Height/2-(textHeight/2)), textHeight, rl.GetColor(int32(style[SpinnerDefaultSymbolColor])))
|
||||
rl.DrawText("-", leftButtonBound.X+(leftButtonBound.Width/2-(rl.MeasureText("+", textHeight))/2), leftButtonBound.Y+(leftButtonBound.Height/2-(textHeight/2)), textHeight, rl.GetColor(uint(style[SpinnerDefaultSymbolColor])))
|
||||
rl.DrawText("+", rightButtonBound.X+(rightButtonBound.Width/2-(rl.MeasureText("-", textHeight))/2), rightButtonBound.Y+(rightButtonBound.Height/2-(textHeight/2)), textHeight, rl.GetColor(uint(style[SpinnerDefaultSymbolColor])))
|
||||
|
||||
rl.DrawRectangle(labelBoxBound.X, labelBoxBound.Y, labelBoxBound.Width, labelBoxBound.Height, rl.GetColor(int32(style[SpinnerLabelBorderColor])))
|
||||
rl.DrawRectangle(labelBoxBound.X+1, labelBoxBound.Y+1, labelBoxBound.Width-2, labelBoxBound.Height-2, rl.GetColor(int32(style[SpinnerLabelInsideColor])))
|
||||
rl.DrawRectangle(labelBoxBound.X, labelBoxBound.Y, labelBoxBound.Width, labelBoxBound.Height, rl.GetColor(uint(style[SpinnerLabelBorderColor])))
|
||||
rl.DrawRectangle(labelBoxBound.X+1, labelBoxBound.Y+1, labelBoxBound.Width-2, labelBoxBound.Height-2, rl.GetColor(uint(style[SpinnerLabelInsideColor])))
|
||||
|
||||
rl.DrawText(fmt.Sprintf("%d", value), labelBoxBound.X+(labelBoxBound.Width/2-textWidth/2), labelBoxBound.Y+(labelBoxBound.Height/2-(textHeight/2)), textHeight, rl.GetColor(int32(style[SpinnerDefaultTextColor])))
|
||||
rl.DrawText(fmt.Sprintf("%d", value), labelBoxBound.X+(labelBoxBound.Width/2-textWidth/2), labelBoxBound.Y+(labelBoxBound.Height/2-(textHeight/2)), textHeight, rl.GetColor(uint(style[SpinnerDefaultTextColor])))
|
||||
break
|
||||
case Focused:
|
||||
if buttonSide == 1 {
|
||||
rl.DrawRectangle(leftButtonBound.X, leftButtonBound.Y, leftButtonBound.Width, leftButtonBound.Height, rl.GetColor(int32(style[SpinnerHoverButtonBorderColor])))
|
||||
rl.DrawRectangle(leftButtonBound.X+2, leftButtonBound.Y+2, leftButtonBound.Width-4, leftButtonBound.Height-4, rl.GetColor(int32(style[SpinnerHoverButtonInsideColor])))
|
||||
rl.DrawRectangle(leftButtonBound.X, leftButtonBound.Y, leftButtonBound.Width, leftButtonBound.Height, rl.GetColor(uint(style[SpinnerHoverButtonBorderColor])))
|
||||
rl.DrawRectangle(leftButtonBound.X+2, leftButtonBound.Y+2, leftButtonBound.Width-4, leftButtonBound.Height-4, rl.GetColor(uint(style[SpinnerHoverButtonInsideColor])))
|
||||
|
||||
rl.DrawRectangle(rightButtonBound.X, rightButtonBound.Y, rightButtonBound.Width, rightButtonBound.Height, rl.GetColor(int32(style[SpinnerDefaultButtonBorderColor])))
|
||||
rl.DrawRectangle(rightButtonBound.X+2, rightButtonBound.Y+2, rightButtonBound.Width-4, rightButtonBound.Height-4, rl.GetColor(int32(style[SpinnerDefaultButtonInsideColor])))
|
||||
rl.DrawRectangle(rightButtonBound.X, rightButtonBound.Y, rightButtonBound.Width, rightButtonBound.Height, rl.GetColor(uint(style[SpinnerDefaultButtonBorderColor])))
|
||||
rl.DrawRectangle(rightButtonBound.X+2, rightButtonBound.Y+2, rightButtonBound.Width-4, rightButtonBound.Height-4, rl.GetColor(uint(style[SpinnerDefaultButtonInsideColor])))
|
||||
|
||||
rl.DrawText("-", leftButtonBound.X+(leftButtonBound.Width/2-(rl.MeasureText("+", textHeight))/2), leftButtonBound.Y+(leftButtonBound.Height/2-(textHeight/2)), textHeight, rl.GetColor(int32(style[SpinnerHoverSymbolColor])))
|
||||
rl.DrawText("+", rightButtonBound.X+(rightButtonBound.Width/2-(rl.MeasureText("-", textHeight))/2), rightButtonBound.Y+(rightButtonBound.Height/2-(textHeight/2)), textHeight, rl.GetColor(int32(style[SpinnerDefaultSymbolColor])))
|
||||
rl.DrawText("-", leftButtonBound.X+(leftButtonBound.Width/2-(rl.MeasureText("+", textHeight))/2), leftButtonBound.Y+(leftButtonBound.Height/2-(textHeight/2)), textHeight, rl.GetColor(uint(style[SpinnerHoverSymbolColor])))
|
||||
rl.DrawText("+", rightButtonBound.X+(rightButtonBound.Width/2-(rl.MeasureText("-", textHeight))/2), rightButtonBound.Y+(rightButtonBound.Height/2-(textHeight/2)), textHeight, rl.GetColor(uint(style[SpinnerDefaultSymbolColor])))
|
||||
} else if buttonSide == 2 {
|
||||
rl.DrawRectangle(leftButtonBound.X, leftButtonBound.Y, leftButtonBound.Width, leftButtonBound.Height, rl.GetColor(int32(style[SpinnerDefaultButtonBorderColor])))
|
||||
rl.DrawRectangle(leftButtonBound.X+2, leftButtonBound.Y+2, leftButtonBound.Width-4, leftButtonBound.Height-4, rl.GetColor(int32(style[SpinnerDefaultButtonInsideColor])))
|
||||
rl.DrawRectangle(leftButtonBound.X, leftButtonBound.Y, leftButtonBound.Width, leftButtonBound.Height, rl.GetColor(uint(style[SpinnerDefaultButtonBorderColor])))
|
||||
rl.DrawRectangle(leftButtonBound.X+2, leftButtonBound.Y+2, leftButtonBound.Width-4, leftButtonBound.Height-4, rl.GetColor(uint(style[SpinnerDefaultButtonInsideColor])))
|
||||
|
||||
rl.DrawRectangle(rightButtonBound.X, rightButtonBound.Y, rightButtonBound.Width, rightButtonBound.Height, rl.GetColor(int32(style[SpinnerHoverButtonBorderColor])))
|
||||
rl.DrawRectangle(rightButtonBound.X+2, rightButtonBound.Y+2, rightButtonBound.Width-4, rightButtonBound.Height-4, rl.GetColor(int32(style[SpinnerHoverButtonInsideColor])))
|
||||
rl.DrawRectangle(rightButtonBound.X, rightButtonBound.Y, rightButtonBound.Width, rightButtonBound.Height, rl.GetColor(uint(style[SpinnerHoverButtonBorderColor])))
|
||||
rl.DrawRectangle(rightButtonBound.X+2, rightButtonBound.Y+2, rightButtonBound.Width-4, rightButtonBound.Height-4, rl.GetColor(uint(style[SpinnerHoverButtonInsideColor])))
|
||||
|
||||
rl.DrawText("-", leftButtonBound.X+(leftButtonBound.Width/2-(rl.MeasureText("+", textHeight))/2), leftButtonBound.Y+(leftButtonBound.Height/2-(textHeight/2)), textHeight, rl.GetColor(int32(style[SpinnerDefaultSymbolColor])))
|
||||
rl.DrawText("+", rightButtonBound.X+(rightButtonBound.Width/2-(rl.MeasureText("-", textHeight))/2), rightButtonBound.Y+(rightButtonBound.Height/2-(textHeight/2)), textHeight, rl.GetColor(int32(style[SpinnerHoverSymbolColor])))
|
||||
rl.DrawText("-", leftButtonBound.X+(leftButtonBound.Width/2-(rl.MeasureText("+", textHeight))/2), leftButtonBound.Y+(leftButtonBound.Height/2-(textHeight/2)), textHeight, rl.GetColor(uint(style[SpinnerDefaultSymbolColor])))
|
||||
rl.DrawText("+", rightButtonBound.X+(rightButtonBound.Width/2-(rl.MeasureText("-", textHeight))/2), rightButtonBound.Y+(rightButtonBound.Height/2-(textHeight/2)), textHeight, rl.GetColor(uint(style[SpinnerHoverSymbolColor])))
|
||||
}
|
||||
|
||||
rl.DrawRectangle(labelBoxBound.X, labelBoxBound.Y, labelBoxBound.Width, labelBoxBound.Height, rl.GetColor(int32(style[SpinnerLabelBorderColor])))
|
||||
rl.DrawRectangle(labelBoxBound.X+1, labelBoxBound.Y+1, labelBoxBound.Width-2, labelBoxBound.Height-2, rl.GetColor(int32(style[SpinnerLabelInsideColor])))
|
||||
rl.DrawRectangle(labelBoxBound.X, labelBoxBound.Y, labelBoxBound.Width, labelBoxBound.Height, rl.GetColor(uint(style[SpinnerLabelBorderColor])))
|
||||
rl.DrawRectangle(labelBoxBound.X+1, labelBoxBound.Y+1, labelBoxBound.Width-2, labelBoxBound.Height-2, rl.GetColor(uint(style[SpinnerLabelInsideColor])))
|
||||
|
||||
rl.DrawText(fmt.Sprintf("%d", value), labelBoxBound.X+(labelBoxBound.Width/2-textWidth/2), labelBoxBound.Y+(labelBoxBound.Height/2-(textHeight/2)), textHeight, rl.GetColor(int32(style[SpinnerHoverTextColor])))
|
||||
rl.DrawText(fmt.Sprintf("%d", value), labelBoxBound.X+(labelBoxBound.Width/2-textWidth/2), labelBoxBound.Y+(labelBoxBound.Height/2-(textHeight/2)), textHeight, rl.GetColor(uint(style[SpinnerHoverTextColor])))
|
||||
break
|
||||
case Pressed:
|
||||
if buttonSide == 1 {
|
||||
rl.DrawRectangle(leftButtonBound.X, leftButtonBound.Y, leftButtonBound.Width, leftButtonBound.Height, rl.GetColor(int32(style[SpinnerPressedButtonBorderColor])))
|
||||
rl.DrawRectangle(leftButtonBound.X+2, leftButtonBound.Y+2, leftButtonBound.Width-4, leftButtonBound.Height-4, rl.GetColor(int32(style[SpinnerPressedButtonInsideColor])))
|
||||
rl.DrawRectangle(leftButtonBound.X, leftButtonBound.Y, leftButtonBound.Width, leftButtonBound.Height, rl.GetColor(uint(style[SpinnerPressedButtonBorderColor])))
|
||||
rl.DrawRectangle(leftButtonBound.X+2, leftButtonBound.Y+2, leftButtonBound.Width-4, leftButtonBound.Height-4, rl.GetColor(uint(style[SpinnerPressedButtonInsideColor])))
|
||||
|
||||
rl.DrawRectangle(rightButtonBound.X, rightButtonBound.Y, rightButtonBound.Width, rightButtonBound.Height, rl.GetColor(int32(style[SpinnerDefaultButtonBorderColor])))
|
||||
rl.DrawRectangle(rightButtonBound.X+2, rightButtonBound.Y+2, rightButtonBound.Width-4, rightButtonBound.Height-4, rl.GetColor(int32(style[SpinnerDefaultButtonInsideColor])))
|
||||
rl.DrawRectangle(rightButtonBound.X, rightButtonBound.Y, rightButtonBound.Width, rightButtonBound.Height, rl.GetColor(uint(style[SpinnerDefaultButtonBorderColor])))
|
||||
rl.DrawRectangle(rightButtonBound.X+2, rightButtonBound.Y+2, rightButtonBound.Width-4, rightButtonBound.Height-4, rl.GetColor(uint(style[SpinnerDefaultButtonInsideColor])))
|
||||
|
||||
rl.DrawText("-", leftButtonBound.X+(leftButtonBound.Width/2-(rl.MeasureText("+", textHeight))/2), leftButtonBound.Y+(leftButtonBound.Height/2-(textHeight/2)), textHeight, rl.GetColor(int32(style[SpinnerPressedSymbolColor])))
|
||||
rl.DrawText("+", rightButtonBound.X+(rightButtonBound.Width/2-(rl.MeasureText("-", textHeight))/2), rightButtonBound.Y+(rightButtonBound.Height/2-(textHeight/2)), textHeight, rl.GetColor(int32(style[SpinnerDefaultSymbolColor])))
|
||||
rl.DrawText("-", leftButtonBound.X+(leftButtonBound.Width/2-(rl.MeasureText("+", textHeight))/2), leftButtonBound.Y+(leftButtonBound.Height/2-(textHeight/2)), textHeight, rl.GetColor(uint(style[SpinnerPressedSymbolColor])))
|
||||
rl.DrawText("+", rightButtonBound.X+(rightButtonBound.Width/2-(rl.MeasureText("-", textHeight))/2), rightButtonBound.Y+(rightButtonBound.Height/2-(textHeight/2)), textHeight, rl.GetColor(uint(style[SpinnerDefaultSymbolColor])))
|
||||
} else if buttonSide == 2 {
|
||||
rl.DrawRectangle(leftButtonBound.X, leftButtonBound.Y, leftButtonBound.Width, leftButtonBound.Height, rl.GetColor(int32(style[SpinnerDefaultButtonBorderColor])))
|
||||
rl.DrawRectangle(leftButtonBound.X+2, leftButtonBound.Y+2, leftButtonBound.Width-4, leftButtonBound.Height-4, rl.GetColor(int32(style[SpinnerDefaultButtonInsideColor])))
|
||||
rl.DrawRectangle(leftButtonBound.X, leftButtonBound.Y, leftButtonBound.Width, leftButtonBound.Height, rl.GetColor(uint(style[SpinnerDefaultButtonBorderColor])))
|
||||
rl.DrawRectangle(leftButtonBound.X+2, leftButtonBound.Y+2, leftButtonBound.Width-4, leftButtonBound.Height-4, rl.GetColor(uint(style[SpinnerDefaultButtonInsideColor])))
|
||||
|
||||
rl.DrawRectangle(rightButtonBound.X, rightButtonBound.Y, rightButtonBound.Width, rightButtonBound.Height, rl.GetColor(int32(style[SpinnerPressedButtonBorderColor])))
|
||||
rl.DrawRectangle(rightButtonBound.X+2, rightButtonBound.Y+2, rightButtonBound.Width-4, rightButtonBound.Height-4, rl.GetColor(int32(style[SpinnerPressedButtonInsideColor])))
|
||||
rl.DrawRectangle(rightButtonBound.X, rightButtonBound.Y, rightButtonBound.Width, rightButtonBound.Height, rl.GetColor(uint(style[SpinnerPressedButtonBorderColor])))
|
||||
rl.DrawRectangle(rightButtonBound.X+2, rightButtonBound.Y+2, rightButtonBound.Width-4, rightButtonBound.Height-4, rl.GetColor(uint(style[SpinnerPressedButtonInsideColor])))
|
||||
|
||||
rl.DrawText("-", leftButtonBound.X+(leftButtonBound.Width/2-(rl.MeasureText("+", textHeight))/2), leftButtonBound.Y+(leftButtonBound.Height/2-(textHeight/2)), textHeight, rl.GetColor(int32(style[SpinnerDefaultSymbolColor])))
|
||||
rl.DrawText("+", rightButtonBound.X+(rightButtonBound.Width/2-(rl.MeasureText("-", textHeight))/2), rightButtonBound.Y+(rightButtonBound.Height/2-(textHeight/2)), textHeight, rl.GetColor(int32(style[SpinnerPressedSymbolColor])))
|
||||
rl.DrawText("-", leftButtonBound.X+(leftButtonBound.Width/2-(rl.MeasureText("+", textHeight))/2), leftButtonBound.Y+(leftButtonBound.Height/2-(textHeight/2)), textHeight, rl.GetColor(uint(style[SpinnerDefaultSymbolColor])))
|
||||
rl.DrawText("+", rightButtonBound.X+(rightButtonBound.Width/2-(rl.MeasureText("-", textHeight))/2), rightButtonBound.Y+(rightButtonBound.Height/2-(textHeight/2)), textHeight, rl.GetColor(uint(style[SpinnerPressedSymbolColor])))
|
||||
}
|
||||
|
||||
rl.DrawRectangle(labelBoxBound.X, labelBoxBound.Y, labelBoxBound.Width, labelBoxBound.Height, rl.GetColor(int32(style[SpinnerLabelBorderColor])))
|
||||
rl.DrawRectangle(labelBoxBound.X+1, labelBoxBound.Y+1, labelBoxBound.Width-2, labelBoxBound.Height-2, rl.GetColor(int32(style[SpinnerLabelInsideColor])))
|
||||
rl.DrawRectangle(labelBoxBound.X, labelBoxBound.Y, labelBoxBound.Width, labelBoxBound.Height, rl.GetColor(uint(style[SpinnerLabelBorderColor])))
|
||||
rl.DrawRectangle(labelBoxBound.X+1, labelBoxBound.Y+1, labelBoxBound.Width-2, labelBoxBound.Height-2, rl.GetColor(uint(style[SpinnerLabelInsideColor])))
|
||||
|
||||
rl.DrawText(fmt.Sprintf("%d", value), labelBoxBound.X+(labelBoxBound.Width/2-textWidth/2), labelBoxBound.Y+(labelBoxBound.Height/2-(textHeight/2)), textHeight, rl.GetColor(int32(style[SpinnerPressedTextColor])))
|
||||
rl.DrawText(fmt.Sprintf("%d", value), labelBoxBound.X+(labelBoxBound.Width/2-textWidth/2), labelBoxBound.Y+(labelBoxBound.Height/2-(textHeight/2)), textHeight, rl.GetColor(uint(style[SpinnerPressedTextColor])))
|
||||
break
|
||||
default:
|
||||
break
|
||||
|
|
|
@ -5,10 +5,11 @@ package raygui
|
|||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
rl "github.com/gen2brain/raylib-go/raylib"
|
||||
"io/ioutil"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
rl "github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
// Property - GUI property
|
||||
|
@ -394,17 +395,17 @@ func GetStyleProperty(guiProperty Property) int64 {
|
|||
|
||||
// BackgroundColor will return the current background color
|
||||
func BackgroundColor() rl.Color {
|
||||
return rl.GetColor(int32(style[GlobalBackgroundColor]))
|
||||
return rl.GetColor(uint(style[GlobalBackgroundColor]))
|
||||
}
|
||||
|
||||
// LinesColor will return the current color for lines
|
||||
func LinesColor() rl.Color {
|
||||
return rl.GetColor(int32(style[GlobalLinesColor]))
|
||||
return rl.GetColor(uint(style[GlobalLinesColor]))
|
||||
}
|
||||
|
||||
// TextColor will return the current color for normal state
|
||||
func TextColor() rl.Color {
|
||||
return rl.GetColor(int32(style[GlobalTextColor]))
|
||||
return rl.GetColor(uint(style[GlobalTextColor]))
|
||||
}
|
||||
|
||||
// GetStyle32 will return the int32 for a given property of the current style
|
||||
|
@ -414,5 +415,5 @@ func GetStyle32(property Property) int32 {
|
|||
|
||||
// GetPropColor will return the Color value for a given property of the current style
|
||||
func GetStyleColor(property Property) rl.Color {
|
||||
return rl.GetColor(int32(style[property]))
|
||||
return rl.GetColor(uint(style[property]))
|
||||
}
|
||||
|
|
|
@ -2,8 +2,9 @@ package raygui
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
"time"
|
||||
|
||||
rl "github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
var backspaceHeld = false
|
||||
|
@ -11,6 +12,7 @@ var nextBackspace = time.Now()
|
|||
|
||||
// BackspaceRepeatDelay controls the time backspace must be held down before it will repeat.
|
||||
var BackspaceRepeatDelay = 300 * time.Millisecond
|
||||
|
||||
// BackspaceRepeatInterval controls how frequently backspace registers after the initial delay.
|
||||
var BackspaceRepeatInterval = 60 * time.Millisecond
|
||||
|
||||
|
@ -54,7 +56,7 @@ func TextBox(bounds rl.Rectangle, text string) string {
|
|||
if state == Focused || state == Pressed {
|
||||
// Draw a cursor, when focused.
|
||||
if (framesCounter2/20)%2 == 0 {
|
||||
rl.DrawRectangle(b.X+4+rl.MeasureText(text, int32(style[GlobalTextFontsize])), b.Y+2, 1, b.Height-4, rl.GetColor(int32(style[TextboxLineColor])))
|
||||
rl.DrawRectangle(b.X+4+rl.MeasureText(text, int32(style[GlobalTextFontsize])), b.Y+2, 1, b.Height-4, rl.GetColor(uint(style[TextboxLineColor])))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package rl
|
||||
|
||||
/*
|
||||
#cgo CFLAGS: -std=gnu99 -Wno-missing-braces -Wno-unused-result
|
||||
#cgo CFLAGS: -std=gnu99 -Wno-missing-braces -Wno-unused-result -Wno-implicit-function-declaration
|
||||
*/
|
||||
import "C"
|
||||
|
|
105
raylib/raudio.go
105
raylib/raudio.go
|
@ -1,3 +1,4 @@
|
|||
//go:build !noaudio
|
||||
// +build !noaudio
|
||||
|
||||
package rl
|
||||
|
@ -9,8 +10,10 @@ package rl
|
|||
#include <stdlib.h>
|
||||
*/
|
||||
import "C"
|
||||
import "unsafe"
|
||||
import "reflect"
|
||||
import (
|
||||
"reflect"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// cptr returns C pointer
|
||||
func (w *Wave) cptr() *C.Wave {
|
||||
|
@ -120,6 +123,12 @@ func PlaySound(sound Sound) {
|
|||
C.PlaySound(*csound)
|
||||
}
|
||||
|
||||
// StopSound - Stop playing a sound
|
||||
func StopSound(sound Sound) {
|
||||
csound := sound.cptr()
|
||||
C.StopSound(*csound)
|
||||
}
|
||||
|
||||
// PauseSound - Pause a sound
|
||||
func PauseSound(sound Sound) {
|
||||
csound := sound.cptr()
|
||||
|
@ -132,10 +141,22 @@ func ResumeSound(sound Sound) {
|
|||
C.ResumeSound(*csound)
|
||||
}
|
||||
|
||||
// StopSound - Stop playing a sound
|
||||
func StopSound(sound Sound) {
|
||||
// PlaySoundMulti - Play a sound (using multichannel buffer pool)
|
||||
func PlaySoundMulti(sound Sound) {
|
||||
csound := sound.cptr()
|
||||
C.StopSound(*csound)
|
||||
C.PlaySoundMulti(*csound)
|
||||
}
|
||||
|
||||
// StopSoundMulti - Stop any sound playing (using multichannel buffer pool)
|
||||
func StopSoundMulti() {
|
||||
C.StopSoundMulti()
|
||||
}
|
||||
|
||||
// GetSoundsPlaying - Get number of sounds playing in the multichannel
|
||||
func GetSoundsPlaying() int {
|
||||
ret := C.GetSoundsPlaying()
|
||||
v := int(ret)
|
||||
return v
|
||||
}
|
||||
|
||||
// IsSoundPlaying - Check if a sound is currently playing
|
||||
|
@ -199,6 +220,11 @@ func LoadWaveSamples(wave Wave) []float32 {
|
|||
return data
|
||||
}
|
||||
|
||||
// UnloadWaveSamples - Unload samples data loaded with LoadWaveSamples()
|
||||
func UnloadWaveSamples(samples []float32) {
|
||||
C.UnloadWaveSamples((*C.float)(unsafe.Pointer(&samples[0])))
|
||||
}
|
||||
|
||||
// LoadMusicStream - Load music stream from file
|
||||
func LoadMusicStream(fileName string) Music {
|
||||
cfileName := C.CString(fileName)
|
||||
|
@ -231,6 +257,14 @@ func PlayMusicStream(music Music) {
|
|||
C.PlayMusicStream(cmusic)
|
||||
}
|
||||
|
||||
// IsMusicStreamPlaying - Check if music is playing
|
||||
func IsMusicStreamPlaying(music Music) bool {
|
||||
cmusic := *(*C.Music)(unsafe.Pointer(&music))
|
||||
ret := C.IsMusicStreamPlaying(cmusic)
|
||||
v := bool(ret)
|
||||
return v
|
||||
}
|
||||
|
||||
// UpdateMusicStream - Updates buffers for music streaming
|
||||
func UpdateMusicStream(music Music) {
|
||||
cmusic := *(*C.Music)(unsafe.Pointer(&music))
|
||||
|
@ -255,12 +289,11 @@ func ResumeMusicStream(music Music) {
|
|||
C.ResumeMusicStream(cmusic)
|
||||
}
|
||||
|
||||
// IsMusicStreamPlaying - Check if music is playing
|
||||
func IsMusicStreamPlaying(music Music) bool {
|
||||
// SeekMusicStream - Seek music to a position (in seconds)
|
||||
func SeekMusicStream(music Music, position float32) {
|
||||
cmusic := *(*C.Music)(unsafe.Pointer(&music))
|
||||
ret := C.IsMusicStreamPlaying(cmusic)
|
||||
v := bool(ret)
|
||||
return v
|
||||
cposition := (C.float)(position)
|
||||
C.SeekMusicStream(cmusic, cposition)
|
||||
}
|
||||
|
||||
// SetMusicVolume - Set volume for music (1.0 is max level)
|
||||
|
@ -293,16 +326,22 @@ func GetMusicTimePlayed(music Music) float32 {
|
|||
return v
|
||||
}
|
||||
|
||||
// InitAudioStream - Init audio stream (to stream raw audio pcm data)
|
||||
func InitAudioStream(sampleRate uint32, sampleSize uint32, channels uint32) AudioStream {
|
||||
// LoadAudioStream - Load audio stream (to stream raw audio pcm data)
|
||||
func LoadAudioStream(sampleRate uint32, sampleSize uint32, channels uint32) AudioStream {
|
||||
csampleRate := (C.uint)(sampleRate)
|
||||
csampleSize := (C.uint)(sampleSize)
|
||||
cchannels := (C.uint)(channels)
|
||||
ret := C.InitAudioStream(csampleRate, csampleSize, cchannels)
|
||||
ret := C.LoadAudioStream(csampleRate, csampleSize, cchannels)
|
||||
v := newAudioStreamFromPointer(unsafe.Pointer(&ret))
|
||||
return v
|
||||
}
|
||||
|
||||
//UnloadAudioStream - Unload audio stream and free memory
|
||||
func UnloadAudioStream(stream AudioStream) {
|
||||
cstream := stream.cptr()
|
||||
C.UnloadAudioStream(*cstream)
|
||||
}
|
||||
|
||||
// UpdateAudioStream - Update audio stream buffers with data
|
||||
func UpdateAudioStream(stream AudioStream, data []float32, samplesCount int32) {
|
||||
cstream := stream.cptr()
|
||||
|
@ -311,12 +350,6 @@ func UpdateAudioStream(stream AudioStream, data []float32, samplesCount int32) {
|
|||
C.UpdateAudioStream(*cstream, cdata, csamplesCount)
|
||||
}
|
||||
|
||||
// CloseAudioStream - Close audio stream and free memory
|
||||
func CloseAudioStream(stream AudioStream) {
|
||||
cstream := stream.cptr()
|
||||
C.CloseAudioStream(*cstream)
|
||||
}
|
||||
|
||||
// IsAudioStreamProcessed - Check if any audio stream buffers requires refill
|
||||
func IsAudioStreamProcessed(stream AudioStream) bool {
|
||||
cstream := stream.cptr()
|
||||
|
@ -343,26 +376,36 @@ func ResumeAudioStream(stream AudioStream) {
|
|||
C.ResumeAudioStream(*cstream)
|
||||
}
|
||||
|
||||
// IsAudioStreamPlaying - Check if audio stream is playing
|
||||
func IsAudioStreamPlaying(stream AudioStream) bool {
|
||||
cstream := stream.cptr()
|
||||
ret := C.IsAudioStreamPlaying(*cstream)
|
||||
v := bool(ret)
|
||||
return v
|
||||
}
|
||||
|
||||
// StopAudioStream - Stop audio stream
|
||||
func StopAudioStream(stream AudioStream) {
|
||||
cstream := stream.cptr()
|
||||
C.StopAudioStream(*cstream)
|
||||
}
|
||||
|
||||
// PlaySoundMulti - Play a sound (using multichannel buffer pool)
|
||||
func PlaySoundMulti(sound Sound) {
|
||||
csound := sound.cptr()
|
||||
C.PlaySoundMulti(*csound)
|
||||
// SetAudioStreamVolume - Set volume for audio stream (1.0 is max level)
|
||||
func SetAudioStreamVolume(stream AudioStream, volume float32) {
|
||||
cstream := stream.cptr()
|
||||
cvolume := (C.float)(volume)
|
||||
C.SetAudioStreamVolume(*cstream, cvolume)
|
||||
}
|
||||
|
||||
// GetSoundsPlaying - Get number of sounds playing in the multichannel
|
||||
func GetSoundsPlaying() int {
|
||||
ret := C.GetSoundsPlaying()
|
||||
v := int(ret)
|
||||
return v
|
||||
// SetAudioStreamPitch - Set pitch for audio stream (1.0 is base level)
|
||||
func SetAudioStreamPitch(stream AudioStream, pitch float32) {
|
||||
cstream := stream.cptr()
|
||||
cpitch := (C.float)(pitch)
|
||||
C.SetAudioStreamPitch(*cstream, cpitch)
|
||||
}
|
||||
|
||||
// StopSoundMulti - Stop any sound playing (using multichannel buffer pool)
|
||||
func StopSoundMulti() {
|
||||
C.StopSoundMulti()
|
||||
// SetAudioStreamBufferSizeDefault - Default size for new audio streams
|
||||
func SetAudioStreamBufferSizeDefault(size int32) {
|
||||
csize := (C.int)(size)
|
||||
C.SetAudioStreamBufferSizeDefault(csize)
|
||||
}
|
||||
|
|
|
@ -894,6 +894,24 @@ func newRayFromPointer(ptr unsafe.Pointer) Ray {
|
|||
return *(*Ray)(ptr)
|
||||
}
|
||||
|
||||
// RayCollision type - ray hit information
|
||||
type RayCollision struct {
|
||||
Hit bool
|
||||
Distance float32
|
||||
Point Vector3
|
||||
Normal Vector3
|
||||
}
|
||||
|
||||
// NewRayCollision - Returns new RayCollision
|
||||
func NewRayCollision(hit bool, distance float32, point, normal Vector3) RayCollision {
|
||||
return RayCollision{hit, distance, point, normal}
|
||||
}
|
||||
|
||||
// newRayCollisionFromPointer - Returns new RayCollision from pointer
|
||||
func newRayCollisionFromPointer(ptr unsafe.Pointer) RayCollision {
|
||||
return *(*RayCollision)(ptr)
|
||||
}
|
||||
|
||||
// BlendMode type
|
||||
type BlendMode int32
|
||||
|
||||
|
@ -935,8 +953,8 @@ func (sh Shader) UpdateLocation(index int32, loc int32) {
|
|||
*(*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(sh.Locs)) + uintptr(index*4))) = loc
|
||||
}
|
||||
|
||||
// CharInfo - Font character info
|
||||
type CharInfo struct {
|
||||
// GlyphInfo - Font character info
|
||||
type GlyphInfo struct {
|
||||
// Character value (Unicode)
|
||||
Value int32
|
||||
// Character offset X when drawing
|
||||
|
@ -949,14 +967,14 @@ type CharInfo struct {
|
|||
Image Image
|
||||
}
|
||||
|
||||
// NewCharInfo - Returns new CharInfo
|
||||
func NewCharInfo(value int32, offsetX, offsetY, advanceX int32, image Image) CharInfo {
|
||||
return CharInfo{value, offsetX, offsetY, advanceX, image}
|
||||
// NewGlyphInfo - Returns new CharInfo
|
||||
func NewGlyphInfo(value int32, offsetX, offsetY, advanceX int32, image Image) GlyphInfo {
|
||||
return GlyphInfo{value, offsetX, offsetY, advanceX, image}
|
||||
}
|
||||
|
||||
// newCharInfoFromPointer - Returns new CharInfo from pointer
|
||||
func newCharInfoFromPointer(ptr unsafe.Pointer) CharInfo {
|
||||
return *(*CharInfo)(ptr)
|
||||
// newGlyphInfoFromPointer - Returns new GlyphInfo from pointer
|
||||
func newGlyphInfoFromPointer(ptr unsafe.Pointer) GlyphInfo {
|
||||
return *(*GlyphInfo)(ptr)
|
||||
}
|
||||
|
||||
// Font type, includes texture and charSet array data
|
||||
|
@ -972,7 +990,7 @@ type Font struct {
|
|||
// Characters rectangles in texture
|
||||
Recs *Rectangle
|
||||
// Characters info data
|
||||
Chars *CharInfo
|
||||
Chars *GlyphInfo
|
||||
}
|
||||
|
||||
// newFontFromPointer - Returns new Font from pointer
|
||||
|
|
|
@ -520,8 +520,8 @@ func ColorAlphaBlend(src, dst, tint Color) Color {
|
|||
}
|
||||
|
||||
// GetColor - Returns a Color struct from hexadecimal value
|
||||
func GetColor(hexValue int32) Color {
|
||||
chexValue := (C.int)(hexValue)
|
||||
func GetColor(hexValue uint) Color {
|
||||
chexValue := (C.uint)(hexValue)
|
||||
ret := C.GetColor(chexValue)
|
||||
v := newColorFromPointer(unsafe.Pointer(&ret))
|
||||
return v
|
||||
|
@ -668,16 +668,6 @@ func IsGamepadAvailable(gamepad int32) bool {
|
|||
return v
|
||||
}
|
||||
|
||||
// IsGamepadName - Check gamepad name (if available)
|
||||
func IsGamepadName(gamepad int32, name string) bool {
|
||||
cgamepad := (C.int)(gamepad)
|
||||
cname := C.CString(name)
|
||||
defer C.free(unsafe.Pointer(cname))
|
||||
ret := C.IsGamepadName(cgamepad, cname)
|
||||
v := bool(ret)
|
||||
return v
|
||||
}
|
||||
|
||||
// GetGamepadName - Return gamepad internal name id
|
||||
func GetGamepadName(gamepad int32) string {
|
||||
cgamepad := (C.int)(gamepad)
|
|
@ -27,9 +27,9 @@ func GetGestureDetected() Gestures {
|
|||
return v
|
||||
}
|
||||
|
||||
// GetTouchPointsCount - Get touch points count
|
||||
func GetTouchPointsCount() int32 {
|
||||
ret := C.GetTouchPointsCount()
|
||||
// GetTouchPointCount - Get number of touch points
|
||||
func GetTouchPointCount() int32 {
|
||||
ret := C.GetTouchPointCount()
|
||||
v := (int32)(ret)
|
||||
return v
|
||||
}
|
|
@ -6,8 +6,10 @@ package rl
|
|||
#include <stdlib.h>
|
||||
*/
|
||||
import "C"
|
||||
import "unsafe"
|
||||
import "reflect"
|
||||
import (
|
||||
"reflect"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// cptr returns C pointer
|
||||
func (s *Shader) cptr() *C.Shader {
|
||||
|
@ -54,20 +56,6 @@ func UnloadShader(shader Shader) {
|
|||
C.UnloadShader(*cshader)
|
||||
}
|
||||
|
||||
// GetShaderDefault - Get default shader
|
||||
func GetShaderDefault() Shader {
|
||||
ret := C.rlGetShaderDefault()
|
||||
v := newShaderFromPointer(unsafe.Pointer(&ret))
|
||||
return v
|
||||
}
|
||||
|
||||
// GetTextureDefault - Get default texture
|
||||
func GetTextureDefault() *Texture2D {
|
||||
ret := C.rlGetTextureDefault()
|
||||
v := newTexture2DFromPointer(unsafe.Pointer(&ret))
|
||||
return &v
|
||||
}
|
||||
|
||||
// GetShaderLocation - Get shader uniform location
|
||||
func GetShaderLocation(shader Shader, uniformName string) int32 {
|
||||
cshader := shader.cptr()
|
||||
|
|
|
@ -35,6 +35,13 @@ func DrawLine3D(startPos Vector3, endPos Vector3, color Color) {
|
|||
C.DrawLine3D(*cstartPos, *cendPos, *ccolor)
|
||||
}
|
||||
|
||||
// DrawPoint3D - Draw a point in 3D space, actually a small line
|
||||
func DrawPoint3D(position Vector3, color Color) {
|
||||
cposition := position.cptr()
|
||||
ccolor := color.cptr()
|
||||
C.DrawPoint3D(*cposition, *ccolor)
|
||||
}
|
||||
|
||||
// DrawCircle3D - Draw a circle in 3D world space
|
||||
func DrawCircle3D(center Vector3, radius float32, rotationAxis Vector3, rotationAngle float32, color Color) {
|
||||
ccenter := center.cptr()
|
||||
|
@ -73,6 +80,14 @@ func DrawCubeWires(position Vector3, width float32, height float32, length float
|
|||
C.DrawCubeWires(*cposition, cwidth, cheight, clength, *ccolor)
|
||||
}
|
||||
|
||||
// DrawCubeWiresV - Draw cube wires (Vector version)
|
||||
func DrawCubeWiresV(position Vector3, size Vector3, color Color) {
|
||||
cposition := position.cptr()
|
||||
csize := size.cptr()
|
||||
ccolor := color.cptr()
|
||||
C.DrawCubeWiresV(*cposition, *csize, *ccolor)
|
||||
}
|
||||
|
||||
// DrawCubeTexture - Draw cube textured
|
||||
func DrawCubeTexture(texture Texture2D, position Vector3, width float32, height float32, length float32, color Color) {
|
||||
ctexture := texture.cptr()
|
||||
|
@ -448,32 +463,63 @@ func CheckCollisionBoxSphere(box BoundingBox, centerSphere Vector3, radiusSphere
|
|||
return v
|
||||
}
|
||||
|
||||
// CheckCollisionRaySphere - Detect collision between ray and sphere
|
||||
func CheckCollisionRaySphere(ray Ray, spherePosition Vector3, sphereRadius float32) bool {
|
||||
// GetRayCollisionSphere - Get collision info between ray and sphere
|
||||
func GetRayCollisionSphere(ray Ray, center Vector3, radius float32) RayCollision {
|
||||
cray := ray.cptr()
|
||||
cspherePosition := spherePosition.cptr()
|
||||
csphereRadius := (C.float)(sphereRadius)
|
||||
ret := C.CheckCollisionRaySphere(*cray, *cspherePosition, csphereRadius)
|
||||
v := bool(ret)
|
||||
ccenter := center.cptr()
|
||||
cradius := (C.float)(radius)
|
||||
ret := C.GetRayCollisionSphere(*cray, *ccenter, cradius)
|
||||
v := newRayCollisionFromPointer(unsafe.Pointer(&ret))
|
||||
return v
|
||||
}
|
||||
|
||||
// CheckCollisionRaySphereEx - Detect collision between ray and sphere with extended parameters and collision point detection
|
||||
func CheckCollisionRaySphereEx(ray Ray, spherePosition Vector3, sphereRadius float32, collisionPoint Vector3) bool {
|
||||
cray := ray.cptr()
|
||||
cspherePosition := spherePosition.cptr()
|
||||
csphereRadius := (C.float)(sphereRadius)
|
||||
ccollisionPoint := collisionPoint.cptr()
|
||||
ret := C.CheckCollisionRaySphereEx(*cray, *cspherePosition, csphereRadius, ccollisionPoint)
|
||||
v := bool(ret)
|
||||
return v
|
||||
}
|
||||
|
||||
// CheckCollisionRayBox - Detect collision between ray and box
|
||||
func CheckCollisionRayBox(ray Ray, box BoundingBox) bool {
|
||||
// GetRayCollisionBox - Get collision info between ray and box
|
||||
func GetRayCollisionBox(ray Ray, box BoundingBox) RayCollision {
|
||||
cray := ray.cptr()
|
||||
cbox := box.cptr()
|
||||
ret := C.CheckCollisionRayBox(*cray, *cbox)
|
||||
v := bool(ret)
|
||||
ret := C.GetRayCollisionBox(*cray, *cbox)
|
||||
v := newRayCollisionFromPointer(unsafe.Pointer(&ret))
|
||||
return v
|
||||
}
|
||||
|
||||
// GetRayCollisionModel - Get collision info between ray and model
|
||||
func GetRayCollisionModel(ray Ray, model Model) RayCollision {
|
||||
cray := ray.cptr()
|
||||
cmodel := model.cptr()
|
||||
ret := C.GetRayCollisionModel(*cray, *cmodel)
|
||||
v := newRayCollisionFromPointer(unsafe.Pointer(&ret))
|
||||
return v
|
||||
}
|
||||
|
||||
// GetRayCollisionMesh - Get collision info between ray and mesh
|
||||
func GetRayCollisionMesh(ray Ray, mesh Mesh, transform Matrix) RayCollision {
|
||||
cray := ray.cptr()
|
||||
cmesh := mesh.cptr()
|
||||
ctransform := transform.cptr()
|
||||
ret := C.GetRayCollisionMesh(*cray, *cmesh, *ctransform)
|
||||
v := newRayCollisionFromPointer(unsafe.Pointer(&ret))
|
||||
return v
|
||||
}
|
||||
|
||||
// GetRayCollisionTriangle - Get collision info between ray and triangle
|
||||
func GetRayCollisionTriangle(ray Ray, p1, p2, p3 Vector3) RayCollision {
|
||||
cray := ray.cptr()
|
||||
cp1 := p1.cptr()
|
||||
cp2 := p2.cptr()
|
||||
cp3 := p3.cptr()
|
||||
ret := C.GetRayCollisionTriangle(*cray, *cp1, *cp2, *cp3)
|
||||
v := newRayCollisionFromPointer(unsafe.Pointer(&ret))
|
||||
return v
|
||||
}
|
||||
|
||||
// GetRayCollisionQuad - Get collision info between ray and quad
|
||||
func GetRayCollisionQuad(ray Ray, p1, p2, p3, p4 Vector3) RayCollision {
|
||||
cray := ray.cptr()
|
||||
cp1 := p1.cptr()
|
||||
cp2 := p2.cptr()
|
||||
cp3 := p3.cptr()
|
||||
cp4 := p4.cptr()
|
||||
ret := C.GetRayCollisionQuad(*cray, *cp1, *cp2, *cp3, *cp4)
|
||||
v := newRayCollisionFromPointer(unsafe.Pointer(&ret))
|
||||
return v
|
||||
}
|
|
@ -178,11 +178,11 @@ func DrawRectangleRec(rec Rectangle, color Color) {
|
|||
}
|
||||
|
||||
// DrawRectanglePro - Draw a color-filled rectangle with pro parameters
|
||||
func DrawRectanglePro(rec Rectangle, origin Vector2, rotation float32, colors []Color) {
|
||||
func DrawRectanglePro(rec Rectangle, origin Vector2, rotation float32, color Color) {
|
||||
crec := rec.cptr()
|
||||
corigin := origin.cptr()
|
||||
crotation := (C.float)(rotation)
|
||||
ccolor := (*C.Color)(unsafe.Pointer(&colors[0]))
|
||||
ccolor := color.cptr()
|
||||
C.DrawRectanglePro(*crec, *corigin, crotation, *ccolor)
|
||||
}
|
||||
|
||||
|
@ -389,6 +389,17 @@ func CheckCollisionLines(startPos1, endPos1, startPos2, endPos2 Vector2, point *
|
|||
return v
|
||||
}
|
||||
|
||||
// CheckCollisionPointLine - Check if point belongs to line created between two points [p1] and [p2] with defined margin in pixels [threshold]
|
||||
func CheckCollisionPointLine(point, p1, p2 Vector2, threshold int32) bool {
|
||||
cpoint := point.cptr()
|
||||
cp1 := p1.cptr()
|
||||
cp2 := p2.cptr()
|
||||
cthreshold := (C.int)(threshold)
|
||||
ret := C.CheckCollisionPointLine(*cpoint, *cp1, *cp2, cthreshold)
|
||||
v := bool(ret)
|
||||
return v
|
||||
}
|
||||
|
||||
// GetCollisionRec - Get collision rectangle for two rectangles collision
|
||||
func GetCollisionRec(rec1, rec2 Rectangle) Rectangle {
|
||||
crec1 := rec1.cptr()
|
|
@ -8,8 +8,8 @@ import "C"
|
|||
import "unsafe"
|
||||
|
||||
// cptr returns C pointer
|
||||
func (c *CharInfo) cptr() *C.CharInfo {
|
||||
return (*C.CharInfo)(unsafe.Pointer(c))
|
||||
func (c *GlyphInfo) cptr() *C.GlyphInfo {
|
||||
return (*C.GlyphInfo)(unsafe.Pointer(c))
|
||||
}
|
||||
|
||||
// cptr returns C pointer
|
||||
|
@ -70,7 +70,7 @@ func LoadFontFromMemory(fileType string, fileData []byte, dataSize int32, fontSi
|
|||
}
|
||||
|
||||
// LoadFontData - Load font data for further use
|
||||
func LoadFontData(fileData []byte, dataSize int32, fontSize int32, fontChars *int32, charsCount, typ int32) *CharInfo {
|
||||
func LoadFontData(fileData []byte, dataSize int32, fontSize int32, fontChars *int32, charsCount, typ int32) *GlyphInfo {
|
||||
cfileData := (*C.uchar)(unsafe.Pointer(&fileData[0]))
|
||||
cdataSize := (C.int)(dataSize)
|
||||
cfontSize := (C.int)(fontSize)
|
||||
|
@ -78,7 +78,7 @@ func LoadFontData(fileData []byte, dataSize int32, fontSize int32, fontChars *in
|
|||
ccharsCount := (C.int)(charsCount)
|
||||
ctype := (C.int)(typ)
|
||||
ret := C.LoadFontData(cfileData, cdataSize, cfontSize, cfontChars, ccharsCount, ctype)
|
||||
v := newCharInfoFromPointer(unsafe.Pointer(&ret))
|
||||
v := newGlyphInfoFromPointer(unsafe.Pointer(&ret))
|
||||
return &v
|
||||
}
|
||||
|
||||
|
@ -111,36 +111,6 @@ func DrawTextEx(font Font, text string, position Vector2, fontSize float32, spac
|
|||
C.DrawTextEx(*cfont, ctext, *cposition, cfontSize, cspacing, *ctint)
|
||||
}
|
||||
|
||||
// DrawTextRec - Draw text using font inside rectangle limits
|
||||
func DrawTextRec(font Font, text string, rec Rectangle, fontSize, spacing float32, wordWrap bool, tint Color) {
|
||||
cfont := font.cptr()
|
||||
ctext := C.CString(text)
|
||||
defer C.free(unsafe.Pointer(ctext))
|
||||
crec := rec.cptr()
|
||||
cfontSize := (C.float)(fontSize)
|
||||
cspacing := (C.float)(spacing)
|
||||
cwordWrap := (C.bool)(wordWrap)
|
||||
ctint := tint.cptr()
|
||||
C.DrawTextRec(*cfont, ctext, *crec, cfontSize, cspacing, cwordWrap, *ctint)
|
||||
}
|
||||
|
||||
// DrawTextRecEx - Draw text using font inside rectangle limits with support for text selection
|
||||
func DrawTextRecEx(font Font, text string, rec Rectangle, fontSize, spacing float32, wordWrap bool, tint Color, selectStart, selectLength int32, selectText, selectBack Color) {
|
||||
cfont := font.cptr()
|
||||
ctext := C.CString(text)
|
||||
defer C.free(unsafe.Pointer(ctext))
|
||||
crec := rec.cptr()
|
||||
cfontSize := (C.float)(fontSize)
|
||||
cspacing := (C.float)(spacing)
|
||||
cwordWrap := (C.bool)(wordWrap)
|
||||
ctint := tint.cptr()
|
||||
cselectStart := (C.int)(selectStart)
|
||||
cselectLength := (C.int)(selectLength)
|
||||
cselectText := selectText.cptr()
|
||||
cselectBack := selectBack.cptr()
|
||||
C.DrawTextRecEx(*cfont, ctext, *crec, cfontSize, cspacing, cwordWrap, *ctint, cselectStart, cselectLength, *cselectText, *cselectBack)
|
||||
}
|
||||
|
||||
// MeasureText - Measure string width for default font
|
||||
func MeasureText(text string, fontSize int32) int32 {
|
||||
ctext := C.CString(text)
|
|
@ -22,7 +22,7 @@ func (i *Image) ToImage() image.Image {
|
|||
|
||||
// Get pixel data from image (RGBA 32bit)
|
||||
cimg := i.cptr()
|
||||
ret := C.GetImageData(*cimg)
|
||||
ret := C.LoadImageColors(*cimg)
|
||||
pixels := (*[1 << 24]uint8)(unsafe.Pointer(ret))[0 : i.Width*i.Height*4]
|
||||
|
||||
img.Pix = pixels
|
||||
|
@ -127,17 +127,17 @@ func UnloadRenderTexture(target RenderTexture2D) {
|
|||
C.UnloadRenderTexture(*ctarget)
|
||||
}
|
||||
|
||||
// GetImageData - Get pixel data from image as a Color slice
|
||||
func GetImageData(img *Image) []Color {
|
||||
// LoadImageColors - Get pixel data from image as a Color slice
|
||||
func LoadImageColors(img *Image) []Color {
|
||||
cimg := img.cptr()
|
||||
ret := C.GetImageData(*cimg)
|
||||
ret := C.LoadImageColors(*cimg)
|
||||
return (*[1 << 24]Color)(unsafe.Pointer(ret))[0 : img.Width*img.Height]
|
||||
}
|
||||
|
||||
// GetTextureData - Get pixel data from GPU texture and return an Image
|
||||
func GetTextureData(texture Texture2D) *Image {
|
||||
// LoadImageFromTexture - Get pixel data from GPU texture and return an Image
|
||||
func LoadImageFromTexture(texture Texture2D) *Image {
|
||||
ctexture := texture.cptr()
|
||||
ret := C.GetTextureData(*ctexture)
|
||||
ret := C.LoadImageFromTexture(*ctexture)
|
||||
v := newImageFromPointer(unsafe.Pointer(&ret))
|
||||
return v
|
||||
}
|
||||
|
@ -543,19 +543,6 @@ func GenImageWhiteNoise(width, height int, factor float32) *Image {
|
|||
return v
|
||||
}
|
||||
|
||||
// GenImagePerlinNoise - Generate image: perlin noise
|
||||
func GenImagePerlinNoise(width, height, offsetX, offsetY int, scale float32) *Image {
|
||||
cwidth := (C.int)(width)
|
||||
cheight := (C.int)(height)
|
||||
coffsetX := (C.int)(offsetX)
|
||||
coffsetY := (C.int)(offsetY)
|
||||
cscale := (C.float)(scale)
|
||||
|
||||
ret := C.GenImagePerlinNoise(cwidth, cheight, coffsetX, coffsetY, cscale)
|
||||
v := newImageFromPointer(unsafe.Pointer(&ret))
|
||||
return v
|
||||
}
|
||||
|
||||
// GenImageCellular - Generate image: cellular algorithm. Bigger tileSize means bigger cells
|
||||
func GenImageCellular(width, height, tileSize int) *Image {
|
||||
cwidth := (C.int)(width)
|
Loading…
Add table
Add a link
Reference in a new issue