OSDN Git Service

...。
[ring-lang-081/ring.git] / docs / ja-jp / build / html / _sources / ringraylib.txt
1 .. index:: 
2         Single: RingRayLib の用法;  はじめに
3
4 =================
5 RingRayLib の用法
6 =================
7
8 この章では RingRayLib 拡張機能の用法を学びます。
9
10
11 .. index:: 
12         pair: RingRayLib の用法; はじめに
13
14 はじめに
15 ========
16
17 RingRayLib は RayLib ゲームプログラミングライブラリ用の拡張機能です。
18
19 RayGUI 関数にも対応しています。
20
21
22 .. index:: 
23         pair: RingRayLib の用法; 基本ウィンドウ
24
25 基本ウィンドウ
26 ==============
27
28 .. code-block:: ring 
29
30         load "raylib.ring"
31
32         screenWidth     = 800
33         screenHeight    = 450
34
35         InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window")
36
37         SetTargetFPS(60)
38
39         while !WindowShouldClose() 
40                 BeginDrawing()
41                 ClearBackground(RED)
42                 DrawText("Congrats! You created your first window!", 190, 200, 20, WHITE)
43                 EndDrawing()
44         end
45
46         CloseWindow()
47
48 スクリーンショット:
49
50 .. image:: raylib_basicwindow.png
51         :alt: RayLib の用例
52
53 .. index:: 
54         pair: RingRayLib の用法; キー入力
55
56 キー入力
57 ========
58
59 .. code-block:: ring 
60
61         load "raylib.ring"
62
63         screenWidth  = 800
64         screenHeight = 450
65
66         InitWindow(screenWidth, screenHeight, "raylib [core] example - keyboard input")
67         ballPosition = Vector2(screenWidth/2, screenHeight/2)
68         SetTargetFPS(60)
69
70         while !WindowShouldClose()
71                         if IsKeyDown(KEY_RIGHT) ballPosition.x += 2 ok
72                         if IsKeyDown(KEY_LEFT)  ballPosition.x -= 2 ok
73                         if IsKeyDown(KEY_UP)    ballPosition.y -= 2 ok
74                         if IsKeyDown(KEY_DOWN)  ballPosition.y += 2 ok
75                         BeginDrawing()
76                         ClearBackground(RAYWHITE)
77                         DrawText("move the ball with arrow keys", 10, 10, 20, DARKGRAY)
78                         DrawCircleV(ballPosition, 50, MAROON)
79                         EndDrawing()
80         end    
81
82         CloseWindow()
83
84 スクリーンショット:
85
86 .. image:: raylib_inputkeys.png
87         :alt: RayLib の用例
88
89
90 .. index:: 
91         pair: RingRayLib の用法; マウス入力
92
93 マウス入力
94 ==========
95
96 .. code-block:: ring 
97
98         load "raylib.ring"
99
100         screenWidth  = 800
101         screenHeight = 450
102
103         InitWindow(screenWidth, screenHeight, "raylib [core] example - mouse input")
104
105         ballPosition    = Vector2(100, 100)
106         ballColor       = DARKBLUE
107
108         SetTargetFPS(60)
109
110         while ! WindowShouldClose()
111
112                         ballPosition = GetMousePosition()
113
114                         if IsMouseButtonPressed(MOUSE_LEFT_BUTTON)
115                                 ballColor = MAROON
116                         but IsMouseButtonPressed(MOUSE_MIDDLE_BUTTON)   
117                                 ballColor = LIME
118                         but IsMouseButtonPressed(MOUSE_RIGHT_BUTTON)    
119                                 ballColor = DARKBLUE
120                         ok
121
122                         BeginDrawing()
123                         ClearBackground(BLACK)
124                         DrawCircleV(ballPosition, 40, ballColor)
125                         DrawText("move ball with mouse and click mouse button to change color",
126                                  10, 10, 20, YELLOW)
127                         EndDrawing()
128
129         end
130          
131         CloseWindow()  
132
133 スクリーンショット:
134
135 .. image:: raylib_inputmouse.png
136         :alt: RayLib の用例
137         
138 .. index:: 
139         pair: RingRayLib の用法; 3Dカメラ
140
141 3Dカメラ
142 ========
143
144 .. code-block:: ring    
145
146         load "raylib.ring"
147
148         screenWidth = 800
149         screenHeight = 450
150
151         InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera mode")
152
153         camera = Camera3D(
154                 0, 10, 10,              // カメラの位置
155                 0, 0, 0 ,               // カメラの視点位置
156                 0, 1, 0,                // カメラの上方向 (対象に向かい合って回転)
157                 45,                     // カメラの Y 視野
158                 CAMERA_PERSPECTIVE)     // カメラモードの型
159
160         cubePosition = Vector3(0, 0, 0)
161
162         SetTargetFPS(60)           
163                 
164         while !WindowShouldClose()
165
166                         BeginDrawing()
167
168                         ClearBackground(RAYWHITE)
169
170                         BeginMode3D(camera)
171
172                         DrawCube(cubePosition, 2, 2, 2, RED)
173                         DrawCubeWires(cubePosition, 2, 2, 2, MAROON)
174
175                         DrawGrid(10, 1)
176
177                         EndMode3D()
178
179                         DrawText("Welcome to the third dimension!", 10, 40, 20, DARKGRAY)
180
181                         DrawFPS(10, 10)
182
183                         EndDrawing()
184
185         end 
186
187         CloseWindow()
188
189
190 スクリーンショット:
191
192 .. image:: raylib_3dcamera.png
193         :alt: RayLib の用例
194         
195 .. index:: 
196         pair: RingRayLib の用法; 3D自由視点カメラ
197
198 3D自由視点カメラ
199 ================
200
201 .. code-block:: ring            
202
203         load "raylib.ring"
204
205         screenWidth = 800
206         screenHeight = 450
207
208         InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera free")
209
210         camera = Camera3D(
211                 10, 10, 10,             // カメラの位置
212                 0, 0, 0 ,               // カメラの視点位置
213                 0, 1, 0,                // カメラの上方向 (対象に向かい合って回転)
214                 45,                     // カメラの Y 視野
215                 CAMERA_PERSPECTIVE)     // カメラモードの型
216
217         cubePosition = Vector3(0, 0, 0)
218
219         SetCameraMode(camera, CAMERA_FREE)              // カメラモードを自由視点へ設定
220
221         SetTargetFPS(60)                   
222
223         while !WindowShouldClose()
224
225                         UpdateCamera(camera)
226
227                         if IsKeyDown("Z") camera.target = Vector3( 0, 0, 0) ok
228
229                         BeginDrawing()
230
231                         ClearBackground(RAYWHITE)
232
233                         BeginMode3D(camera)
234
235                         DrawCube(cubePosition, 2, 2, 2, RED)
236                         DrawCubeWires(cubePosition, 2, 2, 2, MAROON)
237
238                         DrawGrid(10, 1)
239
240                         EndMode3D()
241
242                         DrawRectangle( 10, 10, 320, 133, Fade(SKYBLUE, 0.5))
243                         DrawRectangleLines( 10, 10, 320, 133, BLUE)
244
245                         DrawText("Free camera default controls:", 20, 20, 10, BLACK)
246                         DrawText("- Mouse Wheel to Zoom in-out", 40, 40, 10, DARKGRAY)
247                         DrawText("- Mouse Wheel Pressed to Pan", 40, 60, 10, DARKGRAY)
248                         DrawText("- Alt + Mouse Wheel Pressed to Rotate", 40, 80, 10, DARKGRAY)
249                         DrawText("- Alt + Ctrl + Mouse Wheel Pressed for Smooth Zoom",
250                                  40, 100, 10, DARKGRAY)
251                         DrawText("- Z to zoom to (0, 0, 0)", 40, 120, 10, DARKGRAY)
252
253                         EndDrawing()
254         end 
255
256         CloseWindow() 
257
258
259 スクリーンショット:
260
261 .. image:: raylib_3dcamerafree.png
262         :alt: RayLib の用例
263
264 .. index:: 
265         pair: RingRayLib の用法; マウスホイール
266
267 マウスホイール
268 ==============
269
270 .. code-block:: ring            
271                 
272         load "raylib.ring"
273
274         screenWidth = 800
275         screenHeight = 450
276
277         InitWindow(screenWidth, screenHeight, "raylib [core] example - input mouse wheel")
278
279         boxPositionY = screenHeight/2 - 40
280         scrollSpeed = 4            
281
282         SetTargetFPS(60)  
283
284         while !WindowShouldClose()
285                 boxPositionY -= (GetMouseWheelMove()*scrollSpeed)
286
287                 BeginDrawing()
288
289                 ClearBackground(RAYWHITE)
290
291                 DrawRectangle(screenWidth/2 - 40, boxPositionY, 80, 80, MAROON)
292
293                 DrawText("Use mouse wheel to move the cube up and down!", 10, 10, 20, GRAY)
294                 DrawText("Box position Y: "+boxPositionY, 10, 40, 20, LIGHTGRAY)
295
296                 EndDrawing()
297         end
298
299         CloseWindow()
300
301
302 スクリーンショット:
303
304 .. image:: raylib_mousewheel.png
305         :alt: RayLib の用例
306         
307 .. index:: 
308         pair: RingRayLib の用法; マルチタッチ入力
309
310 マルチタッチ入力
311 ================
312
313 .. code-block:: ring 
314
315         load "raylib.ring"
316
317         screenWidth = 800
318         screenHeight = 450
319
320         InitWindow(screenWidth, screenHeight, "raylib [core] example - input multitouch")
321
322         ballPosition = Vector2(-100, -100)
323         ballColor = BEIGE
324
325         touchCounter = 0
326         touchPosition = vector2(0,0)
327
328         MAX_TOUCH_POINTS = 5
329
330         SetTargetFPS(60)
331
332         while !WindowShouldClose()
333
334                 ballPosition = GetMousePosition()
335
336                 ballColor = BEIGE
337
338                 if IsMouseButtonDown(MOUSE_LEFT_BUTTON) ballColor = MAROON ok
339                 if IsMouseButtonDown(MOUSE_MIDDLE_BUTTON) ballColor = LIME ok
340                 if IsMouseButtonDown(MOUSE_RIGHT_BUTTON) ballColor = DARKBLUE ok
341
342                 if IsMouseButtonPressed(MOUSE_LEFT_BUTTON) touchCounter = 10 ok
343                 if IsMouseButtonPressed(MOUSE_MIDDLE_BUTTON) touchCounter = 10 ok
344                 if IsMouseButtonPressed(MOUSE_RIGHT_BUTTON) touchCounter = 10 ok
345
346                 if touchCounter > 0 touchCounter-- ok
347
348                 BeginDrawing()
349
350                 ClearBackground(RAYWHITE)
351
352                 for i = 0 to MAX_TOUCH_POINTS-1
353                         touchPosition = GetTouchPosition(i)  
354
355                         if touchPosition.x >= 0 && touchPosition.y >= 0
356                                 DrawCircleV(touchPosition, 34, ORANGE)
357                                 DrawText(""+ i, touchPosition.x - 10, 
358                                         touchPosition.y - 70, 40, BLACK)
359                         ok
360                 next
361
362                 DrawCircleV(ballPosition, 30 + (touchCounter*3), ballColor)
363
364                 DrawText("move ball with mouse and click mouse button to change color",
365                                  10, 10, 20, DARKGRAY)
366                 DrawText("touch the screen at multiple locations to get multiple balls",
367                                  10, 30, 20, DARKGRAY)
368
369                 EndDrawing()
370
371         end
372
373         CloseWindow()     
374
375 スクリーンショット:
376
377 .. image:: raylib_inputmt.png
378         :alt: RayLib の用例
379         
380 .. index:: 
381         pair: RingRayLib の用法; ファーストパーソンカメラ
382
383 ファーストパーソンカメラ
384 ========================
385
386 .. code-block:: ring    
387
388         load "raylib.ring"
389
390         MAX_COLUMNS = 20
391
392         screenWidth = 800
393         screenHeight = 450
394
395         InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera first person")
396
397         camera = Camera3d(
398                 4, 2, 4,
399                 0, 1, 0,
400                 0, 1, 0,
401                 60,
402                 CAMERA_PERSPECTIVE
403         )
404
405         heights = list(MAX_COLUMNS)
406         positions = list(MAX_COLUMNS)
407         for item in positions item = vector3(0,0,0) next 
408         colors = list(MAX_COLUMNS)
409         for item in colors item = BLACK next
410
411         for i = 1 to  MAX_COLUMNS 
412                 heights[i] = GetRandomValue(1, 12)
413                 positions[i] = Vector3(GetRandomValue(-15, 15),
414                                  heights[i]/2, GetRandomValue(-15, 15) )
415                 colors[i] = RAYLibColor(GetRandomValue(20, 255),
416                                  GetRandomValue(10, 55), 30, 255 )
417         next
418
419         SetCameraMode(camera, CAMERA_FIRST_PERSON)
420
421         SetTargetFPS(60)                     
422
423         while !WindowShouldClose()
424
425                 UpdateCamera(camera)
426                 BeginDrawing()
427
428                 ClearBackground(RAYWHITE)
429
430                 BeginMode3D(camera)
431
432                 DrawPlane(Vector3( 0, 0, 0 ), Vector2(32, 32 ), LIGHTGRAY) // 地面の描画
433                 DrawCube(Vector3( -16, 2.5, 0 ), 1, 5, 32, BLUE)     // 青壁の描画
434                 DrawCube(Vector3( 16, 2.5, 0 ), 1, 5, 32, LIME)      // 緑壁の描画
435                 DrawCube(Vector3( 0, 2.5, 16 ), 32, 5, 1, GOLD)      // 黄壁の描画
436
437                 for i = 1 to  MAX_COLUMNS 
438                         DrawCube(positions[i], 2, heights[i], 2, colors[i])
439                         DrawCubeWires(positions[i], 2, heights[i], 2, MAROON)
440                 next
441
442                 EndMode3D()
443
444                 DrawRectangle( 10, 10, 220, 70, Fade(SKYBLUE, 0.5f))
445                 DrawRectangleLines( 10, 10, 220, 70, BLUE)
446
447                 DrawText("First person camera default controls:", 20, 20, 10, BLACK)
448                 DrawText("- Move with keys: W, A, S, D", 40, 40, 10, DARKGRAY)
449                 DrawText("- Mouse move to look around", 40, 60, 10, DARKGRAY)
450
451                 EndDrawing()
452         end 
453                 
454         CloseWindow()
455
456 スクリーンショット:
457
458 .. image:: raylib_camerafirstperson.png
459         :alt: RayLib の用例
460
461 .. index:: 
462         pair: RingRayLib の用法; 3Dピッキング
463
464 3Dピッキング
465 ============
466
467 .. code-block:: ring            
468
469         load "raylib.ring"
470
471         screenWidth = 800
472         screenHeight = 450
473
474         InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d picking")
475
476         camera = Camera3D(
477                 10, 10, 10,
478                 0, 0, 0 ,
479                 0, 1, 0 ,
480                 45,
481                 CAMERA_PERSPECTIVE
482         )
483
484         cubePosition = Vector3( 0, 1, 0 )
485         cubeSize = Vector3( 2, 2, 2 )
486
487         ray = Ray(0,0,0,0,0,0)
488
489         collision = false
490
491         SetCameraMode(camera, CAMERA_FREE) 
492
493         SetTargetFPS(60)
494
495         while !WindowShouldClose()
496
497                 UpdateCamera(camera)
498
499                 if IsMouseButtonPressed(MOUSE_LEFT_BUTTON)
500                         if !collision
501                                 ray = GetMouseRay(GetMousePosition(), camera)
502                                 collision = CheckCollisionRayBox(ray,
503                                 BoundingBox( cubePosition.x - cubeSize.x/2, 
504                                 cubePosition.y - cubeSize.y/2, cubePosition.z - cubeSize.z/2,
505                                 cubePosition.x + cubeSize.x/2, cubePosition.y + cubeSize.y/2,
506                                 cubePosition.z + cubeSize.z/2 ) )
507                         else collision = false
508                         ok
509                 ok
510
511                 BeginDrawing()
512
513                 ClearBackground(RAYWHITE)
514
515                 BeginMode3D(camera)
516
517                 if collision
518                         DrawCube(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, RED)
519                         DrawCubeWires(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, MAROON)
520
521                         DrawCubeWires(cubePosition, cubeSize.x + 0.2f,
522                                         cubeSize.y + 0.2f, cubeSize.z + 0.2f, GREEN)
523                 else
524                         DrawCube(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, GRAY)
525                         DrawCubeWires(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, DARKGRAY)
526                 ok
527
528                 DrawRay(ray, MAROON)
529                 DrawGrid(10, 1)
530
531                 EndMode3D()
532
533                 DrawText("Try selecting the box with mouse!", 240, 10, 20, DARKGRAY)
534
535                 if collision  DrawText("BOX SELECTED", 
536                         (screenWidth - MeasureText("BOX SELECTED", 30)) / 2, 
537                         screenHeight * 0.1f, 30, GREEN) ok
538
539                 DrawFPS(10, 10)
540
541                 EndDrawing()
542         end
543
544         CloseWindow()
545
546 スクリーンショット:
547
548 .. image:: raylib_3dpicking.png
549         :alt: RayLib の用例
550
551 .. index:: 
552         pair: RingRayLib の用法; 全画面表示
553
554 全画面表示
555 ==========
556
557 .. code-block:: ring            
558
559         load "raylib.ring"
560
561         screenWidth     = 1024
562         screenHeight    = 768
563
564         InitWindow(screenWidth, screenHeight, "Full Screen")
565         ToggleFullScreen()
566
567         SetTargetFPS(60)
568
569         while !WindowShouldClose() 
570                 BeginDrawing()
571                         ClearBackground(DARKBLUE)
572                         DrawText("Count from 1 to 10", 190, 200, 20, Yellow)
573                         for t = 1 to 10
574                                 DrawText("Number: " + t, 190, 200+(30*t), 20, WHITE)
575                         next 
576                 EndDrawing()
577         end
578
579         CloseWindow()
580
581 スクリーンショット:
582
583 .. image:: raylib_fullscreen.png
584         :alt: RayLib の用例
585
586 .. index:: 
587         pair: RingRayLib の用法; 二個の立方体
588
589 二個の立方体
590 ============
591
592 .. code-block:: ring 
593
594         load "raylib.ring"
595
596         screenWidth  = 800
597         screenHeight = 450
598         InitWindow(screenWidth, screenHeight, "raylib [core] example - Two Cubes")
599
600         camera = Camera3D(
601                 10, 10, 10,
602                 0, 0, 0 ,
603                 0, 1, 0 ,
604                 45,
605                 CAMERA_PERSPECTIVE
606         )
607
608         cubePosition1 = Vector3( 0, 1, 4 )
609         cubePosition2 = Vector3( 0, 1, -4 )
610         cubeSize = Vector3( 2, 2, 2 )
611
612         ray = Ray(0,0,0,0,0,0)
613
614         collision1 = false
615         collision2 = false
616
617         SetCameraMode(camera, CAMERA_FREE) 
618
619         SetTargetFPS(60)
620
621         while !WindowShouldClose()
622
623                         UpdateCamera(camera)
624
625                         if IsMouseButtonPressed(MOUSE_LEFT_BUTTON)
626                                 if !collision1
627                                         ray = GetMouseRay(GetMousePosition(), camera)
628
629                                         collision1 = CheckCollisionRayBox(ray,
630                                         BoundingBox( cubePosition1.x - 
631                                         cubeSize.x/2, cubePosition1.y - cubeSize.y/2,
632                                         cubePosition1.z - cubeSize.z/2,
633                                         cubePosition1.x + cubeSize.x/2,
634                                         cubePosition1.y + cubeSize.y/2,
635                                         cubePosition1.z + cubeSize.z/2 ) )
636                                 else 
637                                         collision1 = false
638                                 ok
639                                 if  !collision2
640                                         ray = GetMouseRay(GetMousePosition(), camera)
641
642                                         collision2 = CheckCollisionRayBox(ray,
643                                         BoundingBox( cubePosition2.x -
644                                         cubeSize.x/2, cubePosition2.y - cubeSize.y/2,
645                                         cubePosition2.z - cubeSize.z/2,
646                                         cubePosition2.x + cubeSize.x/2,
647                                         cubePosition2.y + cubeSize.y/2,
648                                         cubePosition2.z + cubeSize.z/2 ) )
649                                 else 
650                                         collision2 = false
651                         ok
652                 ok
653
654                         BeginDrawing()
655
656                                 ClearBackground(RAYWHITE)
657
658                                 BeginMode3D(camera)
659
660                                          if collision1
661                                                 DrawCube(cubePosition1, cubeSize.x,
662                                                 cubeSize.y, cubeSize.z, RED)
663                                                 DrawCubeWires(cubePosition1, cubeSize.x,
664                                                 cubeSize.y, cubeSize.z, MAROON)
665
666                                                 DrawCubeWires(cubePosition1, cubeSize.x +
667                                                 0.2f, cubeSize.y + 0.2f,
668                                                 cubeSize.z + 0.2f, GREEN)
669                                                 collision1 = true
670                                          else
671                                                 DrawCube(cubePosition1, cubeSize.x,
672                                                 cubeSize.y, cubeSize.z, GRAY)
673                                                 DrawCubeWires(cubePosition1, cubeSize.x,
674                                                 cubeSize.y, cubeSize.z, DARKGRAY)
675                                                 collision1 = false
676                                          ok
677
678                                          if collision2
679                                                 DrawCube(cubePosition2, cubeSize.x,
680                                                 cubeSize.y, cubeSize.z, RED)
681                                                 DrawCubeWires(cubePosition2, cubeSize.x,
682                                                 cubeSize.y, cubeSize.z, MAROON)
683
684                                                 DrawCubeWires(cubePosition2, cubeSize.x +
685                                                 0.2f, cubeSize.y + 0.2f,
686                                                 cubeSize.z + 0.2f, GREEN)
687                                                 collision2 = true
688                                          else
689                                                 DrawCube(cubePosition2, cubeSize.x,
690                                                 cubeSize.y, cubeSize.z, GRAY)
691                                                 DrawCubeWires(cubePosition2, cubeSize.x,
692                                                 cubeSize.y, cubeSize.z, DARKGRAY)
693                                                 collision2 = false
694                                          ok
695
696
697                                         DrawRay(ray, MAROON)
698                                         DrawGrid(10, 1)
699
700                                 EndMode3D()
701
702                                 DrawText("Try selecting the box with mouse!", 240, 10,
703                                                 20, DARKGRAY)
704
705                                 if collision1 or collision2  
706                                         DrawText("BOX SELECTED", 
707                                         (screenWidth - MeasureText("BOX SELECTED", 30)) / 2,
708                                         screenHeight * 0.1f, 30, GREEN) 
709                                 ok
710
711                                 DrawFPS(10, 10)
712
713                         EndDrawing()
714         end
715
716         CloseWindow()
717
718 スクリーンショット:
719
720 .. image:: raylib_twocubes.png
721         :alt: RayLib の用例
722         
723 .. index:: 
724         pair: RingRayLib の用法; 基本図形
725
726 基本図形
727 ========
728
729 .. code-block:: ring 
730
731         load "raylib.ring"
732
733         screenWidth = 800
734         screenHeight = 450
735
736         InitWindow(screenWidth, screenHeight, "raylib [shapes] example - basic shapes drawing")
737
738         SetTargetFPS(60)
739
740         while !WindowShouldClose()
741
742                 BeginDrawing()
743
744                 ClearBackground(RAYWHITE)
745
746                 DrawText("some basic shapes available on raylib", 20, 20, 20, DARKGRAY)
747
748                 DrawCircle(screenWidth/4, 120, 35, DARKBLUE)
749
750                 DrawRectangle(screenWidth/4*2 - 60, 100, 120, 60, RED)
751                 DrawRectangleLines(screenWidth/4*2 - 40, 320, 80, 60, ORANGE)  
752                 DrawRectangleGradientH(screenWidth/4*2 - 90, 170, 180, 130, MAROON, GOLD)
753
754                 DrawTriangle(Vector2(screenWidth/4*3, 80),
755                                          Vector2(screenWidth/4*3 - 60, 150),
756                                          Vector2(screenWidth/4*3 + 60, 150), VIOLET)
757
758                 DrawPoly(Vector2(screenWidth/4*3, 320), 6, 80, 0, BROWN)
759
760                 DrawCircleGradient(screenWidth/4, 220, 60, GREEN, SKYBLUE)
761
762                 DrawLine(18, 42, screenWidth - 18, 42, BLACK)
763                 DrawCircleLines(screenWidth/4, 340, 80, DARKBLUE)
764                 DrawTriangleLines(Vector2(screenWidth/4*3, 160),
765                                 Vector2(screenWidth/4*3 - 20, 230),
766                                 Vector2(screenWidth/4*3 + 20, 230), DARKBLUE)
767                 EndDrawing()
768
769         end
770
771         CloseWindow()
772
773 スクリーンショット:
774
775 .. image:: raylib_basicshapes.png
776         :alt: RayLib の用例
777
778 .. index:: 
779         pair: RingRayLib の用法; Ring の描画
780
781 Ring の描画
782 ===========
783
784 .. code-block:: ring 
785
786         load "raylib.ring"
787
788         screenWidth = 800       screenHeight = 450
789
790         InitWindow(screenWidth, screenHeight, "raylib [shapes] example - draw ring")
791
792         center = Vector2((GetScreenWidth() - 300)/2, GetScreenHeight()/2 )
793
794         innerRadius = 80        outerRadius = 190
795         startAngle = 0          endAngle = 360          segments = 0
796         drawRing = true         drawRingLines = false   drawCircleLines = false
797
798         SetTargetFPS(60)
799
800         while !WindowShouldClose()
801
802                 BeginDrawing()
803
804                 ClearBackground(RAYWHITE)
805
806                 DrawLine(500, 0, 500, GetScreenHeight(), Fade(LIGHTGRAY, 0.6))
807                 DrawRectangle(500, 0, GetScreenWidth() - 500,
808                                  GetScreenHeight(), Fade(LIGHTGRAY, 0.3))
809
810                 if drawRing DrawRing(center, innerRadius, outerRadius, 
811                         startAngle, endAngle, segments, Fade(MAROON, 0.3)) ok
812                 if drawRingLines DrawRingLines(center, innerRadius, 
813                         outerRadius, startAngle, endAngle,
814                          segments, Fade(BLACK, 0.4)) ok
815                 if drawCircleLines DrawCircleSectorLines(center, outerRadius,
816                         startAngle, endAngle, segments, Fade(BLACK, 0.4)) ok
817
818                 startAngle = GuiSliderBar(Rectangle( 600, 40, 120, 20 ), 
819                                 "StartAngle", startAngle, -450, 450, true)
820                 endAngle = GuiSliderBar(Rectangle( 600, 70, 120, 20 ), 
821                                 "EndAngle", endAngle, -450, 450, true)
822
823                 innerRadius = GuiSliderBar(Rectangle( 600, 140, 120, 20 ), 
824                                 "InnerRadius", innerRadius, 0, 100, true)
825                 outerRadius = GuiSliderBar(Rectangle( 600, 170, 120, 20 ), 
826                                 "OuterRadius", outerRadius, 0, 200, true)
827
828                 segments = GuiSliderBar(Rectangle( 600, 240, 120, 20 ), 
829                                 "Segments", segments, 0, 100, true)
830
831                 drawRing = GuiCheckBox(Rectangle( 600, 320, 20, 20 ), 
832                                 "Draw Ring", drawRing)
833                 drawRingLines = GuiCheckBox(Rectangle( 600, 350, 20, 20 ), 
834                                 "Draw RingLines", drawRingLines)
835                 drawCircleLines = GuiCheckBox(Rectangle( 600, 380, 20, 20 ), 
836                                 "Draw CircleLines", drawCircleLines)
837
838                 if segments >= 4        
839                         DrawText("MODE: MANUAL", 600, 270, 10, MAROON)
840                 else            
841                         DrawText("MODE: AUTO", 600, 270, 10, DARKGRAY)  
842                 ok
843                 
844                 DrawFPS(10, 10)
845
846                 EndDrawing()
847         end
848
849         CloseWindow()
850
851 スクリーンショット:
852
853 .. image:: raylib_drawring.png
854         :alt: RayLib の用例
855
856 スクリーンショット (2):
857
858 .. image:: raylib_drawring2.png
859         :alt: RayLib の用例
860
861 .. index:: 
862         pair: RingRayLib の用法; ベジェ曲線
863
864 ベジェ曲線
865 ==========
866
867 .. code-block:: ring 
868
869         load "raylib.ring"
870
871         screenWidth = 800
872         screenHeight = 450
873
874         SetConfigFlags(FLAG_MSAA_4X_HINT)
875         InitWindow(screenWidth, screenHeight, "raylib [shapes] example - cubic-bezier lines")
876
877         start = Vector2(0,0)
878         endvec = Vector2(screenWidth,screenHeight)
879
880         SetTargetFPS(60)  
881
882         while (!WindowShouldClose())  
883
884                 if (IsMouseButtonDown(MOUSE_LEFT_BUTTON))
885                         start = GetMousePosition() 
886                 else (IsMouseButtonDown(MOUSE_RIGHT_BUTTON))
887                           endvec = GetMousePosition()
888                 ok
889                 
890
891                 BeginDrawing()
892
893                 ClearBackground(RAYWHITE)
894                 DrawText("USE MOUSE LEFT-RIGHT CLICK to DEFINE LINE START and END POINTS",
895                                  15, 20, 20, GRAY)
896                 DrawLineBezier(start, endvec, 2.0, RED)
897
898                 EndDrawing()
899
900         end
901
902         CloseWindow()
903
904 スクリーンショット:
905
906 .. image:: raylib_bezierlines.png
907         :alt: RayLib の用例
908
909 .. index:: 
910         pair: RingRayLib の用法; 当たり判定の領域
911
912 当たり判定の領域
913 ================
914
915 .. code-block:: ring 
916
917         load "raylib.ring"
918
919         screenWidth = 800
920         screenHeight = 450
921
922         InitWindow(screenWidth, screenHeight, "raylib [shapes] example - collision area")
923
924         // ボックス A: ボックスの移動
925         boxA = Rectangle( 10, GetScreenHeight()/2 - 50, 200, 100 )
926         boxASpeedX = 4
927
928         // ボックス B: マウスで移動したボックス
929         boxB = Rectangle( GetScreenWidth()/2 - 30, GetScreenHeight()/2 - 30, 60, 60 )
930
931         boxCollision = GetCollisionRec(boxA, boxB)
932
933         boxCollision = Rectangle( 0,0,0,0 ) // 長方形の当たり判定
934
935         screenUpperLimit = 40      // トップメニューの制限
936
937         pause = false             // 移動の一時停止
938         collision = false         // 当たり判定の検出
939
940         SetTargetFPS(60)               
941
942         while !WindowShouldClose()  
943
944                 // 一時停止中でなければボックスを移動します
945                 if (not pause) boxA.x += boxASpeedX ok
946
947                 // 画面制限における X 方向のバウンスボックス
948                 if (((boxA.x + boxA.width) >= GetScreenWidth()) or (boxA.x <= 0)) 
949                         boxASpeedX = boxASpeedX*(-1) ok
950
951                 // プレイヤー操作のボックスを更新 (box02)
952                 boxB.x = GetMouseX() - boxB.width/2
953                 boxB.y = GetMouseY() - boxB.height/2
954
955                 // ボックス B が制限領域内から出られないようにします
956                 if ((boxB.x + boxB.width) >= GetScreenWidth()) 
957                         boxB.x = GetScreenWidth() - boxB.width 
958                 else (boxB.x <= 0) boxB.x = 0 ok
959
960                 if ((boxB.y + boxB.height) >= GetScreenHeight()) 
961                         boxB.y = GetScreenHeight() - boxB.height
962                 else (boxB.y <= screenUpperLimit) boxB.y = screenUpperLimit ok
963
964                 // ボックスの当たり判定を確認
965                 collision = CheckCollisionRecs(boxA, boxB)
966
967                 // 長方形の当たり判定を取得 (当たり判定のみ)
968                 if (collision) boxCollision = GetCollisionRec(boxA, boxB) ok
969
970                 // ボックス A の移動を一時停止
971                 if (IsKeyPressed(KEY_SPACE)) pause = not pause ok
972
973                 BeginDrawing()
974
975                         ClearBackground(RAYWHITE)
976
977                         if collision = true
978                            color = RED
979                         else
980                            color = BLACK
981                         ok
982                         DrawRectangle(0, 0, screenWidth, screenUpperLimit, color)
983                         DrawRectangleRec(boxA, GOLD)
984
985                         boxB.x = GetMouseX() - boxB.width/2
986                         boxB.y = GetMouseY() - boxB.height/2
987                         collision = CheckCollisionRecs(boxA, boxB)
988                         DrawRectangleRec(boxB, BLUE)
989                         boxCollision = GetCollisionRec(boxA, boxB)
990
991                         if (collision) = true
992
993                                 // 当たり判定の領域を描画
994                                 DrawRectangleRec(boxCollision, LIME)
995
996                                 // 当たり判定のメッセージを描画
997                                 DrawText("COLLISION!", GetScreenWidth()/2 -
998                                                  MeasureText("COLLISION!", 20)/2,
999                                                 screenUpperLimit/2 - 10, 20, BLACK)
1000
1001                                 // 当たり判定の領域を描画
1002                                 DrawText("Collision Area: " + 
1003                                         string(boxCollision.width*boxCollision.height),
1004                                         GetScreenWidth()/2 - 100, 
1005                                         screenUpperLimit + 10, 20, BLACK)
1006
1007                         ok
1008
1009                         DrawFPS(10, 10)
1010
1011                 EndDrawing()
1012                 
1013         end
1014
1015         CloseWindow()
1016
1017 スクリーンショット:
1018
1019 .. image:: raylib_collisionarea.png
1020         :alt: RayLib の用例
1021
1022 .. index:: 
1023         pair: RingRayLib の用法; 視線追従
1024
1025 視線追従
1026 ========
1027
1028 .. code-block:: ring
1029
1030         load "raylib.ring"
1031
1032         screenWidth = 800
1033         screenHeight = 450
1034
1035         InitWindow(screenWidth, screenHeight, "raylib [shapes] example - following eyes")
1036
1037         scleraLeftPosition = Vector2( GetScreenWidth()/2 - 100, GetScreenHeight()/2 )
1038         scleraRightPosition = Vector2( GetScreenWidth()/2 + 100, GetScreenHeight()/2 )
1039         scleraRadius = 80
1040
1041         irisLeftPosition = Vector2( GetScreenWidth()/2 - 100, GetScreenHeight()/2 )
1042         irisRightPosition = Vector2( GetScreenWidth()/2 + 100, GetScreenHeight()/2 )
1043         irisRadius = 24
1044
1045         angle = 0.0
1046         dx = 0.0 dy = 0.0 dxx = 0.0 dyy = 0.0
1047
1048         SetTargetFPS(60) 
1049
1050         while !WindowShouldClose()
1051
1052                 irisLeftPosition = GetMousePosition()
1053                 irisRightPosition = GetMousePosition()
1054
1055                 // 左目にある強膜は確認しません
1056                 if !CheckCollisionPointCircle(irisLeftPosition,
1057                         scleraLeftPosition, scleraRadius - 20)
1058                         dx = irisLeftPosition.x - scleraLeftPosition.x
1059                         dy = irisLeftPosition.y - scleraLeftPosition.y
1060
1061                         angle = atan2(dy, dx)
1062
1063                         dxx = (scleraRadius - irisRadius)*cos(angle)
1064                         dyy = (scleraRadius - irisRadius)*sin(angle)
1065
1066                         irisLeftPosition.x = scleraLeftPosition.x + dxx
1067                         irisLeftPosition.y = scleraLeftPosition.y + dyy
1068                 ok
1069
1070                 // 右目にある強膜は確認しません。
1071                 if !CheckCollisionPointCircle(irisRightPosition,
1072                          scleraRightPosition, scleraRadius - 20)
1073                         dx = irisRightPosition.x - scleraRightPosition.x
1074                         dy = irisRightPosition.y - scleraRightPosition.y
1075
1076                         angle = atan2(dy, dx)
1077
1078                         dxx = (scleraRadius - irisRadius)*cos(angle)
1079                         dyy = (scleraRadius - irisRadius)*sin(angle)
1080
1081                         irisRightPosition.x = scleraRightPosition.x + dxx
1082                         irisRightPosition.y = scleraRightPosition.y + dyy
1083                 ok
1084
1085                 BeginDrawing()
1086
1087                         ClearBackground(RAYWHITE)
1088
1089                         DrawCircleV(scleraLeftPosition, scleraRadius, LIGHTGRAY)
1090                         DrawCircleV(irisLeftPosition, irisRadius, BROWN)
1091                         DrawCircleV(irisLeftPosition, 10, BLACK)
1092
1093                         DrawCircleV(scleraRightPosition, scleraRadius, LIGHTGRAY)
1094                         DrawCircleV(irisRightPosition, irisRadius, DARKGREEN)
1095                         DrawCircleV(irisRightPosition, 10, BLACK)
1096
1097                         DrawFPS(10, 10)
1098
1099                 EndDrawing()
1100
1101         end
1102
1103         CloseWindow()
1104
1105 スクリーンショット:
1106
1107 .. image:: raylib_followingeyes.png
1108         :alt: RayLib の用例
1109         
1110 .. index:: 
1111         pair: RingRayLib の用法; カラーパレット
1112
1113 カラーパレット
1114 ==============
1115
1116 .. code-block:: ring
1117
1118         load "raylib.ring"
1119
1120         MAX_COLORS_COUNT = 21          // 利用できる色値数
1121
1122         screenWidth = 800
1123         screenHeight = 450
1124         colors = list(MAX_COLORS_COUNT)
1125         colorNames = list(MAX_COLORS_COUNT)
1126         colorsRecs = list(MAX_COLORS_COUNT)
1127         colorState = list(MAX_COLORS_COUNT)
1128
1129         InitWindow(screenWidth, screenHeight, "raylib [shapes] example - colors palette")
1130
1131         colors = [
1132                 DARKGRAY, MAROON, ORANGE, DARKGREEN, DARKBLUE, DARKPURPLE, DARKBROWN,
1133                 GRAY, RED, GOLD, LIME, BLUE, VIOLET, BROWN, LIGHTGRAY, PINK, YELLOW,
1134                 GREEN, SKYBLUE, PURPLE, BEIGE ]
1135
1136         colorNames = [
1137                 "DARKGRAY", "MAROON", "ORANGE", "DARKGREEN", "DARKBLUE", "DARKPURPLE",
1138                 "DARKBROWN", "GRAY", "RED", "GOLD", "LIME", "BLUE", "VIOLET", "BROWN",
1139                 "LIGHTGRAY", "PINK", "YELLOW", "GREEN", "SKYBLUE", "PURPLE", "BEIGE" ]
1140
1141         for i = 1 to MAX_COLORS_COUNT
1142                 colorsRecs[i] = new Rectangle(0,0,0,0) 
1143         next
1144
1145         for i = 1 to MAX_COLORS_COUNT
1146                 colorState[i] = 0
1147         next
1148
1149
1150         // colorsRecs データで塗りつぶします (長方形ごとに)
1151         for i = 1 to MAX_COLORS_COUNT
1152                 colorsRecs[i].x = 20 + 100*((i-1)%7) + 10*((i-1)%7)
1153                 colorsRecs[i].y = 80 + 100*floor((i-1)/7) + 10*floor((i-1)/7)
1154                 colorsRecs[i].width = 100
1155                 colorsRecs[i].height = 100
1156         next
1157
1158         mousePoint = Vector2( 0.0, 0.0 )
1159
1160         SetTargetFPS(60)
1161
1162         // ゲームのメインループ
1163         while !WindowShouldClose()
1164
1165                 mousePoint = GetMousePosition()
1166
1167                 for i = 1 to MAX_COLORS_COUNT 
1168                         if (CheckCollisionPointRec(mousePoint,
1169                                  colorsRecs[i])) colorState[i] = 1
1170                         else colorState[i] = 0 ok
1171                 next
1172
1173                 BeginDrawing()
1174
1175                         ClearBackground(RAYWHITE)
1176
1177                         DrawText("raylib colors palette", 28, 42, 20, BLACK)
1178                         DrawText("press SPACE to see all colors",
1179                                          GetScreenWidth() - 180,
1180                                          GetScreenHeight() - 40, 10, GRAY)
1181
1182                         for i = 1 to MAX_COLORS_COUNT    // 長方形の描画
1183                                 if colorState[i]
1184                                    cstate = 0.6
1185                                 else
1186                                    cstate = 1.0
1187                                 ok
1188
1189                                 DrawRectangleRec(colorsRecs[i], Fade(colors[i], cstate))
1190
1191                                 if (IsKeyDown(KEY_SPACE) || colorState[i])
1192                                         DrawRectangle(colorsRecs[i].x,
1193                                         colorsRecs[i].y + colorsRecs[i].height - 26,
1194                                         colorsRecs[i].width, 20, BLACK)
1195                                         DrawRectangleLinesEx(colorsRecs[i], 6,
1196                                         Fade(BLACK, 0.3f))
1197                                         DrawText(colorNames[i], colorsRecs[i].x + 
1198                                         colorsRecs[i].width - MeasureText(colorNames[i],
1199                                         10) - 12, colorsRecs[i].y +
1200                                         colorsRecs[i].height - 20, 10, colors[i])
1201                                 ok
1202                         next
1203
1204                 EndDrawing()
1205                 
1206         end
1207
1208         CloseWindow()
1209
1210
1211 スクリーンショット:
1212
1213 .. image:: raylib_colorspalette.png
1214         :alt: RayLib の用例
1215
1216 .. index:: 
1217         pair: RingRayLib の用法; 長方形の拡縮
1218
1219 長方形の拡縮
1220 ============
1221
1222 .. code-block:: ring    
1223
1224         load "raylib.ring"
1225
1226         MOUSE_SCALE_MARK_SIZE = 12
1227
1228         screenWidth = 800
1229         screenHeight = 450
1230
1231         InitWindow(screenWidth, screenHeight,
1232                          "raylib [shapes] example - rectangle scaling mouse")
1233
1234         rec = Rectangle( 100, 100, 200, 80 )
1235
1236         mousePosition = Vector2( 0,0 )
1237
1238         mouseScaleReady = false
1239         mouseScaleMode = false
1240
1241         SetTargetFPS(60)
1242
1243         while !WindowShouldClose()
1244
1245                 mousePosition = GetMousePosition()
1246
1247                 if (CheckCollisionPointRec(mousePosition, rec) and
1248                         CheckCollisionPointRec(mousePosition,
1249                          Rectangle(rec.x + rec.width - MOUSE_SCALE_MARK_SIZE,
1250                                 rec.y + rec.height - MOUSE_SCALE_MARK_SIZE,
1251                                  MOUSE_SCALE_MARK_SIZE, MOUSE_SCALE_MARK_SIZE )))
1252                         mouseScaleReady = true
1253                         if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) 
1254                                 mouseScaleMode = true ok
1255                 else mouseScaleReady = false ok
1256
1257                 if (mouseScaleMode)
1258                 
1259                         mouseScaleReady = true
1260
1261                         rec.width = (mousePosition.x - rec.x)
1262                         rec.height = (mousePosition.y - rec.y)
1263
1264                         if (rec.width < MOUSE_SCALE_MARK_SIZE) 
1265                                 rec.width = MOUSE_SCALE_MARK_SIZE ok
1266                         if (rec.height < MOUSE_SCALE_MARK_SIZE) 
1267                                 rec.height = MOUSE_SCALE_MARK_SIZE ok
1268
1269                         if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) 
1270                                 mouseScaleMode = false ok
1271                 ok
1272
1273                 BeginDrawing()
1274
1275                         ClearBackground(RAYWHITE)
1276
1277                         DrawText("Scale rectangle dragging from bottom-right corner!",
1278                                          10, 10, 20, GRAY)
1279
1280                         DrawRectangleRec(rec, Fade(GREEN, 0.5f))
1281
1282                         if (mouseScaleReady)
1283                    
1284                                 DrawRectangleLinesEx(rec, 1, RED)
1285                                 DrawTriangle(Vector2( rec.x + rec.width -
1286                                 MOUSE_SCALE_MARK_SIZE, rec.y + rec.height ),
1287                                 Vector2( rec.x + rec.width, rec.y + rec.height ),
1288                                 Vector2( rec.x + rec.width, rec.y + rec.height -
1289                                          MOUSE_SCALE_MARK_SIZE ), RED)
1290                         ok
1291
1292                 EndDrawing()
1293
1294         end
1295
1296         CloseWindow()
1297
1298
1299 スクリーンショット:
1300
1301 .. image:: raylib_rectanglescaling.png
1302         :alt: RayLib の用例
1303
1304 .. index:: 
1305         pair: RingRayLib の用法; 音楽のストリーミング再生
1306
1307 音楽のストリーミング再生
1308 ========================
1309
1310 .. code-block:: ring    
1311
1312         load "raylib.ring"
1313
1314         screenWidth = 800
1315         screenHeight = 450
1316
1317         InitWindow(screenWidth, screenHeight,
1318                  "raylib [audio] example - music playing (streaming)")
1319
1320         InitAudioDevice()               
1321
1322         music = LoadMusicStream("guitar_noodling.ogg")
1323
1324         PlayMusicStream(music)
1325
1326         timePlayed = 0.0
1327         pause = false
1328
1329         SetTargetFPS(60)
1330
1331
1332         while !WindowShouldClose()
1333
1334                 UpdateMusicStream(music)  
1335
1336                 if IsKeyPressed(KEY_SPACE)   
1337                         StopMusicStream(music)
1338                         PlayMusicStream(music)
1339                 ok
1340
1341                 if IsKeyPressed(KEY_P)
1342                         pause = !pause
1343
1344                         if pause 
1345                                 PauseMusicStream(music)
1346                         else 
1347                                 ResumeMusicStream(music)
1348                         ok
1349                 ok
1350
1351                 timePlayed = GetMusicTimePlayed(music) / GetMusicTimeLength(music) *400
1352
1353                 if timePlayed > 400 
1354                         StopMusicStream(music)
1355                 ok
1356
1357                 BeginDrawing()
1358
1359                         ClearBackground(RAYWHITE)
1360
1361                         DrawText("MUSIC SHOULD BE PLAYING!", 255, 150, 20, LIGHTGRAY)
1362
1363                                  DrawRectangle(200, 200, 400, 12, LIGHTGRAY)
1364                                  DrawRectangle(200, 200, timePlayed, 12, MAROON)
1365                         DrawRectangleLines(200, 200, 400, 12, GRAY)
1366
1367                         DrawText("PRESS SPACE  TO RESTART MUSIC", 215, 250, 20, LIGHTGRAY)
1368                         DrawText("PRESS P TO PAUSE/RESUME MUSIC", 208, 280, 20, LIGHTGRAY)
1369
1370                 EndDrawing()
1371
1372         end 
1373
1374         UnloadMusicStream(music)
1375
1376         CloseAudioDevice()
1377
1378         CloseWindow()
1379
1380 スクリーンショット:
1381         
1382 .. image:: raylib_musicplaying.png
1383         :alt: RayLib の用例
1384
1385 .. index:: 
1386         pair: RingRayLib の用法; 音声の読み込みと再生
1387
1388 音声の読み込みと再生
1389 ====================
1390
1391 .. code-block:: ring    
1392
1393         load "raylib.ring"
1394
1395         screenWidth = 800
1396         screenHeight = 450
1397
1398         InitWindow(screenWidth, screenHeight,
1399                         "raylib [audio] example - sound loading and playing")
1400
1401         InitAudioDevice()       
1402
1403         fxWav = LoadSound("sound.wav")         
1404         fxOgg = LoadSound("tanatana.ogg")  
1405
1406
1407         SetTargetFPS(60) 
1408
1409         while !WindowShouldClose()
1410
1411                 if IsKeyPressed(KEY_SPACE) PlaySound(fxWav)  ok  
1412                 if IsKeyPressed(KEY_ENTER) PlaySound(fxOgg)  ok  
1413
1414                 BeginDrawing()
1415
1416                         ClearBackground(RAYWHITE)
1417
1418                         DrawText("Press SPACE to PLAY the WAV sound!", 200, 180, 20, LIGHTGRAY)
1419                         DrawText("Press ENTER to PLAY the OGG sound!", 200, 220, 20, LIGHTGRAY)
1420
1421                 EndDrawing()
1422                 
1423         end
1424
1425         UnloadSound(fxWav)
1426         UnloadSound(fxOgg)
1427
1428         CloseAudioDevice() 
1429
1430         CloseWindow()
1431
1432 スクリーンショット:
1433         
1434 .. image:: raylib_soundloading.png
1435         :alt: RayLib の用例
1436
1437         
1438 .. index:: 
1439         pair: RingRayLib の用法; 画像の描画
1440
1441 画像の描画
1442 ==========
1443
1444 .. code-block:: ring    
1445
1446         load "raylib.ring"
1447
1448         screenWidth  = 800
1449         screenHeight = 450
1450
1451         InitWindow(screenWidth, screenHeight,
1452                          "raylib [textures] example - image drawing")
1453
1454         cat = LoadImage("cat.png")                              
1455
1456         ImageCrop( cat,  Rectangle( 100, 10, 280, 380 ))        
1457         ImageFlipHorizontal( cat)                               
1458         ImageResize( cat, 150, 200)                             
1459
1460         parrots = LoadImage("parrots.png")                      
1461
1462         ImageDraw( parrots, cat, Rectangle( 0, 0, cat.width, cat.height ), 
1463                                 Rectangle( 30, 40, cat.width*1.5, cat.height*1.5 ))
1464         ImageCrop( parrots, Rectangle( 0, 50, parrots.width, parrots.height - 100 )) 
1465
1466         UnloadImage(cat)       
1467
1468         font = LoadFont("custom_jupiter_crash.png")
1469
1470         ImageDrawTextEx(parrots, Vector2( 300, 230 ), font,
1471                          "PARROTS & CAT", font.baseSize, -2, WHITE)
1472         UnloadFont(font);                              
1473
1474         texture = LoadTextureFromImage(parrots)        
1475
1476         UnloadImage(parrots)                           
1477
1478         SetTargetFPS(60)
1479
1480         while !WindowShouldClose()
1481                 BeginDrawing()
1482
1483                 ClearBackground(RAYWHITE)
1484
1485                 DrawTexture(texture, screenWidth/2 - texture.width/2,
1486                         screenHeight/2 - texture.height/2 - 40, WHITE)
1487                 DrawRectangleLines(screenWidth/2 - texture.width/2,
1488                         screenHeight/2 - texture.height/2 - 40,
1489                          texture.width, texture.height, DARKGRAY)
1490
1491                 DrawText("We are drawing only one texture from various images composed!",
1492                                         240, 350, 10, DARKGRAY)
1493                 DrawText("Source images have been cropped, scaled,"+
1494                                 " flipped and copied one over the other.",
1495                                         190, 370, 10, DARKGRAY)
1496
1497                 EndDrawing()
1498         end
1499
1500         UnloadTexture(texture)       
1501
1502         CloseWindow()                
1503
1504 スクリーンショット:
1505         
1506 .. image:: raylib_imagedrawing.png
1507         :alt: RayLib の用例
1508
1509         
1510 .. index:: 
1511         pair: RingRayLib の用法; 画像生成
1512
1513 画像生成
1514 ========
1515
1516 .. code-block:: ring            
1517
1518         load "raylib.ring"
1519
1520         NUM_TEXTURES = 7
1521         textures     = list(7)
1522
1523         screenWidth  = 800
1524         screenHeight = 450
1525
1526         InitWindow(screenWidth, screenHeight,
1527                  "raylib [textures] example - procedural images generation")
1528
1529         verticalGradient   = GenImageGradientV(screenWidth, screenHeight, RED, BLUE)
1530         horizontalGradient = GenImageGradientH(screenWidth, screenHeight, RED, BLUE)
1531         radialGradient     = GenImageGradientRadial(screenWidth,
1532                                  screenHeight, 0.0, WHITE, BLACK)
1533         checked            = GenImageChecked(screenWidth, screenHeight,
1534                                  32, 32, RED, BLUE)
1535         whiteNoise         = GenImageWhiteNoise(screenWidth, screenHeight, 0.5)
1536         perlinNoise        = GenImagePerlinNoise(screenWidth, screenHeight, 50, 50, 4.0)
1537         cellular           = GenImageCellular(screenWidth, screenHeight, 32)
1538          
1539         textures[NUM_TEXTURES] =  0 
1540                            
1541         textures[1] = LoadTextureFromImage(verticalGradient)
1542         textures[2] = LoadTextureFromImage(horizontalGradient)
1543         textures[3] = LoadTextureFromImage(radialGradient)
1544         textures[4] = LoadTextureFromImage(checked)
1545         textures[5] = LoadTextureFromImage(whiteNoise)
1546         textures[6] = LoadTextureFromImage(perlinNoise)
1547         textures[7] = LoadTextureFromImage(cellular)
1548
1549         UnloadImage(verticalGradient)
1550         UnloadImage(horizontalGradient)
1551         UnloadImage(radialGradient)
1552         UnloadImage(checked)
1553         UnloadImage(whiteNoise)
1554         UnloadImage(perlinNoise)
1555         UnloadImage(cellular)
1556
1557         currentTexture = 1  
1558
1559         SetTargetFPS(10)
1560          
1561         while !WindowShouldClose()
1562
1563                 if IsMouseButtonPressed(MOUSE_LEFT_BUTTON) || IsKeyPressed(KEY_RIGHT)
1564                         currentTexture++
1565                         if currentTexture > NUM_TEXTURES  currentTexture = 1 ok
1566                 ok
1567
1568                 BeginDrawing()
1569
1570                         ClearBackground(RAYWHITE)
1571
1572                         DrawTexture(textures[currentTexture], 0, 0, WHITE)
1573
1574                         DrawRectangle(30, 400, 325, 30, Fade(SKYBLUE, 0.5))
1575                         DrawRectangleLines(30, 400, 325, 30, Fade(WHITE, 0.5))
1576                         DrawText("MOUSE LEFT BUTTON to CYCLE PROCEDURAL TEXTURES",
1577                                  40, 410, 10, WHITE)
1578
1579                         switch(currentTexture)
1580                                 on 1  DrawText("VERTICAL GRADIENT", 560, 10, 20, RAYWHITE)  
1581                                 on 2  DrawText("HORIZONTAL GRADIENT", 540, 10, 20, RAYWHITE)
1582                                 on 3  DrawText("RADIAL GRADIENT", 580, 10, 20, LIGHTGRAY)   
1583                                 on 4  DrawText("CHECKED", 680, 10, 20, RAYWHITE)            
1584                                 on 5  DrawText("WHITE NOISE", 640, 10, 20, RED)             
1585                                 on 6  DrawText("PERLIN NOISE", 630, 10, 20, RAYWHITE)       
1586                                 on 7  DrawText("CELLULAR", 670, 10, 20, RAYWHITE)           
1587                         off 
1588
1589                 EndDrawing()
1590
1591         end
1592
1593         for i = 1 to  NUM_TEXTURES
1594                 UnloadTexture( textures[i] )
1595         next 
1596
1597         CloseWindow()
1598
1599
1600 スクリーンショット:
1601         
1602 .. image:: raylib_imagegeneration.png
1603         :alt: RayLib の用例
1604
1605         
1606 .. index:: 
1607         pair: RingRayLib の用法; テクスチャの入力
1608
1609 テクスチャの入力
1610 ================
1611
1612 .. code-block:: ring    
1613         
1614         load "raylib.ring"
1615
1616         screenWidth = 800
1617         screenHeight = 800
1618
1619         InitWindow(screenWidth, screenHeight,
1620                 "raylib [textures] examples - texture source and destination rectangles")
1621
1622         // 注意: テクスチャの読み込みは必ずウィンドウの初期化後に行ってください
1623         // (OpenGL コンテキストが必要です)
1624
1625         scarfy = LoadTexture("RingLogo.png")        // テクスチャの読み込み
1626
1627         frameWidth = scarfy.width
1628         frameHeight = scarfy.height
1629
1630         // 入力元となる長方形 (描画で使うテクスチャ部品です)
1631         sourceRec = Rectangle( 0.0, 0.0, frameWidth, frameHeight )
1632
1633         // 出力先の長方形 (テクスチャ部品は画面へ長方形として描画されます)
1634         destRec = Rectangle( screenWidth/2, screenHeight/2, frameWidth*2, frameHeight*2 )
1635
1636         // オリジナルのテクスチャ (回転/点の拡縮)
1637         // つまり、出力先の長方形の相対的寸法です
1638         origin = Vector2( frameWidth, frameHeight )
1639
1640         rotation = 0
1641
1642         SetTargetFPS(60)
1643
1644         while !WindowShouldClose()
1645
1646                 rotation = rotation+1
1647
1648                 BeginDrawing()
1649
1650                         ClearBackground(RAYWHITE)
1651
1652                         DrawTexturePro(scarfy, sourceRec, destRec,
1653                                          origin, rotation, WHITE)
1654
1655                         DrawLine(destRec.x, 0, destRec.x, screenHeight, GRAY)
1656                         DrawLine(0, destRec.y, screenWidth, destRec.y, GRAY)
1657
1658                         DrawText("(c) Scarfy sprite by Eiden Marsal",
1659                                  screenWidth - 200, screenHeight - 20, 10, GRAY)
1660
1661                 EndDrawing()
1662
1663         end
1664
1665         UnloadTexture(scarfy)        // テクスチャの解放
1666
1667         CloseWindow()
1668                 
1669
1670 スクリーンショット:
1671         
1672 .. image:: raylib_texturesource.png
1673         :alt: RayLib の用例  
1674
1675
1676 .. index:: 
1677         pair: RingRayLib の用法; 幾何学的図形
1678
1679 幾何学的図形
1680 ============
1681
1682 .. code-block:: ring    
1683
1684         load "raylib.ring"
1685
1686         FOVY_PERSPECTIVE   =  45.0
1687         WIDTH_ORTHOGRAPHIC =  10.0
1688
1689         screenWidth  = 800
1690         screenHeight = 450
1691
1692         InitWindow(screenWidth, screenHeight,
1693                  "raylib [models] example - geometric shapes")
1694
1695         camera = Camera3D(  0.0, 10.0, 10.0,
1696                                         0.0, 0.0, 0.0,
1697                                         0.0, 1.0, 0.0, 
1698                                         FOVY_PERSPECTIVE, CAMERA_PERSPECTIVE 
1699                                 )
1700
1701         SetTargetFPS(60)       
1702
1703         while !WindowShouldClose()  
1704
1705                 if IsKeyPressed(KEY_SPACE)
1706                 
1707                         if camera.type = CAMERA_PERSPECTIVE
1708                         
1709                                 camera.fovy = WIDTH_ORTHOGRAPHIC
1710                                 camera.type = CAMERA_ORTHOGRAPHIC
1711                         
1712                         else
1713                         
1714                                 camera.fovy = FOVY_PERSPECTIVE
1715                                 camera.type = CAMERA_PERSPECTIVE
1716                         ok
1717                 ok
1718
1719                 BeginDrawing()
1720
1721                 ClearBackground(RAYWHITE)
1722
1723                 BeginMode3D(camera)
1724
1725                 DrawCube(Vector3(-4.0, 0.0,  2.0), 2.0, 5.0, 2.0, RED)
1726                 DrawCubeWires(Vector3(-4.0, 0.0,  2.0), 2.0, 5.0, 2.0, GOLD)
1727                 DrawCubeWires(Vector3(-4.0, 0.0, -2.0), 3.0, 6.0, 2.0, MAROON)
1728
1729                 DrawSphere(Vector3(-1.0, 0.0, -2.0), 1.0, GREEN)
1730                 DrawSphereWires(Vector3( 1.0, 0.0,  2.0), 2.0, 16, 16, LIME)
1731
1732                 DrawCylinder(Vector3(4.0, 0.0, -2.0), 1.0, 2.0, 3.0, 4, SKYBLUE)
1733                 DrawCylinderWires(Vector3(4.0, 0.0, -2.0), 1.0, 2.0, 3.0, 4, DARKBLUE)
1734                 DrawCylinderWires(Vector3(4.5, -1.0, 2.0), 1.0, 1.0, 2.0, 6, BROWN)
1735
1736                 DrawCylinder(Vector3(1.0, 0.0, -4.0), 0.0, 1.5, 3.0, 8, GOLD)
1737                 DrawCylinderWires(Vector3(1.0, 0.0, -4.0), 0.0, 1.5, 3.0, 8, PINK)
1738
1739                 DrawGrid(10, 1.0)
1740
1741                 EndMode3D()
1742
1743                 DrawText("Press Spacebar to switch camera type", 10,
1744                                  GetScreenHeight() - 30, 20, DARKGRAY)
1745
1746                 if camera.type = CAMERA_ORTHOGRAPHIC
1747                         DrawText("ORTHOGRAPHIC", 10, 40, 20, BLACK)
1748                 else 
1749                         if camera.type = CAMERA_PERSPECTIVE 
1750                                 DrawText("PERSPECTIVE", 10, 40, 20, BLACK)
1751                         ok
1752                 ok
1753
1754                 DrawFPS(10, 10)
1755
1756                 EndDrawing()
1757                 
1758         end
1759
1760         CloseWindow()
1761
1762 スクリーンショット:
1763         
1764 .. image:: raylib_geometricshapes.png
1765         :alt: RayLib の用例  
1766
1767
1768 .. index:: 
1769         pair: RingRayLib の用法; キュービックマップ
1770
1771 キュービックマップ
1772 ==================
1773
1774 .. code-block:: ring
1775
1776         load "raylib.ring"
1777
1778         screenWidth  = 800
1779         screenHeight = 450
1780
1781         InitWindow(screenWidth, screenHeight,
1782                  "raylib [models] example - cubesmap loading and drawing")
1783
1784         camera = Camera3D( 16.0, 14.0, 16.0,
1785                                          0.0, 0.0, 0.0,
1786                                          0.0, 1.0, 0.0, 
1787                                          45.0, 0 )
1788
1789         image    = LoadImage("cubicmap.png")        
1790         cubicmap = LoadTextureFromImage(image)      
1791
1792         mesh     = GenMeshCubicmap(image, Vector3( 1.0, 1.0, 1.0 ))
1793         model    = LoadModelFromMesh(mesh)
1794
1795         texture  = LoadTexture("cubicmap_atlas.png") 
1796
1797         setmodelmaterialtexture(model,0,MAP_DIFFUSE,texture)
1798
1799         mapPosition = Vector3( -16.0, 0.0, -8.0 )   
1800
1801         UnloadImage(image)                     
1802         SetCameraMode(camera, CAMERA_ORBITAL)  
1803         SetTargetFPS(60)                       
1804         
1805         while !WindowShouldClose()
1806
1807                 UpdateCamera(camera)
1808                 
1809                 BeginDrawing()
1810
1811                         ClearBackground(RAYWHITE)
1812                         BeginMode3D(camera)
1813                                 DrawModel(model, mapPosition, 1.0, WHITE)
1814                         EndMode3D()
1815
1816                         DrawTextureEx(cubicmap, Vector2( screenWidth -
1817                                          cubicmap.width*4 - 20, 20 ),
1818                                                         0.0, 4.0, WHITE)
1819                         DrawRectangleLines(screenWidth - cubicmap.width*4 -
1820                                          20, 20, cubicmap.width*4,
1821                                         cubicmap.height*4, GREEN)
1822
1823                         DrawText("cubicmap image used to", 658,  90, 10, GRAY)
1824                         DrawText("generate map 3d model",  658, 104, 10, GRAY)
1825                         DrawFPS(10, 10)
1826
1827                 EndDrawing()
1828                 
1829         end
1830
1831         UnloadTexture(cubicmap) 
1832         UnloadTexture(texture)  
1833         UnloadModel(model)      
1834
1835         CloseWindow()
1836         
1837 スクリーンショット:
1838         
1839 .. image:: raylib_cubicmap.png
1840         :alt: RayLib の用例
1841
1842
1843 .. index:: 
1844         pair: RingRayLib の用法; 関数
1845
1846 関数
1847 ====
1848
1849 .. code-block:: none
1850
1851         void InitWindow(int width, int height, const char *title)
1852         bool WindowShouldClose(void)
1853         void CloseWindow(void)
1854         bool IsWindowReady(void)
1855         bool IsWindowMinimized(void)
1856         bool IsWindowResized(void)
1857         bool IsWindowHidden(void)
1858         void ToggleFullscreen(void)
1859         void UnhideWindow(void)
1860         void HideWindow(void)
1861         void SetWindowIcon(Image image)
1862         void SetWindowTitle(const char *title)
1863         void SetWindowPosition(int x, int y)
1864         void SetWindowMonitor(int monitor)
1865         void SetWindowMinSize(int width, int height)
1866         void SetWindowSize(int width, int height)
1867         void *GetWindowHandle(void)
1868         int GetScreenWidth(void)
1869         int GetScreenHeight(void)
1870         int GetMonitorCount(void)
1871         int GetMonitorWidth(int monitor)
1872         int GetMonitorHeight(int monitor)
1873         int GetMonitorPhysicalWidth(int monitor)
1874         int GetMonitorPhysicalHeight(int monitor)
1875         const char *GetMonitorName(int monitor)
1876         const char *GetClipboardText(void)
1877         void SetClipboardText(const char *text)
1878         void ShowCursor(void)
1879         void HideCursor(void)
1880         bool IsCursorHidden(void)
1881         void EnableCursor(void)
1882         void DisableCursor(void)
1883         void ClearBackground(Color color)
1884         void BeginDrawing(void)
1885         void EndDrawing(void)
1886         void BeginMode2D(Camera2D camera)
1887         void EndMode2D(void)
1888         void BeginMode3D(Camera3D camera)
1889         void EndMode3D(void)
1890         void BeginTextureMode(RenderTexture2D target)
1891         void EndTextureMode(void)
1892         Ray GetMouseRay(Vector2 mousePosition, Camera3D camera)
1893         Vector2 GetWorldToScreen(Vector3 position, Camera3D camera)
1894         Matrix GetCameraMatrix(Camera3D camera)
1895         void SetTargetFPS(int fps)
1896         int GetFPS(void)
1897         float GetFrameTime(void)
1898         double GetTime(void)
1899         int ColorToInt(Color color)
1900         Vector4 ColorNormalize(Color color)
1901         Vector3 ColorToHSV(Color color)
1902         Color ColorFromHSV(Vector3 hsv)
1903         Color GetColor(int hexValue)
1904         Color Fade(Color color, float alpha)
1905         void SetConfigFlags(unsigned char flags)
1906         void SetTraceLogLevel(int logType)
1907         void SetTraceLogExit(int logType)
1908         void SetTraceLogCallback(TraceLogCallback callback)
1909         void TraceLog(int logType, const char *text)
1910         void TakeScreenshot(const char *fileName)
1911         int GetRandomValue(int min, int max)
1912         bool FileExists(const char *fileName)
1913         bool IsFileExtension(const char *fileName, const char *ext)
1914         const char *GetExtension(const char *fileName)
1915         const char *GetFileName(const char *filePath)
1916         const char *GetFileNameWithoutExt(const char *filePath)
1917         const char *GetDirectoryPath(const char *fileName)
1918         const char *GetWorkingDirectory(void)
1919         char **GetDirectoryFiles(const char *dirPath, int *count)
1920         void ClearDirectoryFiles(void)
1921         bool ChangeDirectory(const char *dir)
1922         bool IsFileDropped(void)
1923         char **GetDroppedFiles(int *count)
1924         void ClearDroppedFiles(void)
1925         long GetFileModTime(const char *fileName)
1926         void StorageSaveValue(int position, int value)
1927         int StorageLoadValue(int position)
1928         void OpenURL(const char *url)
1929         bool IsKeyPressed(int key)
1930         bool IsKeyDown(int key)
1931         bool IsKeyReleased(int key)
1932         bool IsKeyUp(int key)
1933         int GetKeyPressed(void)
1934         void SetExitKey(int key)
1935         bool IsGamepadAvailable(int gamepad)
1936         bool IsGamepadName(int gamepad, const char *name)
1937         const char *GetGamepadName(int gamepad)
1938         bool IsGamepadButtonPressed(int gamepad, int button)
1939         bool IsGamepadButtonDown(int gamepad, int button)
1940         bool IsGamepadButtonReleased(int gamepad, int button)
1941         bool IsGamepadButtonUp(int gamepad, int button)
1942         int GetGamepadButtonPressed(void)
1943         int GetGamepadAxisCount(int gamepad)
1944         float GetGamepadAxisMovement(int gamepad, int axis)
1945         bool IsMouseButtonPressed(int button)
1946         bool IsMouseButtonDown(int button)
1947         bool IsMouseButtonReleased(int button)
1948         bool IsMouseButtonUp(int button)
1949         int GetMouseX(void)
1950         int GetMouseY(void)
1951         Vector2 GetMousePosition(void)
1952         void SetMousePosition(int x, int y)
1953         void SetMouseOffset(int offsetX, int offsetY)
1954         void SetMouseScale(float scaleX, float scaleY)
1955         int GetMouseWheelMove(void)
1956         int GetTouchX(void)
1957         int GetTouchY(void)
1958         Vector2 GetTouchPosition(int index)
1959         void SetGesturesEnabled(unsigned int gestureFlags)
1960         bool IsGestureDetected(int gesture)
1961         int GetGestureDetected(void)
1962         int GetTouchPointsCount(void)
1963         float GetGestureHoldDuration(void)
1964         Vector2 GetGestureDragVector(void)
1965         float GetGestureDragAngle(void)
1966         Vector2 GetGesturePinchVector(void)
1967         float GetGesturePinchAngle(void)
1968         void SetCameraMode(Camera3D camera, int mode)
1969         void UpdateCamera(Camera3D *camera)
1970         void SetCameraPanControl(int panKey)
1971         void SetCameraAltControl(int altKey)
1972         void SetCameraSmoothZoomControl(int szKey)
1973         void SetCameraMoveControls(int frontKey, int backKey, int rightKey, int leftKey,
1974                  int upKey, int downKey)
1975         void DrawPixel(int posX, int posY, Color color)
1976         void DrawPixelV(Vector2 position, Color color)
1977         void DrawLine(int startPosX, int startPosY, int endPosX, int endPosY, Color color)
1978         void DrawLineV(Vector2 startPos, Vector2 endPos, Color color)
1979         void DrawLineEx(Vector2 startPos, Vector2 endPos, float thick, Color color)
1980         void DrawLineBezier(Vector2 startPos, Vector2 endPos, float thick, Color color)
1981         void DrawLineStrip(Vector2 *points, int numPoints, Color color)
1982         void DrawCircle(int centerX, int centerY, float radius, Color color)
1983         void DrawCircleSector(Vector2 center, float radius, int startAngle, int endAngle,
1984                  int segments, Color color)
1985         void DrawCircleSectorLines(Vector2 center, float radius, int startAngle, 
1986                 int endAngle, int segments, Color color)
1987         void DrawCircleGradient(int centerX, int centerY, float radius, 
1988                 Color color1, Color color2)
1989         void DrawCircleV(Vector2 center, float radius, Color color)
1990         void DrawCircleLines(int centerX, int centerY, float radius, Color color)
1991         void DrawRing(Vector2 center, float innerRadius, float outerRadius,
1992                  int startAngle, int endAngle, int segments, Color color)
1993         void DrawRingLines(Vector2 center, float innerRadius, float outerRadius,
1994                  int startAngle, int endAngle, int segments, Color color)
1995         void DrawRectangle(int posX, int posY, int width, int height, Color color)
1996         void DrawRectangleV(Vector2 position, Vector2 size, Color color)
1997         void DrawRectangleRec(Rectangle rec, Color color)
1998         void DrawRectanglePro(Rectangle rec, Vector2 origin, 
1999                 float rotation, Color color)
2000         void DrawRectangleGradientV(int posX, int posY, int width, 
2001                 int height, Color color1, Color color2)
2002         void DrawRectangleGradientH(int posX, int posY, int width, 
2003                 int height, Color color1, Color color2)
2004         void DrawRectangleGradientEx(Rectangle rec, Color col1, 
2005                 Color col2, Color col3, Color col4)
2006         void DrawRectangleLines(int posX, int posY, int width, 
2007                 int height, Color color)
2008         void DrawRectangleLinesEx(Rectangle rec, int lineThick, Color color)
2009         void DrawRectangleRounded(Rectangle rec, float roundness, 
2010                 int segments, Color color)
2011         void DrawRectangleRoundedLines(Rectangle rec, float roundness, 
2012                 int segments, int lineThick, Color color)
2013         void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color)
2014         void DrawTriangleLines(Vector2 v1, Vector2 v2, Vector2 v3, Color color)
2015         void DrawTriangleFan(Vector2 *points, int numPoints, Color color)
2016         void DrawPoly(Vector2 center, int sides, float radius, 
2017                 float rotation, Color color)
2018         void SetShapesTexture(Texture2D texture, Rectangle source)
2019         bool CheckCollisionRecs(Rectangle rec1, Rectangle rec2)
2020         bool CheckCollisionCircles(Vector2 center1, float radius1, 
2021                 Vector2 center2, float radius2)
2022         bool CheckCollisionCircleRec(Vector2 center, float radius, 
2023                 Rectangle rec)
2024         Rectangle GetCollisionRec(Rectangle rec1, Rectangle rec2)
2025         bool CheckCollisionPointRec(Vector2 point, Rectangle rec)
2026         bool CheckCollisionPointCircle(Vector2 point, Vector2 center, float radius)
2027         bool CheckCollisionPointTriangle(Vector2 point, Vector2 p1, 
2028                 Vector2 p2, Vector2 p3)
2029         Image LoadImage(const char *fileName)
2030         Image LoadImageEx(Color *pixels, int width, int height)
2031         Image LoadImagePro(void *data, int width, int height, int format)
2032         Image LoadImageRaw(const char *fileName, int width, int height, 
2033                 int format, int headerSize)
2034         void ExportImage(Image image, const char *fileName)
2035         void ExportImageAsCode(Image image, const char *fileName)
2036         Texture2D LoadTexture(const char *fileName)
2037         Texture2D LoadTextureFromImage(Image image)
2038         TextureCubemap LoadTextureCubemap(Image image, int layoutType)
2039         RenderTexture2D LoadRenderTexture(int width, int height)
2040         void UnloadImage(Image image)
2041         void UnloadTexture(Texture2D texture)
2042         void UnloadRenderTexture(RenderTexture2D target)
2043         Color *GetImageData(Image image)
2044         Vector4 *GetImageDataNormalized(Image image)
2045         int GetPixelDataSize(int width, int height, int format)
2046         Image GetTextureData(Texture2D texture)
2047         Image GetScreenData(void)
2048         void UpdateTexture(Texture2D texture, const void *pixels)
2049         Image ImageCopy(Image image)
2050         void ImageToPOT(Image *image, Color fillColor)
2051         void ImageFormat(Image *image, int newFormat)
2052         void ImageAlphaMask(Image *image, Image alphaMask)
2053         void ImageAlphaClear(Image *image, Color color, float threshold)
2054         void ImageAlphaCrop(Image *image, float threshold)
2055         void ImageAlphaPremultiply(Image *image)
2056         void ImageCrop(Image *image, Rectangle crop)
2057         void ImageResize(Image *image, int newWidth, int newHeight)
2058         void ImageResizeNN(Image *image, int newWidth,int newHeight)
2059         void ImageResizeCanvas(Image *image, int newWidth, int newHeight, 
2060                 int offsetX, int offsetY, Color color)
2061         void ImageMipmaps(Image *image)
2062         void ImageDither(Image *image, int rBpp, int gBpp, int bBpp, int aBpp)
2063         Color *ImageExtractPalette(Image image, int maxPaletteSize, int *extractCount)
2064         Image ImageText(const char *text, int fontSize, Color color)
2065         Image ImageTextEx(Font font, const char *text, float fontSize, 
2066                 float spacing, Color tint)
2067         void ImageDraw(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec)
2068         void ImageDrawRectangle(Image *dst, Rectangle rec, Color color)
2069         void ImageDrawRectangleLines(Image *dst, Rectangle rec, int thick, Color color)
2070         void ImageDrawText(Image *dst, Vector2 position, const char *text, 
2071                 int fontSize, Color color)
2072         void ImageDrawTextEx(Image *dst, Vector2 position, Font font, 
2073                 const char *text, float fontSize, float spacing, Color color)
2074         void ImageFlipVertical(Image *image)
2075         void ImageFlipHorizontal(Image *image)
2076         void ImageRotateCW(Image *image)
2077         void ImageRotateCCW(Image *image)
2078         void ImageColorTint(Image *image, Color color)
2079         void ImageColorInvert(Image *image)
2080         void ImageColorGrayscale(Image *image)
2081         void ImageColorContrast(Image *image, float contrast)
2082         void ImageColorBrightness(Image *image, int brightness)
2083         void ImageColorReplace(Image *image, Color color, Color replace)
2084         Image GenImageColor(int width, int height, Color color)
2085         Image GenImageGradientV(int width, int height, Color top, Color bottom)
2086         Image GenImageGradientH(int width, int height, Color left, Color right)
2087         Image GenImageGradientRadial(int width, int height, float density, 
2088                 Color inner, Color outer)
2089         Image GenImageChecked(int width, int height, int checksX, int checksY, 
2090                 Color col1, Color col2)
2091         Image GenImageWhiteNoise(int width, int height, float factor)
2092         Image GenImagePerlinNoise(int width, int height, int offsetX, 
2093                 int offsetY, float scale)
2094         Image GenImageCellular(int width, int height, int tileSize)
2095         void GenTextureMipmaps(Texture2D *texture)
2096         void SetTextureFilter(Texture2D texture, int filterMode)
2097         void SetTextureWrap(Texture2D texture, int wrapMode)
2098         void DrawTexture(Texture2D texture, int posX, int posY, Color tint)
2099         void DrawTextureV(Texture2D texture, Vector2 position, Color tint)
2100         void DrawTextureEx(Texture2D texture, Vector2 position, 
2101                 float rotation, float scale, Color tint)
2102         void DrawTextureRec(Texture2D texture, Rectangle sourceRec, 
2103                 Vector2 position, Color tint)
2104         void DrawTextureQuad(Texture2D texture, Vector2 tiling, Vector2 offset, 
2105                 Rectangle quad, Color tint)
2106         void DrawTexturePro(Texture2D texture, Rectangle sourceRec, 
2107                 Rectangle destRec, Vector2 origin, float rotation, Color tint)
2108         void DrawTextureNPatch(Texture2D texture, NPatchInfo nPatchInfo, 
2109                 Rectangle destRec, Vector2 origin, float rotation, Color tint)
2110         Font GetFontDefault(void)
2111         Font LoadFont(const char *fileName)
2112         Font LoadFontEx(const char *fileName, int fontSize, 
2113                 int *fontChars, int charsCount)
2114         Font LoadFontFromImage(Image image, Color key, int firstChar)
2115         CharInfo *LoadFontData(const char *fileName, int fontSize, 
2116                 int *fontChars, int charsCount, int type)
2117         Image GenImageFontAtlas(CharInfo *chars, int charsCount, 
2118                 int fontSize, int padding, int packMethod)
2119         void UnloadFont(Font font)
2120         void DrawFPS(int posX, int posY)
2121         void DrawText(const char *text, int posX, int posY, int fontSize, Color color)
2122         void DrawTextEx(Font font, const char *text, Vector2 position, 
2123                 float fontSize, float spacing, Color tint)
2124         void DrawTextRec(Font font, const char *text, Rectangle rec, 
2125                 float fontSize, float spacing, bool wordWrap, Color tint)
2126         void DrawTextRecEx(Font font, const char *text, Rectangle rec, 
2127                 float fontSize, float spacing, bool wordWrap, Color tint,
2128                 int selectStart, int selectLength, Color selectText, Color selectBack)
2129         int MeasureText(const char *text, int fontSize)
2130         Vector2 MeasureTextEx(Font font, const char *text, 
2131                 float fontSize, float spacing)
2132         int GetGlyphIndex(Font font, int character)
2133         int GetNextCodepoint(const char *text, int *count)
2134         bool TextIsEqual(const char *text1, const char *text2)
2135         unsigned int TextLength(const char *text)
2136         unsigned int TextCountCodepoints(const char *text)
2137         const char *TextFormat(const char *text)
2138         const char *TextSubtext(const char *text, int position, int length)
2139         const char *TextReplace(char *text, const char *replace, const char *by)
2140         const char *TextInsert(const char *text, const char *insert, int position)
2141         const char *TextJoin(const char **textList, int count, const char *delimiter)
2142         const char **TextSplit(const char *text, char delimiter, int *count)
2143         void TextAppend(char *text, const char *append, int *position)
2144         int TextFindIndex(const char *text, const char *find)
2145         const char *TextToUpper(const char *text)
2146         const char *TextToLower(const char *text)
2147         const char *TextToPascal(const char *text)
2148         int TextToInteger(const char *text)
2149         void DrawLine3D(Vector3 startPos, Vector3 endPos, Color color)
2150         void DrawCircle3D(Vector3 center, float radius, Vector3 rotationAxis, 
2151         float rotationAngle, Color color)
2152         void DrawCube(Vector3 position, float width, float height, float length, Color color)
2153         void DrawCubeV(Vector3 position, Vector3 size, Color color)
2154         void DrawCubeWires(Vector3 position, float width, float height, 
2155                 float length, Color color)
2156         void DrawCubeWiresV(Vector3 position, Vector3 size, Color color)
2157         void DrawCubeTexture(Texture2D texture, Vector3 position, 
2158                 float width, float height, float length, Color color)
2159         void DrawSphere(Vector3 centerPos, float radius, Color color)
2160         void DrawSphereEx(Vector3 centerPos, float radius, int rings, 
2161                 int slices, Color color)
2162         void DrawSphereWires(Vector3 centerPos, float radius, int rings, 
2163                 int slices, Color color)
2164         void DrawCylinder(Vector3 position, float radiusTop, float radiusBottom, 
2165                 float height, int slices, Color color)
2166         void DrawCylinderWires(Vector3 position, float radiusTop, 
2167                 float radiusBottom, float height, int slices, Color color)
2168         void DrawPlane(Vector3 centerPos, Vector2 size, Color color)
2169         void DrawRay(Ray ray, Color color)
2170         void DrawGrid(int slices, float spacing)
2171         void DrawGizmo(Vector3 position)
2172         Model LoadModel(const char *fileName)
2173         Model LoadModelFromMesh(Mesh mesh)
2174         void UnloadModel(Model model)
2175         Mesh *LoadMeshes(const char *fileName, int *meshCount)
2176         void ExportMesh(Mesh mesh, const char *fileName)
2177         void UnloadMesh(Mesh *mesh)
2178         Material *LoadMaterials(const char *fileName, int *materialCount)
2179         Material LoadMaterialDefault(void)
2180         void UnloadMaterial(Material material)
2181         void SetMaterialTexture(Material *material, int mapType, Texture2D texture)
2182         void SetModelMeshMaterial(Model *model, int meshId, int materialId)
2183         ModelAnimation *LoadModelAnimations(const char *fileName, int *animsCount)
2184         void UpdateModelAnimation(Model model, ModelAnimation anim, int frame)
2185         void UnloadModelAnimation(ModelAnimation anim)
2186         bool IsModelAnimationValid(Model model, ModelAnimation anim)
2187         Mesh GenMeshPoly(int sides, float radius)
2188         Mesh GenMeshPlane(float width, float length, int resX, int resZ)
2189         Mesh GenMeshCube(float width, float height, float length)
2190         Mesh GenMeshSphere(float radius, int rings, int slices)
2191         Mesh GenMeshHemiSphere(float radius, int rings, int slices)
2192         Mesh GenMeshCylinder(float radius, float height, int slices)
2193         Mesh GenMeshTorus(float radius, float size, int radSeg, int sides)
2194         Mesh GenMeshKnot(float radius, float size, int radSeg, int sides)
2195         Mesh GenMeshHeightmap(Image heightmap, Vector3 size)
2196         Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize)
2197         BoundingBox MeshBoundingBox(Mesh mesh)
2198         void MeshTangents(Mesh *mesh)
2199         void MeshBinormals(Mesh *mesh)
2200         void DrawModel(Model model, Vector3 position, float scale, Color tint)
2201         void DrawModelEx(Model model, Vector3 position, Vector3 rotationAxis, 
2202                 float rotationAngle, Vector3 scale, Color tint)
2203         void DrawModelWires(Model model, Vector3 position, float scale, Color tint)
2204         void DrawModelWiresEx(Model model, Vector3 position, 
2205                 Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint)
2206         void DrawBoundingBox(BoundingBox box, Color color)
2207         void DrawBillboard(Camera3D camera, Texture2D texture, 
2208                 Vector3 center, float size, Color tint)
2209         void DrawBillboardRec(Camera3D camera, Texture2D texture, 
2210                 Rectangle sourceRec, Vector3 center, float size, Color tint)
2211         bool CheckCollisionSpheres(Vector3 centerA, float radiusA, 
2212                 Vector3 centerB, float radiusB)
2213         bool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2)
2214         bool CheckCollisionBoxSphere(BoundingBox box, Vector3 centerSphere, float radiusSphere)
2215         bool CheckCollisionRaySphere(Ray ray, Vector3 spherePosition, float sphereRadius)
2216         bool CheckCollisionRaySphereEx(Ray ray, Vector3 spherePosition, 
2217                 float sphereRadius, Vector3 *collisionPoint)
2218         bool CheckCollisionRayBox(Ray ray, BoundingBox box)
2219         RayHitInfo GetCollisionRayModel(Ray ray, Model *model)
2220         RayHitInfo GetCollisionRayTriangle(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3)
2221         RayHitInfo GetCollisionRayGround(Ray ray, float groundHeight)
2222         char *LoadText(const char *fileName)
2223         Shader LoadShader(const char *vsFileName, const char *fsFileName)
2224         Shader LoadShaderCode(char *vsCode, char *fsCode)
2225         void UnloadShader(Shader shader)
2226         Shader GetShaderDefault(void)
2227         Texture2D GetTextureDefault(void)
2228         int GetShaderLocation(Shader shader, const char *uniformName)
2229         void SetShaderValue(Shader shader, int uniformLoc, 
2230                 const void *value, int uniformType)
2231         void SetShaderValueV(Shader shader, int uniformLoc, 
2232                 const void *value, int uniformType, int count)
2233         void SetShaderValueMatrix(Shader shader, int uniformLoc, Matrix mat)
2234         void SetShaderValueTexture(Shader shader, int uniformLoc, Texture2D texture)
2235         void SetMatrixProjection(Matrix proj)
2236         void SetMatrixModelview(Matrix view)
2237         Matrix GetMatrixModelview(void)
2238         Texture2D GenTextureCubemap(Shader shader, Texture2D skyHDR, int size)
2239         Texture2D GenTextureIrradiance(Shader shader, Texture2D cubemap, int size)
2240         Texture2D GenTexturePrefilter(Shader shader, Texture2D cubemap, int size)
2241         Texture2D GenTextureBRDF(Shader shader, int size)
2242         void BeginShaderMode(Shader shader)
2243         void EndShaderMode(void)
2244         void BeginBlendMode(int mode)
2245         void EndBlendMode(void)
2246         void BeginScissorMode(int x, int y, int width, int height)
2247         void EndScissorMode(void)
2248         void InitVrSimulator(void)
2249         void CloseVrSimulator(void)
2250         void UpdateVrTracking(Camera3D *camera)
2251         void SetVrConfiguration(VrDeviceInfo info, Shader distortion)
2252         bool IsVrSimulatorReady(void)
2253         void ToggleVrMode(void)
2254         void BeginVrDrawing(void)
2255         void EndVrDrawing(void)
2256         void InitAudioDevice(void)
2257         void CloseAudioDevice(void)
2258         bool IsAudioDeviceReady(void)
2259         void SetMasterVolume(float volume)
2260         Wave LoadWave(const char *fileName)
2261         Wave LoadWaveEx(void *data, int sampleCount, int sampleRate, 
2262                 int sampleSize, int channels)
2263         Sound LoadSound(const char *fileName)
2264         Sound LoadSoundFromWave(Wave wave)
2265         void UpdateSound(Sound sound, const void *data, int samplesCount)
2266         void UnloadWave(Wave wave)
2267         void UnloadSound(Sound sound)
2268         void ExportWave(Wave wave, const char *fileName)
2269         void ExportWaveAsCode(Wave wave, const char *fileName)
2270         void PlaySound(Sound sound)
2271         void PauseSound(Sound sound)
2272         void ResumeSound(Sound sound)
2273         void StopSound(Sound sound)
2274         bool IsSoundPlaying(Sound sound)
2275         void SetSoundVolume(Sound sound, float volume)
2276         void SetSoundPitch(Sound sound, float pitch)
2277         void WaveFormat(Wave *wave, int sampleRate, int sampleSize, int channels)
2278         Wave WaveCopy(Wave wave)
2279         void WaveCrop(Wave *wave, int initSample, int finalSample)
2280         float *GetWaveData(Wave wave)
2281         Music LoadMusicStream(const char *fileName)
2282         void UnloadMusicStream(Music music)
2283         void PlayMusicStream(Music music)
2284         void UpdateMusicStream(Music music)
2285         void StopMusicStream(Music music)
2286         void PauseMusicStream(Music music)
2287         void ResumeMusicStream(Music music)
2288         bool IsMusicPlaying(Music music)
2289         void SetMusicVolume(Music music, float volume)
2290         void SetMusicPitch(Music music, float pitch)
2291         void SetMusicLoopCount(Music music, int count)
2292         float GetMusicTimeLength(Music music)
2293         float GetMusicTimePlayed(Music music)
2294         AudioStream InitAudioStream(unsigned int sampleRate, 
2295                 unsigned int sampleSize, unsigned int channels)
2296         void UpdateAudioStream(AudioStream stream, const void *data, int samplesCount)
2297         void CloseAudioStream(AudioStream stream)
2298         bool IsAudioBufferProcessed(AudioStream stream)
2299         void PlayAudioStream(AudioStream stream)
2300         void PauseAudioStream(AudioStream stream)
2301         void ResumeAudioStream(AudioStream stream)
2302         bool IsAudioStreamPlaying(AudioStream stream)
2303         void StopAudioStream(AudioStream stream)
2304         void SetAudioStreamVolume(AudioStream stream, float volume)
2305         void SetAudioStreamPitch(AudioStream stream, float pitch)
2306         void GuiEnable(void)
2307         void GuiDisable(void)
2308         void GuiLock(void)
2309         void GuiUnlock(void)
2310         void GuiState(int state)
2311         void GuiFont(Font font)
2312         void GuiFade(float alpha)
2313         void GuiSetStyle(int control, int property, int value)
2314         int GuiGetStyle(int control, int property)
2315         bool GuiWindowBox(Rectangle bounds, const char *text)
2316         void GuiGroupBox(Rectangle bounds, const char *text)
2317         void GuiLine(Rectangle bounds, const char *text)
2318         void GuiPanel(Rectangle bounds)
2319         Rectangle GuiScrollPanel(Rectangle bounds, Rectangle content, Vector2 *scroll)
2320         void GuiLabel(Rectangle bounds, const char *text)
2321         bool GuiButton(Rectangle bounds, const char *text)
2322         bool GuiLabelButton(Rectangle bounds, const char *text)
2323         bool GuiImageButton(Rectangle bounds, Texture2D texture)
2324         bool GuiImageButtonEx(Rectangle bounds, Texture2D texture, 
2325                 Rectangle texSource, const char *text)
2326         bool GuiToggle(Rectangle bounds, const char *text, bool active)
2327         int GuiToggleGroup(Rectangle bounds, const char *text, int active)
2328         bool GuiCheckBox(Rectangle bounds, const char *text, bool checked)
2329         int GuiComboBox(Rectangle bounds, const char *text, int active)=
2330         bool GuiDropdownBox(Rectangle bounds, const char *text, 
2331                 int *active, bool editMode)
2332         bool GuiSpinner(Rectangle bounds, int *value, int minValue, 
2333                 int maxValue, bool editMode)
2334         bool GuiValueBox(Rectangle bounds, int *value, int minValue, 
2335                 int maxValue, bool editMode)
2336         bool GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
2337         bool GuiTextBoxMulti(Rectangle bounds, char *text, int textSize, bool editMode)
2338         float GuiSlider(Rectangle bounds, const char *text, float value, 
2339                 float minValue, float maxValue, bool showValue)
2340         float GuiSliderBar(Rectangle bounds, const char *text, float value, 
2341                 float minValue, float maxValue, bool showValue)
2342         float GuiProgressBar(Rectangle bounds, const char *text, float value, 
2343                 float minValue, float maxValue, bool showValue)
2344         void GuiStatusBar(Rectangle bounds, const char *text)
2345         void GuiDummyRec(Rectangle bounds, const char *text)
2346         int GuiScrollBar(Rectangle bounds, int value, int minValue, int maxValue)
2347         Vector2 GuiGrid(Rectangle bounds, float spacing, int subdivs)
2348         bool GuiListView(Rectangle bounds, const char *text, int *active, 
2349                 int *scrollIndex, bool editMode)
2350         bool GuiListViewEx(Rectangle bounds, const char **text, int count, 
2351                 int *enabled, int *active, int *focus, int *scrollIndex, bool editMode)
2352         int GuiMessageBox(Rectangle bounds, const char *windowTitle, 
2353                 const char *message, const char *buttons)
2354         int GuiTextInputBox(Rectangle bounds, const char *windowTitle, 
2355                 const char *message, char *text, const char *buttons)
2356         Color GuiColorPicker(Rectangle bounds, Color color)
2357         void GuiLoadStyle(const char *fileName)
2358         void GuiLoadStyleProps(const int *props, int count)
2359         void GuiLoadStyleDefault(void)
2360         void GuiUpdateStyleComplete(void)
2361         const char *GuiIconText(int iconId, const char *text)