C API
The goal of the C API is make usage as similar to the original C as CFFI will allow. So the example programs are very, very similar to the C originals.
Example program:
from raylib import *
InitWindow(800, 450, b"Hello Raylib")
SetTargetFPS(60)
camera = ffi.new("struct Camera3D *", [[18.0, 16.0, 18.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0], 45.0, 0])
while not WindowShouldClose():
UpdateCamera(camera, CAMERA_ORBITAL)
BeginDrawing()
ClearBackground(RAYWHITE)
BeginMode3D(camera[0])
DrawGrid(20, 1.0)
EndMode3D()
DrawText(b"Hellow World", 190, 200, 20, VIOLET)
EndDrawing()
CloseWindow()
If you want to be more portable (i.e. same code will work with dynamic bindings) you can prefix the functions like this:
from raylib import ffi, rl, colors
rl.InitWindow(800, 450, b"Hello Raylib")
rl.SetTargetFPS(60)
...
Note
Whenever you need to convert stuff between C and Python see https://cffi.readthedocs.io
Important
Your primary reference should always be
However, here is a list of available functions:
Functions API reference
- raylib.BEIGE = (211, 176, 131, 255)
- raylib.BLACK = (0, 0, 0, 255)
- raylib.BLANK = (0, 0, 0, 0)
- raylib.BLUE = (0, 121, 241, 255)
- raylib.BROWN = (127, 106, 79, 255)
- raylib.DARKBLUE = (0, 82, 172, 255)
- raylib.DARKBROWN = (76, 63, 47, 255)
- raylib.DARKGRAY = (80, 80, 80, 255)
- raylib.DARKGREEN = (0, 117, 44, 255)
- raylib.DARKPURPLE = (112, 31, 126, 255)
- raylib.GOLD = (255, 203, 0, 255)
- raylib.GRAY = (130, 130, 130, 255)
- raylib.GREEN = (0, 228, 48, 255)
- raylib.LIGHTGRAY = (200, 200, 200, 255)
- raylib.LIME = (0, 158, 47, 255)
- raylib.MAGENTA = (255, 0, 255, 255)
- raylib.MAROON = (190, 33, 55, 255)
- raylib.ORANGE = (255, 161, 0, 255)
- raylib.PINK = (255, 109, 194, 255)
- raylib.PURPLE = (200, 122, 255, 255)
- raylib.RAYWHITE = (245, 245, 245, 255)
- raylib.RED = (230, 41, 55, 255)
- raylib.SKYBLUE = (102, 191, 255, 255)
- raylib.VIOLET = (135, 60, 190, 255)
- raylib.WHITE = (255, 255, 255, 255)
- raylib.YELLOW = (253, 249, 0, 255)