Vector2LineAngle and more Color functions.

This commit is contained in:
jussi
2023-04-06 22:17:33 +03:00
parent fe15e836bd
commit 9e7f538a38
9 changed files with 196 additions and 4 deletions

36
API.md
View File

@@ -2831,6 +2831,15 @@ Check if point is inside a triangle
--- ---
> collision = RL.CheckCollisionPointPoly( Vector2 point, Vector2{} points )
Check if point is within a polygon described by array of vertices
- Failure return nil
- Success return bool
---
> collision, position = RL.CheckCollisionLines( Vector2 startPos1, Vector2 endPos1, Vector2 startPos2, Vector2 endPos2 ) > collision, position = RL.CheckCollisionLines( Vector2 startPos1, Vector2 endPos1, Vector2 startPos2, Vector2 endPos2 )
Check the collision between two lines defined by two points each, returns collision point by reference Check the collision between two lines defined by two points each, returns collision point by reference
@@ -3620,6 +3629,33 @@ Returns a Color from HSV values, hue [0..360], saturation/value [0..1]
--- ---
> color = RL.ColorTint( Color color, Color tint )
Get color multiplied with another color
- Failure return false
- Success return Color
---
> color = RL.ColorBrightness( Color color, float factor )
Get color with brightness correction, brightness factor goes from -1.0f to 1.0f
- Failure return false
- Success return Color
---
> color = RL.ColorContrast( Color color, float contrast )
Get color with contrast correction, contrast values between -1.0f and 1.0f
- Failure return false
- Success return Color
---
> color = RL.ColorAlpha( Color color, float alpha ) > color = RL.ColorAlpha( Color color, float alpha )
Returns color with alpha applied, alpha goes from 0.0f to 1.0f Returns color with alpha applied, alpha goes from 0.0f to 1.0f

View File

@@ -1989,6 +1989,14 @@ function RL.CheckCollisionPointCircle( point, center, radius ) end
---@return any collision ---@return any collision
function RL.CheckCollisionPointTriangle( point, p1, p2, p3 ) end function RL.CheckCollisionPointTriangle( point, p1, p2, p3 ) end
---Check if point is within a polygon described by array of vertices
---- Failure return nil
---- Success return bool
---@param point table
---@param points any
---@return any collision
function RL.CheckCollisionPointPoly( point, points ) end
---Check the collision between two lines defined by two points each, returns collision point by reference ---Check the collision between two lines defined by two points each, returns collision point by reference
---- Failure return nil ---- Failure return nil
---- Success return bool, Vector2 ---- Success return bool, Vector2
@@ -2688,6 +2696,30 @@ function RL.ColorToHSV( color ) end
---@return any color ---@return any color
function RL.ColorFromHSV( hue, saturation, value ) end function RL.ColorFromHSV( hue, saturation, value ) end
---Get color multiplied with another color
---- Failure return false
---- Success return Color
---@param color table
---@param tint table
---@return any color
function RL.ColorTint( color, tint ) end
---Get color with brightness correction, brightness factor goes from -1.0f to 1.0f
---- Failure return false
---- Success return Color
---@param color table
---@param factor number
---@return any color
function RL.ColorBrightness( color, factor ) end
---Get color with contrast correction, contrast values between -1.0f and 1.0f
---- Failure return false
---- Success return Color
---@param color table
---@param contrast number
---@return any color
function RL.ColorContrast( color, contrast ) end
---Returns color with alpha applied, alpha goes from 0.0f to 1.0f ---Returns color with alpha applied, alpha goes from 0.0f to 1.0f
---- Failure return false ---- Failure return false
---- Success return Color ---- Success return Color

View File

@@ -24,6 +24,10 @@ Detailed changes:
- ADDED: UpdateCamera3DPro. Same as UpdateCameraPro in raylib. - ADDED: UpdateCamera3DPro. Same as UpdateCameraPro in raylib.
- ADDED: BLEND_CUSTOM_SEPARATE. - ADDED: BLEND_CUSTOM_SEPARATE.
- ADDED: Vector2LineAngle - ADDED: Vector2LineAngle
- ADDED: CheckCollisionPointPoly
- ADDED: ColorTint
- ADDED: ColorBrightness
- ADDED: ColorContrast
------------------------------------------------------------------------ ------------------------------------------------------------------------
Release: ReiLua version 0.4.0 Using Raylib 4.2 Release: ReiLua version 0.4.0 Using Raylib 4.2

View File

@@ -4,16 +4,24 @@ Current {
} }
Backlog { Backlog {
* Raymath * IsWaveReady and others like that.
* Vector2LineAngle
* rlgl * rlgl
* More low level functions. * More low level functions. Could be usefull now when draw polygon is removed.
* Text * Text
* Ability to set font texture filtering. * Ability to set font texture filtering.
* Codepoints? * Codepoints?
* Audio * Audio
* AudioStream. * AudioStream.
* VR.
* Core. * Core.
* Compression/Encoding functionality. * Compression/Encoding functionality.
* SetWindowIcons.
* Textures
* GenImagePerlinNoise
* GenImageText
* ImageDrawCircleLines
* ImageBlurGaussian
* Models
* DrawCapsule and DrawCapsuleWires
* LoadMaterials
} }

View File

@@ -40,6 +40,7 @@ int lshapesCheckCollisionCircleRec( lua_State *L );
int lshapesCheckCollisionPointRec( lua_State *L ); int lshapesCheckCollisionPointRec( lua_State *L );
int lshapesCheckCollisionPointCircle( lua_State *L ); int lshapesCheckCollisionPointCircle( lua_State *L );
int lshapesCheckCollisionPointTriangle( lua_State *L ); int lshapesCheckCollisionPointTriangle( lua_State *L );
int lshapesCheckCollisionPointPoly( lua_State *L );
int lshapesCheckCollisionLines( lua_State *L ); int lshapesCheckCollisionLines( lua_State *L );
int lshapesCheckCollisionPointLine( lua_State *L ); int lshapesCheckCollisionPointLine( lua_State *L );
int lshapesGetCollisionRec( lua_State *L ); int lshapesGetCollisionRec( lua_State *L );

View File

@@ -100,6 +100,9 @@ int ltexturesColorNormalize( lua_State *L );
int ltexturesColorFromNormalized( lua_State *L ); int ltexturesColorFromNormalized( lua_State *L );
int ltexturesColorToHSV( lua_State *L ); int ltexturesColorToHSV( lua_State *L );
int ltexturesColorFromHSV( lua_State *L ); int ltexturesColorFromHSV( lua_State *L );
int ltexturesColorTint( lua_State *L );
int ltexturesColorBrightness( lua_State *L );
int ltexturesColorContrast( lua_State *L );
int ltexturesColorAlpha( lua_State *L ); int ltexturesColorAlpha( lua_State *L );
int ltexturesColorAlphaBlend( lua_State *L ); int ltexturesColorAlphaBlend( lua_State *L );
int ltexturesGetColor( lua_State *L ); int ltexturesGetColor( lua_State *L );

View File

@@ -914,6 +914,7 @@ void luaRegister() {
assingGlobalFunction( "CheckCollisionPointRec", lshapesCheckCollisionPointRec ); assingGlobalFunction( "CheckCollisionPointRec", lshapesCheckCollisionPointRec );
assingGlobalFunction( "CheckCollisionPointCircle", lshapesCheckCollisionPointCircle ); assingGlobalFunction( "CheckCollisionPointCircle", lshapesCheckCollisionPointCircle );
assingGlobalFunction( "CheckCollisionPointTriangle", lshapesCheckCollisionPointTriangle ); assingGlobalFunction( "CheckCollisionPointTriangle", lshapesCheckCollisionPointTriangle );
assingGlobalFunction( "CheckCollisionPointPoly", lshapesCheckCollisionPointPoly );
assingGlobalFunction( "CheckCollisionLines", lshapesCheckCollisionLines ); assingGlobalFunction( "CheckCollisionLines", lshapesCheckCollisionLines );
assingGlobalFunction( "CheckCollisionPointLine", lshapesCheckCollisionPointLine ); assingGlobalFunction( "CheckCollisionPointLine", lshapesCheckCollisionPointLine );
assingGlobalFunction( "GetCollisionRec", lshapesGetCollisionRec ); assingGlobalFunction( "GetCollisionRec", lshapesGetCollisionRec );
@@ -1011,6 +1012,9 @@ void luaRegister() {
assingGlobalFunction( "ColorFromNormalized", ltexturesColorFromNormalized ); assingGlobalFunction( "ColorFromNormalized", ltexturesColorFromNormalized );
assingGlobalFunction( "ColorToHSV", ltexturesColorToHSV ); assingGlobalFunction( "ColorToHSV", ltexturesColorToHSV );
assingGlobalFunction( "ColorFromHSV", ltexturesColorFromHSV ); assingGlobalFunction( "ColorFromHSV", ltexturesColorFromHSV );
assingGlobalFunction( "ColorTint", ltexturesColorTint );
assingGlobalFunction( "ColorBrightness", ltexturesColorBrightness );
assingGlobalFunction( "ColorContrast", ltexturesColorContrast );
assingGlobalFunction( "ColorAlpha", ltexturesColorAlpha ); assingGlobalFunction( "ColorAlpha", ltexturesColorAlpha );
assingGlobalFunction( "ColorAlphaBlend", ltexturesColorAlphaBlend ); assingGlobalFunction( "ColorAlphaBlend", ltexturesColorAlphaBlend );
assingGlobalFunction( "GetColor", ltexturesGetColor ); assingGlobalFunction( "GetColor", ltexturesGetColor );

View File

@@ -1105,6 +1105,41 @@ int lshapesCheckCollisionPointTriangle( lua_State *L ) {
return 1; return 1;
} }
/*
> collision = RL.CheckCollisionPointPoly( Vector2 point, Vector2{} points )
Check if point is within a polygon described by array of vertices
- Failure return nil
- Success return bool
*/
int lshapesCheckCollisionPointPoly( lua_State *L ) {
if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.CheckCollisionPointPoly( Vector2 point, Vector2{} points )" );
lua_pushnil( L );
return 1;
}
int pointCount = uluaGetTableLen( L );
Vector2 points[ pointCount ];
int t = lua_gettop( L );
int i = 0;
lua_pushnil( L );
while ( lua_next( L, t ) != 0 ) {
points[i] = uluaGetVector2( L );
i++;
lua_pop( L, 1 );
}
lua_pop( L, 1 );
Vector2 point = uluaGetVector2( L );
lua_pushboolean( L, CheckCollisionPointPoly( point, points, pointCount ) );
return 1;
}
/* /*
> collision, position = RL.CheckCollisionLines( Vector2 startPos1, Vector2 endPos1, Vector2 startPos2, Vector2 endPos2 ) > collision, position = RL.CheckCollisionLines( Vector2 startPos1, Vector2 endPos1, Vector2 startPos2, Vector2 endPos2 )

View File

@@ -2448,6 +2448,75 @@ int ltexturesColorFromHSV( lua_State *L ) {
return 1; return 1;
} }
/*
> color = RL.ColorTint( Color color, Color tint )
Get color multiplied with another color
- Failure return false
- Success return Color
*/
int ltexturesColorTint( lua_State *L ) {
if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.ColorTint( Color color, Color tint )" );
lua_pushboolean( L, false );
return 1;
}
Color tint = uluaGetColor( L );
lua_pop( L, 1 );
Color color = uluaGetColor( L );
uluaPushColor( L, ColorTint( color, tint ) );
return 1;
}
/*
> color = RL.ColorBrightness( Color color, float factor )
Get color with brightness correction, brightness factor goes from -1.0f to 1.0f
- Failure return false
- Success return Color
*/
int ltexturesColorBrightness( lua_State *L ) {
if ( !lua_istable( L, -2 ) || !lua_isnumber( L, -1 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.ColorBrightness( Color color, float factor )" );
lua_pushboolean( L, false );
return 1;
}
float factor = lua_tonumber( L, -1 );
lua_pop( L, 1 );
Color color = uluaGetColor( L );
uluaPushColor( L, ColorBrightness( color, factor ) );
return 1;
}
/*
> color = RL.ColorContrast( Color color, float contrast )
Get color with contrast correction, contrast values between -1.0f and 1.0f
- Failure return false
- Success return Color
*/
int ltexturesColorContrast( lua_State *L ) {
if ( !lua_istable( L, -2 ) || !lua_isnumber( L, -1 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.ColorContrast( Color color, float contrast )" );
lua_pushboolean( L, false );
return 1;
}
float contrast = lua_tonumber( L, -1 );
lua_pop( L, 1 );
Color color = uluaGetColor( L );
uluaPushColor( L, ColorContrast( color, contrast ) );
return 1;
}
/* /*
> color = RL.ColorAlpha( Color color, float alpha ) > color = RL.ColorAlpha( Color color, float alpha )