summaryrefslogtreecommitdiff
path: root/src/shapes.c
blob: cf50ca3123c118800e795b936af565682342e598 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
#include "main.h"
#include "shapes.h"
#include "lua_core.h"
#include "textures.h"

/*
## Shapes - Drawing
*/

/*
> success = RL.SetShapesTexture( Texture2D texture, Rectangle source )

Set texture and rectangle to be used on shapes drawing
NOTE: It can be useful when using basic shapes and one single font,
defining a font char white rectangle would allow drawing everything in a single draw call

- Failure return false
- Success return true
*/
int lshapesSetShapesTexture( lua_State *L ) {
	if ( !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) {
		TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.SetShapesTexture( Texture2D texture, Rectangle source )" );
		lua_pushboolean( L, false );
		return 1;
	}
	Rectangle source = uluaGetRectangle( L );
	lua_pop( L, 1 );
	size_t texId = lua_tointeger( L, -1 );

	if ( !validSourceTexture( texId ) ) {
		lua_pushboolean( L, false );
		return 1;
	}
	SetShapesTexture( *texturesGetSourceTexture( texId ), source );
	lua_pushboolean( L, true );

	return 1;
}

/*
> success = RL.DrawPixel( Vector2 pos, Color color )

Draw a pixel

- Failure return false
- Success return true
*/
int lshapesDrawPixel( lua_State *L ) {
	if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) {
		TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawPixel( Vector2 pos, Color color )" );
		lua_pushboolean( L, false );
		return 1;
	}
	Color color = uluaGetColor( L );
	lua_pop( L, 1 );
	Vector2 pos = uluaGetVector2( L );

	DrawPixelV( pos, color );
	lua_pushboolean( L, true );

	return 1;
}

/*
> success = RL.DrawLine( Vector2 startPos, Vector2 endPos, float thickness, Color color )

Draw a line defining thickness

- Failure return false
- Success return true
*/
int lshapesDrawLine( lua_State *L ) {
	if ( !lua_istable( L, -4 ) || !lua_istable( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
		TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawLine( Vector2 startPos, Vector2 endPos, float thickness, Color color )" );
		lua_pushboolean( L, false );
		return 1;
	}
	Color color = uluaGetColor( L );
	lua_pop( L, 1 );
	float thickness = lua_tonumber( L, -1 );
	lua_pop( L, 1 );
	Vector2 endPos = uluaGetVector2( L );
	lua_pop( L, 1 );
	Vector2 startPos = uluaGetVector2( L );

	DrawLineEx( startPos, endPos, thickness, color );
	lua_pushboolean( L, true );

	return 1;
}

/*
> success = RL.DrawLineBezier( Vector2 startPos, Vector2 endPos, float thickness, Color color )

Draw a line using cubic-bezier curves in-out

- Failure return false
- Success return true
*/
int lshapesDrawLineBezier( lua_State *L ) {
	if ( !lua_istable( L, -4 ) || !lua_istable( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
		TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawLineBezier( Vector2 startPos, Vector2 endPos, float thickness, Color color )" );
		lua_pushboolean( L, false );
		return 1;
	}
	Color color = uluaGetColor( L );
	lua_pop( L, 1 );
	float thickness = lua_tonumber( L, -1 );
	lua_pop( L, 1 );
	Vector2 endPos = uluaGetVector2( L );
	lua_pop( L, 1 );
	Vector2 startPos = uluaGetVector2( L );

	DrawLineBezier( startPos, endPos, thickness, color );
	lua_pushboolean( L, true );

	return 1;
}

/*
> success = RL.DrawLineBezierQuad( Vector2 startPos, Vector2 endPos, Vector2 controlPos, float thickness, Color color )

Draw line using quadratic bezier curves with a control point

- Failure return false
- Success return true
*/
int lshapesDrawLineBezierQuad( lua_State *L ) {
	if ( !lua_istable( L, -5 ) || !lua_istable( L, -4 ) || !lua_istable( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
		TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawLineBezier( Vector2 startPos, Vector2 endPos, Vector2 controlPos, float thickness, Color color )" );
		lua_pushboolean( L, false );
		return 1;
	}
	Color color = uluaGetColor( L );
	lua_pop( L, 1 );
	float thickness = lua_tonumber( L, -1 );
	lua_pop( L, 1 );
	Vector2 controlPos = uluaGetVector2( L );
	lua_pop( L, 1 );
	Vector2 endPos = uluaGetVector2( L );
	lua_pop( L, 1 );
	Vector2 startPos = uluaGetVector2( L );

	DrawLineBezierQuad( startPos, endPos, controlPos, thickness, color );
	lua_pushboolean( L, true );

	return 1;
}

/*
> success = RL.DrawLineBezierCubic( Vector2 startPos, Vector2 endPos, Vector2 startControlPos, Vector2 endControlPos, float thickness, Color color )

Draw line using quadratic bezier curves with a control point

- Failure return false
- Success return true
*/
int lshapesDrawLineBezierCubic( lua_State *L ) {
	if ( !lua_istable( L, -6 ) || !lua_istable( L, -5 ) || !lua_istable( L, -4 ) ||
		 !lua_istable( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
		TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawLineBezierCubic( Vector2 startPos, Vector2 endPos, Vector2 startControlPos, Vector2 endControlPos, float thickness, Color color )" );
		lua_pushboolean( L, false );
		return 1;
	}
	Color color = uluaGetColor( L );
	lua_pop( L, 1 );
	float thickness = lua_tonumber( L, -1 );
	lua_pop( L, 1 );
	Vector2 endControlPos = uluaGetVector2( L );
	lua_pop( L, 1 );
	Vector2 startControlPos = uluaGetVector2( L );
	lua_pop( L, 1 );
	Vector2 endPos = uluaGetVector2( L );
	lua_pop( L, 1 );
	Vector2 startPos = uluaGetVector2( L );

	DrawLineBezierCubic( startPos, endPos, startControlPos, endControlPos, thickness, color );
	lua_pushboolean( L, true );

	return 1;
}

/*
> success = RL.DrawLineStrip( Vector2{} points, int pointsCount, Color color )

Draw lines sequence

- Failure return false
- Success return true
*/
int lshapesDrawLineStrip( lua_State *L ) {
	if ( !lua_istable( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
		TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawLineStrip( Vector2{} points, int pointsCount, Color color )" );
		lua_pushboolean( L, false );
		return 1;
	}
	Color color = uluaGetColor( L );
	lua_pop( L, 1 );
	int pointsCount = lua_tointeger( L, -1 );
	lua_pop( L, 1 );
	Vector2 points[ pointsCount ];

	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 );
	}

	DrawLineStrip( points, pointsCount, color );
	lua_pushboolean( L, true );

	return 1;
}

/*
> success = RL.DrawCircle( Vector2 center, float radius, Color color )

Draw a color-filled circle

- Failure return false
- Success return true
*/
int lshapesDrawCircle( lua_State *L ) {
	if ( !lua_istable( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
		TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawCircle( Vector2 center, float radius, Color color )" );
		lua_pushboolean( L, false );
		return 1;
	}
	Color color = uluaGetColor( L );
	lua_pop( L, 1 );
	float radius = lua_tonumber( L, -1 );
	lua_pop( L, 1 );
	Vector2 center = uluaGetVector2( L );

	DrawCircleV( center, radius, color );
	lua_pushboolean( L, true );

	return 1;
}

/*
> success = RL.DrawCircleSector( Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color )

Draw a piece of a circle

- Failure return false
- Success return true
*/
int lshapesDrawCircleSector( lua_State *L ) {
	if ( !lua_istable( L, -6 ) || !lua_isnumber( L, -5 ) || !lua_isnumber( L, -4 ) ||
		 !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
		TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawCircleSector( Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color )" );
		lua_pushboolean( L, false );
		return 1;
	}
	Color color = uluaGetColor( L );
	lua_pop( L, 1 );
	int segments = lua_tointeger( L, -1 );
	lua_pop( L, 1 );
	float endAngle = lua_tonumber( L, -1 );
	lua_pop( L, 1 );
	float startAngle = lua_tonumber( L, -1 );
	lua_pop( L, 1 );
	float radius = lua_tonumber( L, -1 );
	lua_pop( L, 1 );
	Vector2 center = uluaGetVector2( L );

	DrawCircleSector( center, radius, startAngle, endAngle, segments, color );
	lua_pushboolean( L, true );

	return 1;
}

/*
> success = RL.DrawCircleSectorLines( Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color )

Draw circle sector outline

- Failure return false
- Success return true
*/
int lshapesDrawCircleSectorLines( lua_State *L ) {
	if ( !lua_istable( L, -6 ) || !lua_isnumber( L, -5 ) || !lua_isnumber( L, -4 ) ||
		 !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
		TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawCircleSectorLines( Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color )" );
		lua_pushboolean( L, false );
		return 1;
	}
	Color color = uluaGetColor( L );
	lua_pop( L, 1 );
	int segments = lua_tointeger( L, -1 );
	lua_pop( L, 1 );
	float endAngle = lua_tonumber( L, -1 );
	lua_pop( L, 1 );
	float startAngle = lua_tonumber( L, -1 );
	lua_pop( L, 1 );
	float radius = lua_tonumber( L, -1 );
	lua_pop( L, 1 );
	Vector2 center = uluaGetVector2( L );

	DrawCircleSectorLines( center, radius, startAngle, endAngle, segments, color );
	lua_pushboolean( L, true );

	return 1;
}

/*
> success = RL.DrawCircleGradient( Vector2 center, float radius, Color color1, Color color2 )

Draw a gradient-filled circle

- Failure return false
- Success return true
*/
int lshapesDrawCircleGradient( lua_State *L ) {
	if ( !lua_istable( L, -4 ) || !lua_isnumber( L, -3 ) || !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) {
		TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawCircleGradient( Vector2 center, float radius, Color color1, Color color2 )" );
		lua_pushboolean( L, false );
		return 1;
	}
	Color color2 = uluaGetColor( L );
	lua_pop( L, 1 );
	Color color1 = uluaGetColor( L );
	lua_pop( L, 1 );
	float radius = lua_tonumber( L, -1 );
	lua_pop( L, 1 );
	Vector2 center = uluaGetVector2( L );

	DrawCircleGradient( center.x, center.y, radius, color1, color2 );
	lua_pushboolean( L, true );

	return 1;
}

/*
> success = RL.DrawCircleLines( Vector2 center, float radius, Color color )

Draw circle outline

- Failure return false
- Success return true
*/
int lshapesDrawCircleLines( lua_State *L ) {
	if ( !lua_istable( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
		TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawCircleLines( Vector2 center, float radius, Color color )" );
		lua_pushboolean( L, false );
		return 1;
	}
	Color color = uluaGetColor( L );
	lua_pop( L, 1 );
	float radius = lua_tonumber( L, -1 );
	lua_pop( L, 1 );
	Vector2 center = uluaGetVector2( L );

	DrawCircleLines( center.x, center.y, radius, color );
	lua_pushboolean( L, true );

	return 1;
}

/*
> success = RL.DrawEllipse( Vector2 center, float radiusH, float radiusV, Color color )

Draw ellipse

- Failure return false
- Success return true
*/
int lshapesDrawEllipse( lua_State *L ) {
	if ( !lua_istable( L, -4 ) || !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
		TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawEllipse( Vector2 center, float radiusH, float radiusV, Color color )" );
		lua_pushboolean( L, false );
		return 1;
	}
	Color color = uluaGetColor( L );
	lua_pop( L, 1 );
	float radiusV = lua_tonumber( L, -1 );
	lua_pop( L, 1 );
	float radiusH = lua_tonumber( L, -1 );
	lua_pop( L, 1 );
	Vector2 center = uluaGetVector2( L );

	DrawEllipse( center.x, center.y, radiusH, radiusV, color );
	lua_pushboolean( L, true );

	return 1;
}

/*
> success = RL.DrawEllipseLines( Vector2 center, float radiusH, float radiusV, Color color )

Draw ellipse outline

- Failure return false
- Success return true
*/
int lshapesDrawEllipseLines( lua_State *L ) {
	if ( !lua_istable( L, -4 ) || !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
		TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawEllipseLines( Vector2 center, float radiusH, float radiusV, Color color )" );
		lua_pushboolean( L, false );
		return 1;
	}
	Color color = uluaGetColor( L );
	lua_pop( L, 1 );
	float radiusV = lua_tonumber( L, -1 );
	lua_pop( L, 1 );
	float radiusH = lua_tonumber( L, -1 );
	lua_pop( L, 1 );
	Vector2 center = uluaGetVector2( L );

	DrawEllipseLines( center.x, center.y, radiusH, radiusV, color );
	lua_pushboolean( L, true );

	return 1;
}

/*
> success = RL.DrawRing( Vector2 center, float innerRadius, float outerRadius, float startAngle, float endAngle, int segments, Color color )

Draw ring

- Failure return false
- Success return true
*/
int lshapesDrawRing( lua_State *L ) {
	if ( !lua_istable( L, -7 ) || !lua_istable( L, -6 ) || !lua_isnumber( L, -5 ) || !lua_isnumber( L, -4 ) ||
		 !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
		TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawRing( Vector2 center, float innerRadius, float outerRadius, float startAngle, float endAngle, int segments, Color color )" );
		lua_pushboolean( L, false );
		return 1;
	}
	Color color = uluaGetColor( L );
	lua_pop( L, 1 );
	int segments = lua_tointeger( L, -1 );
	lua_pop( L, 1 );
	float endAngle = lua_tonumber( L, -1 );
	lua_pop( L, 1 );
	float startAngle = lua_tonumber( L, -1 );
	lua_pop( L, 1 );
	float outerRadius = lua_tonumber( L, -1 );
	lua_pop( L, 1 );
	float innerRadius = lua_tonumber( L, -1 );
	lua_pop( L, 1 );
	Vector2 center = uluaGetVector2( L );

	DrawRing( center, innerRadius, outerRadius, startAngle, endAngle, segments, color );
	lua_pushboolean( L, true );

	return 1;
}

/*
> success = RL.DrawRingLines( Vector2 center, float innerRadius, float outerRadius, float startAngle, float endAngle, int segments, Color color )

Draw ring outline

- Failure return false
- Success return true
*/
int lshapesDrawRingLines( lua_State *L ) {
	if ( !lua_istable( L, -7 ) || !lua_istable( L, -6 ) || !lua_isnumber( L, -5 ) || !lua_isnumber( L, -4 ) ||
		 !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
		TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawRingLines( Vector2 center, float innerRadius, float outerRadius, float startAngle, float endAngle, int segments, Color color )" );
		lua_pushboolean( L, false );
		return 1;
	}
	Color color = uluaGetColor( L );
	lua_pop( L, 1 );
	int segments = lua_tointeger( L, -1 );
	lua_pop( L, 1 );
	float endAngle = lua_tonumber( L, -1 );
	lua_pop( L, 1 );
	float startAngle = lua_tonumber( L, -1 );
	lua_pop( L, 1 );
	float outerRadius = lua_tonumber( L, -1 );
	lua_pop( L, 1 );
	float innerRadius = lua_tonumber( L, -1 );
	lua_pop( L, 1 );
	Vector2 center = uluaGetVector2( L );

	DrawRingLines( center, innerRadius, outerRadius, startAngle, endAngle, segments, color );
	lua_pushboolean( L, true );

	return 1;
}

/*
> success = RL.DrawRectangle( Rectangle rec, Color color )

Draw a color-filled rectangle

- Failure return false
- Success return true
*/
int lshapesDrawRectangle( lua_State *L ) {
	if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) {
		TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawRectangle( Rectangle rec, Color color )" );
		lua_pushboolean( L, false );
		return 1;
	}
	Color color = uluaGetColor( L );
	lua_pop( L, 1 );
	Rectangle rect = uluaGetRectangle( L );

	DrawRectangleRec( rect, color );
	lua_pushboolean( L, true );

	return 1;
}

/*
> success = RL.DrawRectanglePro( Rectangle rec, Vector2 origin, float rotation, Color color )

Draw a color-filled rectangle with pro parameters

- Failure return false
- Success return true
*/
int lshapesDrawRectanglePro( lua_State *L ) {
	if ( !lua_istable( L, -4 ) || !lua_istable( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
		TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawRectanglePro( Rectangle rec, Vector2 origin, float rotation, Color color )" );
		lua_pushboolean( L, false );
		return 1;
	}
	Color color = uluaGetColor( L );
	lua_pop( L, 1 );
	float rotation = lua_tonumber( L, -1 );
	lua_pop( L, 1 );
	Vector2 origin = uluaGetVector2( L );
	lua_pop( L, 1 );
	Rectangle rec = uluaGetRectangle( L );

	DrawRectanglePro( rec, origin, rotation, color );
	lua_pushboolean( L, true );

	return 1;
}

/*
> success = RL.DrawRectangleGradientV( Rectangle rectangle, Color color1, Color color2 )

Draw a vertical-gradient-filled rectangle

- Failure return false
- Success return true
*/
int lshapesDrawRectangleGradientV( lua_State *L ) {
	if ( !lua_istable( L, -3 ) || !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) {
		TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawRectangleGradientV( Rectangle rectangle, Color color1, Color color2 )" );
		lua_pushboolean( L, false );
		return 1;
	}
	Color color2 = uluaGetColor( L );
	lua_pop( L, 1 );
	Color color1 = uluaGetColor( L );
	lua_pop( L, 1 );
	Rectangle rect = uluaGetRectangle( L );

	DrawRectangleGradientV( rect.x, rect.y, rect.width, rect.height, color1, color2 );
	lua_pushboolean( L, true );

	return 1;
}

/*
> success = RL.DrawRectangleGradientH( Rectangle rectangle, Color color1, Color color2 )

Draw a horizontal-gradient-filled rectangle

- Failure return false
- Success return true
*/
int lshapesDrawRectangleGradientH( lua_State *L ) {
	if ( !lua_istable( L, -3 ) || !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) {
		TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawRectangleGradientH( Rectangle rectangle, Color color1, Color color2 )" );
		lua_pushboolean( L, false );
		return 1;
	}
	Color color2 = uluaGetColor( L );
	lua_pop( L, 1 );
	Color color1 = uluaGetColor( L );
	lua_pop( L, 1 );
	Rectangle rect = uluaGetRectangle( L );

	DrawRectangleGradientH( rect.x, rect.y, rect.width, rect.height, color1, color2 );
	lua_pushboolean( L, true );

	return 1;
}

/*
> success = RL.DrawRectangleGradientEx( Rectangle rectangle, Color col1, Color col2, Color col3, Color col4 )

Draw a gradient-filled rectangle with custom vertex colors

- Failure return false
- Success return true
*/
int lshapesDrawRectangleGradientEx( lua_State *L ) {
	if ( !lua_istable( L, -5 ) || !lua_istable( L, -4 ) || !lua_istable( L, -3 ) || !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) {
		TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawRectangleGradientEx( Rectangle rectangle, Color col1, Color col2, Color col3, Color col4 )" );
		lua_pushboolean( L, false );
		return 1;
	}
	Color color4 = uluaGetColor( L );
	lua_pop( L, 1 );
	Color color3 = uluaGetColor( L );
	lua_pop( L, 1 );
	Color color2 = uluaGetColor( L );
	lua_pop( L, 1 );
	Color color1 = uluaGetColor( L );
	lua_pop( L, 1 );
	Rectangle rect = uluaGetRectangle( L );

	DrawRectangleGradientEx( rect, color1, color2, color3, color4 );
	lua_pushboolean( L, true );

	return 1;
}

/*
> success = RL.DrawRectangleLines( Rectangle rec, Color color )

Draw rectangle outline

- Failure return false
- Success return true
*/
int lshapesDrawRectangleLines( lua_State *L ) {
	if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) {
		TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawRectangleLines( Rectangle rec, Color color )" );
		lua_pushboolean( L, false );
		return 1;
	}
	Color color = uluaGetColor( L );
	lua_pop( L, 1 );
	Rectangle rect = uluaGetRectangle( L );

	DrawRectangleLines( rect.x, rect.y, rect.width, rect.height, color );
	lua_pushboolean( L, true );

	return 1;
}

/*
> success = RL.DrawRectangleLinesEx( Rectangle rec, int lineThick, Color color )

Draw rectangle outline with extended parameters

- Failure return false
- Success return true
*/
int lshapesDrawRectangleLinesEx( lua_State *L ) {
	if ( !lua_istable( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
		TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawRectangleLinesEx( Rectangle rec, int lineThick, Color color )" );
		lua_pushboolean( L, false );
		return 1;
	}
	Color color = uluaGetColor( L );
	lua_pop( L, 1 );
	int lineThick = lua_tointeger( L, -1 );
	lua_pop( L, 1 );
	Rectangle rect = uluaGetRectangle( L );

	DrawRectangleLinesEx( rect, lineThick, color );
	lua_pushboolean( L, true );

	return 1;
}

/*
> success = RL.DrawRectangleRounded( Rectangle rec, float roundness, int segments, Color color )

Draw rectangle with rounded edges

- Failure return false
- Success return true
*/
int lshapesDrawRectangleRounded( lua_State *L ) {
	if ( !lua_istable( L, -4 ) || !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
		TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawRectangleRounded( Rectangle rec, float roundness, int segments, Color color )" );
		lua_pushboolean( L, false );
		return 1;
	}
	Color color = uluaGetColor( L );
	lua_pop( L, 1 );
	int segments = lua_tointeger( L, -1 );
	lua_pop( L, 1 );
	float roundness = lua_tonumber( L, -1 );
	lua_pop( L, 1 );
	Rectangle rect = uluaGetRectangle( L );

	DrawRectangleRounded( rect, roundness, segments, color );
	lua_pushboolean( L, true );

	return 1;
}

/*
> success = RL.DrawRectangleRoundedLines( Rectangle rec, float roundness, int segments, int lineThick, Color color )

Draw rectangle with rounded edges outline

- Failure return false
- Success return true
*/
int lshapesDrawRectangleRoundedLines( lua_State *L ) {
	if ( !lua_istable( L, -5 ) || !lua_isnumber( L, -4 ) || !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
		TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawRectangleRoundedLines( Rectangle rec, float roundness, int segments, int lineThick, Color color )" );
		lua_pushboolean( L, false );
		return 1;
	}
	Color color = uluaGetColor( L );
	lua_pop( L, 1 );
	int lineThick = lua_tointeger( L, -1 );
	lua_pop( L, 1 );
	int segments = lua_tointeger( L, -1 );
	lua_pop( L, 1 );
	float roundness = lua_tonumber( L, -1 );
	lua_pop( L, 1 );
	Rectangle rect = uluaGetRectangle( L );

	DrawRectangleRoundedLines( rect, roundness, segments, lineThick, color );
	lua_pushboolean( L, true );

	return 1;
}

/*
> success = RL.DrawTriangle( Vector2 v1, Vector2 v2, Vector2 v3, Color color )

Draw a color-filled triangle ( Vertex in counter-clockwise order! )

- Failure return false
- Success return true
*/
int lshapesDrawTriangle( lua_State *L ) {
	if ( !lua_istable( L, -4 ) || !lua_istable( L, -3 ) || !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) {
		TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawTriangle( Vector2 v1, Vector2 v2, Vector2 v3, Color color )" );
		lua_pushboolean( L, false );
		return 1;
	}
	Color color = uluaGetColor( L );
	lua_pop( L, 1 );
	Vector2 v3 = uluaGetVector2( L );
	lua_pop( L, 1 );
	Vector2 v2 = uluaGetVector2( L );
	lua_pop( L, 1 );
	Vector2 v1 = uluaGetVector2( L );

	DrawTriangle( v1, v2, v3, color );
	lua_pushboolean( L, true );

	return 1;
}

/*
> success = RL.DrawTriangleLines( Vector2 v1, Vector2 v2, Vector2 v3, Color color )

Draw triangle outline ( Vertex in counter-clockwise order! )

- Failure return false
- Success return true
*/
int lshapesDrawTriangleLines( lua_State *L ) {
	if ( !lua_istable( L, -4 ) || !lua_istable( L, -3 ) || !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) {
		TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawTriangleLines( Vector2 v1, Vector2 v2, Vector2 v3, Color color )" );
		lua_pushboolean( L, false );
		return 1;
	}
	Color color = uluaGetColor( L );
	lua_pop( L, 1 );
	Vector2 v3 = uluaGetVector2( L );
	lua_pop( L, 1 );
	Vector2 v2 = uluaGetVector2( L );
	lua_pop( L, 1 );
	Vector2 v1 = uluaGetVector2( L );

	DrawTriangleLines( v1, v2, v3, color );
	lua_pushboolean( L, true );

	return 1;
}

/*
> success = RL.DrawTriangleFan( Vector2{} points, int pointsCount, Color color )

Draw a triangle fan defined by points ( first vertex is the center )

- Failure return false
- Success return true
*/
int lshapesDrawTriangleFan( lua_State *L ) {
	if ( !lua_istable( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
		TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawTriangleFan( Vector2{} points, int pointsCount, Color color )" );
		lua_pushboolean( L, false );
		return 1;
	}
	Color color = uluaGetColor( L );
	lua_pop( L, 1 );
	int pointsCount = lua_tointeger( L, -1 );
	lua_pop( L, 1 );
	Vector2 points[ pointsCount ];

	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 );
	}

	DrawTriangleFan( points, pointsCount, color );
	lua_pushboolean( L, true );

	return 1;
}

/*
> success = RL.DrawTriangleStrip( Vector2{} points, int pointsCount, Color color )

Draw a triangle strip defined by points

- Failure return false
- Success return true
*/
int lshapesDrawTriangleStrip( lua_State *L ) {
	if ( !lua_istable( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
		TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawTriangleStrip( Vector2{} points, int pointsCount, Color color )" );
		lua_pushboolean( L, false );
		return 1;
	}
	Color color = uluaGetColor( L );
	lua_pop( L, 1 );
	int pointsCount = lua_tointeger( L, -1 );
	lua_pop( L, 1 );
	Vector2 points[ pointsCount ];

	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 );
	}

	DrawTriangleStrip( points, pointsCount, color );
	lua_pushboolean( L, true );

	return 1;
}

/*
> success = RL.DrawPoly( Vector2 center, int sides, float radius, float rotation, Color color )

Draw a regular polygon ( Vector version )

- Failure return false
- Success return true
*/
int lshapesDrawPoly( lua_State *L ) {
	if ( !lua_istable( L, -5 ) || !lua_isnumber( L, -4 ) || !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
		TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawPoly( Vector2 center, int sides, float radius, float rotation, Color color )" );
		lua_pushboolean( L, false );
		return 1;
	}
	Color color = uluaGetColor( L );
	lua_pop( L, 1 );
	float rotation = lua_tonumber( L, -1 );
	lua_pop( L, 1 );
	float radius = lua_tonumber( L, -1 );
	lua_pop( L, 1 );
	int sides = lua_tointeger( L, -1 );
	lua_pop( L, 1 );
	Vector2 center = uluaGetVector2( L );

	DrawPoly( center, sides, radius, rotation, color );
	lua_pushboolean( L, true );

	return 1;
}

/*
> success = RL.DrawPolyLines( Vector2 center, int sides, float radius, float rotation, Color color )

Draw a polygon outline of n sides

- Failure return false
- Success return true
*/
int lshapesDrawPolyLines( lua_State *L ) {
	if ( !lua_istable( L, -5 ) || !lua_isnumber( L, -4 ) || !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
		TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawPolyLines( Vector2 center, int sides, float radius, float rotation, Color color )" );
		lua_pushboolean( L, false );
		return 1;
	}
	Color color = uluaGetColor( L );
	lua_pop( L, 1 );
	float rotation = lua_tonumber( L, -1 );
	lua_pop( L, 1 );
	float radius = lua_tonumber( L, -1 );
	lua_pop( L, 1 );
	int sides = lua_tointeger( L, -1 );
	lua_pop( L, 1 );
	Vector2 center = uluaGetVector2( L );

	DrawPolyLines( center, sides, radius, rotation, color );
	lua_pushboolean( L, true );

	return 1;
}

/*
> success = RL.DrawPolyLinesEx( Vector2 center, int sides, float radius, float rotation, float lineThick, Color color )

Draw a polygon outline of n sides with extended parameters

- Failure return false
- Success return true
*/
int lshapesDrawPolyLinesEx( lua_State *L ) {
	if ( !lua_istable( L, -6 ) || !lua_isnumber( L, -5 ) || !lua_isnumber( L, -4 ) ||
		 !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
		TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawPolyLinesEx( Vector2 center, int sides, float radius, float rotation, float lineThick, Color color )" );
		lua_pushboolean( L, false );
		return 1;
	}
	Color color = uluaGetColor( L );
	lua_pop( L, 1 );
	float lineThick = lua_tonumber( L, -1 );
	lua_pop( L, 1 );
	float rotation = lua_tonumber( L, -1 );
	lua_pop( L, 1 );
	float radius = lua_tonumber( L, -1 );
	lua_pop( L, 1 );
	int sides = lua_tointeger( L, -1 );
	lua_pop( L, 1 );
	Vector2 center = uluaGetVector2( L );

	DrawPolyLinesEx( center, sides, radius, rotation, lineThick, color );
	lua_pushboolean( L, true );

	return 1;
}

/*
## Shapes - Collision
*/

/*
> collision = RL.CheckCollisionRecs( Rectangle rec1, Rectangle rec2 )

Check collision between two rectangles

- Failure return nil
- Success return bool
*/
int lshapesCheckCollisionRecs( lua_State *L ) {
	if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) {
		TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.CheckCollisionRecs( Rectangle rec1, Rectangle rec2 )" );
		lua_pushnil( L );
		return 1;
	}
	Rectangle rect1 = uluaGetRectangle( L );
	lua_pop( L, 1 );
	Rectangle rect2 = uluaGetRectangle( L );

	lua_pushboolean( L, CheckCollisionRecs( rect1, rect2 ) );

	return 1;
}

/*
> collision = RL.CheckCollisionCircles( Vector2 center1, float radius1, Vector2 center2, float radius2 )

Check collision between two circles

- Failure return nil
- Success return bool
*/
int lshapesCheckCollisionCircles( lua_State *L ) {
	if ( !lua_istable( L, -4 ) || !lua_isnumber( L, -3 ) || !lua_istable( L, -2 ) || !lua_isnumber( L, -1 ) ) {
		TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.CheckCollisionCircles( Vector2 center1, float radius1, Vector2 center2, float radius2 )" );
		lua_pushnil( L );
		return 1;
	}
	float radius2 = lua_tonumber( L, -1 );
	lua_pop( L, 1 );
	Vector2 center2 = uluaGetVector2( L );
	lua_pop( L, 1 );
	float radius1 = lua_tonumber( L, -1 );
	lua_pop( L, 1 );
	Vector2 center1 = uluaGetVector2( L );

	lua_pushboolean( L, CheckCollisionCircles( center1, radius1, center2, radius2 ) );

	return 1;
}

/*
> collision = RL.CheckCollisionCircleRec( Vector2 center, float radius, Rectangle rec )

Check collision between circle and rectangle

- Failure return nil
- Success return bool
*/
int lshapesCheckCollisionCircleRec( lua_State *L ) {
	if ( !lua_istable( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
		TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.CheckCollisionCircleRec( Vector2 center, float radius, Rectangle rec )" );
		lua_pushnil( L );
		return 1;
	}
	Rectangle rec = uluaGetRectangle( L );
	lua_pop( L, 1 );
	float radius = lua_tonumber( L, -1 );
	lua_pop( L, 1 );
	Vector2 center = uluaGetVector2( L );

	lua_pushboolean( L, CheckCollisionCircleRec( center, radius, rec ) );

	return 1;
}

/*
> collision = RL.CheckCollisionPointRec( Vector2 point, Rectangle rec )

Check if point is inside rectangle

- Failure return nil
- Success return bool
*/
int lshapesCheckCollisionPointRec( lua_State *L ) {
	if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) {
		TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.CheckCollisionPointRec( Vector2 point, Rectangle rec )" );
		lua_pushnil( L );
		return 1;
	}
	Rectangle rec = uluaGetRectangle( L );
	lua_pop( L, 1 );
	Vector2 point = uluaGetVector2( L );

	lua_pushboolean( L, CheckCollisionPointRec( point, rec ) );

	return 1;
}

/*
> collision = RL.CheckCollisionPointCircle( Vector2 point, Vector2 center, float radius )

Check if point is inside circle

- Failure return nil
- Success return bool
*/
int lshapesCheckCollisionPointCircle( lua_State *L ) {
	if ( !lua_istable( L, -3 ) || !lua_istable( L, -2 ) || !lua_isnumber( L, -1 ) ) {
		TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.CheckCollisionPointCircle( Vector2 point, Vector2 center, float radius )" );
		lua_pushnil( L );
		return 1;
	}
	float radius = lua_tonumber( L, -1 );
	lua_pop( L, 1 );
	Vector2 center = uluaGetVector2( L );
	lua_pop( L, 1 );
	Vector2 point = uluaGetVector2( L );

	lua_pushboolean( L, CheckCollisionPointCircle( point, center, radius ) );

	return 1;
}

/*
> collision = RL.CheckCollisionPointTriangle( Vector2 point, Vector2 p1, Vector2 p2, Vector2 p3 )

Check if point is inside a triangle

- Failure return nil
- Success return bool
*/
int lshapesCheckCollisionPointTriangle( lua_State *L ) {
	if ( !lua_istable( L, -4 ) || !lua_istable( L, -3 ) || !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) {
		TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.CheckCollisionPointTriangle( Vector2 point, Vector2 p1, Vector2 p2, Vector2 p3 )" );
		lua_pushnil( L );
		return 1;
	}
	Vector2 p3 = uluaGetVector2( L );
	lua_pop( L, 1 );
	Vector2 p2 = uluaGetVector2( L );
	lua_pop( L, 1 );
	Vector2 p1 = uluaGetVector2( L );
	lua_pop( L, 1 );
	Vector2 point = uluaGetVector2( L );

	lua_pushboolean( L, CheckCollisionPointTriangle( point, p1, p2, p3 ) );

	return 1;
}

/*
> 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

- Failure return nil
- Success return bool, Vector2
*/
int lshapesCheckCollisionLines( lua_State *L ) {
	if ( !lua_istable( L, -4 ) || !lua_istable( L, -3 ) || !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) {
		TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.CheckCollisionLines( Vector2 startPos1, Vector2 endPos1, Vector2 startPos2, Vector2 endPos2 )" );
		lua_pushnil( L );
		return 1;
	}
	Vector2 endPos2 = uluaGetVector2( L );
	lua_pop( L, 1 );
	Vector2 startPos2 = uluaGetVector2( L );
	lua_pop( L, 1 );
	Vector2 endPos1 = uluaGetVector2( L );
	lua_pop( L, 1 );
	Vector2 startPos1 = uluaGetVector2( L );

	Vector2 colPoint = { 0, 0 };

	lua_pushboolean( L, CheckCollisionLines( startPos1, endPos1, startPos2, endPos2, &colPoint ) );
	uluaPushVector2( L, colPoint );

	return 2;
}

/*
> collision = RL.CheckCollisionPointLine( Vector2 point, Vector2 p1, Vector2 p2, int threshold )

Check if point belongs to line created between two points [p1] and [p2] with defined margin in pixels [threshold]

- Failure return nil
- Success return bool
*/
int lshapesCheckCollisionPointLine( lua_State *L ) {
	if ( !lua_istable( L, -4 ) || !lua_istable( L, -3 ) || !lua_istable( L, -2 ) || !lua_isnumber( L, -1 ) ) {
		TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.CheckCollisionPointLine( Vector2 point, Vector2 p1, Vector2 p2, int threshold )" );
		lua_pushnil( L );
		return 1;
	}
	int threshold = lua_tointeger( L, -1 );
	lua_pop( L, 1 );
	Vector2 p2 = uluaGetVector2( L );
	lua_pop( L, 1 );
	Vector2 p1 = uluaGetVector2( L );
	lua_pop( L, 1 );
	Vector2 point = uluaGetVector2( L );

	lua_pushboolean( L, CheckCollisionPointLine( point, p1, p2, threshold ) );

	return 1;
}

/*
> rectangle = RL.GetCollisionRec( Rectangle rec1, Rectangle rec2 )

Get collision rectangle for two rectangles collision

- Failure return nil
- Success return Rectangle
*/
int lshapesGetCollisionRec( lua_State *L ) {
	/* Rectangle rec1, Rectangle rec2 */
	if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) {
		TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.GetCollisionRec( Rectangle rec1, Rectangle rec2 )" );
		lua_pushnil( L );
		return 1;
	}
	Rectangle rec2 = uluaGetRectangle( L );
	lua_pop( L, 1 );
	Rectangle rec1 = uluaGetRectangle( L );

	uluaPushRectangle( L, GetCollisionRec( rec1, rec2 ) );

	return 1;
}