Skip to main content

src/ffi/ffi.gleam

pub type Color

pub type Image

pub type Vector2

pub type Texture

pub type Rectangle

@external(javascript, "./rl.mjs", "getX")
pub fn get_x2(of vector: Vector2) -> Float

@external(javascript, "./rl.mjs", "getY")
pub fn get_y2(of vector: Vector2) -> Float

@external(javascript, "./rl.mjs", "BeginDrawing")
pub fn begin_drawing() -> Nil

@external(javascript, "./rl.mjs", "ClearBackground")
pub fn clear_background(color color: Color) -> Nil

@external(javascript, "./rl.mjs", "DisableCursor")
pub fn disable_cursor() -> Nil

@external(javascript, "./rl.mjs", "DisableEventWaiting")
pub fn disable_event_waiting() -> Nil

@external(javascript, "./rl.mjs", "DrawCircle")
pub fn draw_circle(
  x x: Int,
  y y: Int,
  radius radius: Float,
  color color: Color,
) -> Nil

@external(javascript, "./rl.mjs", "DrawCircleLines")
pub fn draw_circle_lines(
  x x: Int,
  y y: Int,
  radius radius: Float,
  color color: Color,
) -> Nil

@external(javascript, "./rl.mjs", "DrawCircleSector")
pub fn draw_circle_sector(
  center center: Vector2,
  radius radius: Float,
  from start_angle: Float,
  to end_angle: Float,
  segments segments: Int,
  color color: Color,
) -> Nil

@external(javascript, "./rl.mjs", "DrawCircleSectorLines")
pub fn draw_circle_sector_lines(
  center center: Vector2,
  radius radius: Float,
  from start_angle: Float,
  to end_angle: Float,
  segments segments: Int,
  color color: Color,
) -> Nil

@external(javascript, "./rl.mjs", "DrawEllipse")
pub fn draw_ellipse(
  x x: Int,
  y y: Int,
  radius_h radius_h: Float,
  radius_v radius_v: Float,
  color color: Color,
) -> Nil

@external(javascript, "./rl.mjs", "DrawEllipseLines")
pub fn draw_ellipse_lines(
  x x: Int,
  y y: Int,
  radius_h radius_h: Float,
  radius_v radius_v: Float,
  color color: Color,
) -> Nil

@external(javascript, "./rl.mjs", "DrawLine")
pub fn draw_line(
  sx sx: Int,
  sy sy: Int,
  ex ex: Int,
  ey ey: Int,
  color color: Color,
) -> Nil

@external(javascript, "./rl.mjs", "DrawLineBezier")
pub fn draw_line_bezier(
  start start: Vector2,
  end end: Vector2,
  thick thick: Float,
  color color: Color,
) -> Nil

@external(javascript, "./rl.mjs", "DrawLineEx")
pub fn draw_line_ex(
  start start: Vector2,
  end end: Vector2,
  thick thick: Float,
  color color: Color,
) -> Nil

@external(javascript, "./rl.mjs", "DrawPixel")
pub fn draw_pixel(x x: Int, y y: Int, color color: Color) -> Nil

@external(javascript, "./rl.mjs", "DrawRectangle")
pub fn draw_rectangle(
  x x: Int,
  y y: Int,
  w width: Int,
  h height: Int,
  color color: Color,
) -> Nil

@external(javascript, "./rl.mjs", "DrawRectanglePro")
pub fn draw_rectangle_pro(
  rec rec: Rectangle,
  origin origin: Vector2,
  rot rotation: Float,
  color color: Color,
) -> Nil

@external(javascript, "./rl.mjs", "DrawRectangleRounded")
pub fn draw_rectangle_rounded(
  rec rec: Rectangle,
  roundness roundness: Float,
  segments segments: Int,
  color color: Color,
) -> Nil

@external(javascript, "./rl.mjs", "DrawRectangleRoundedLinesEx")
pub fn draw_rectangle_rounded_lines_ex(
  rec rec: Rectangle,
  roundness roundness: Float,
  segments segments: Int,
  thick thick: Float,
  color color: Color,
) -> Nil

@external(javascript, "./rl.mjs", "DrawRing")
pub fn draw_ring(
  center: Vector2,
  from_radius inner_radius: Float,
  to_radius outer_radius: Float,
  from_angle start_angle: Float,
  to_angle end_angle: Float,
  segments segments: Int,
  color color: Color,
) -> Nil

@external(javascript, "./rl.mjs", "DrawRingLines")
pub fn draw_ring_lines(
  center center: Vector2,
  from_radius inner_radius: Float,
  to_radius outer_radius: Float,
  from_angle start_angle: Float,
  to_angle end_angle: Float,
  segments segments: Float,
  color color: Color,
) -> Nil

@external(javascript, "./rl.mjs", "EnableCursor")
pub fn enable_cursor() -> Nil

@external(javascript, "./rl.mjs", "EnableEventWaiting")
pub fn enable_event_waiting() -> Nil

@external(javascript, "./rl.mjs", "EndDrawing")
pub fn end_drawing() -> Nil

@external(javascript, "./rl.mjs", "GetCharPressed")
pub fn get_char_pressed() -> Int

@external(javascript, "./rl.mjs", "GetClipboardImage")
pub fn get_clipboard_image() -> Image

@external(javascript, "./rl.mjs", "GetClipboardText")
pub fn get_clipboard_text() -> String

@external(javascript, "./rl.mjs", "GetColor")
pub fn get_color(from hex: Int) -> Color

@external(javascript, "./rl.mjs", "GetFPS")
pub fn get_fps() -> Int

@external(javascript, "./rl.mjs", "GetFrameTime")
pub fn get_frame_time() -> Float

@external(javascript, "./rl.mjs", "GetKeyPressed")
pub fn get_key_pressed() -> Int

@external(javascript, "./rl.mjs", "GetMonitorCount")
pub fn get_monitor_count() -> Int

@external(javascript, "./rl.mjs", "GetCurrentMonitor")
pub fn get_current_monitor() -> Int

@external(javascript, "./rl.mjs", "GetMonitorHeight")
pub fn get_monitor_height(of monitor: Int) -> Int

@external(javascript, "./rl.mjs", "GetMonitorName")
pub fn get_monitor_name(of monitor: Int) -> String

@external(javascript, "./rl.mjs", "GetMonitorPhysicalHeight")
pub fn get_monitor_physical_height(of monitor: Int) -> Int

@external(javascript, "./rl.mjs", "GetMonitorPhysicalWidth")
pub fn get_monitor_physical_width(of monitor: Int) -> Int

@external(javascript, "./rl.mjs", "GetMonitorPosition")
pub fn get_monitor_position(of monitor: Int) -> Vector2

@external(javascript, "./rl.mjs", "GetMonitorRefreshRate")
pub fn get_monitor_refresh_rate(of monitor: Int) -> Int

@external(javascript, "./rl.mjs", "GetMonitorWidth")
pub fn get_monitor_width(of monitor: Int) -> Int

@external(javascript, "./rl.mjs", "GetMouseDelta")
pub fn get_mouse_delta() -> Vector2

@external(javascript, "./rl.mjs", "GetMousePosition")
pub fn get_mouse_position() -> Vector2

@external(javascript, "./rl.mjs", "GetMouseWheelMove")
pub fn get_mouse_wheel_move() -> Float

@external(javascript, "./rl.mjs", "GetMouseWheelMoveV")
pub fn get_mouse_wheel_move_v() -> Vector2

@external(javascript, "./rl.mjs", "GetMouseX")
pub fn get_mouse_x() -> Int

@external(javascript, "./rl.mjs", "GetMouseY")
pub fn get_mouse_y() -> Int

@external(javascript, "./rl.mjs", "GetRenderHeight")
pub fn get_render_height() -> Int

@external(javascript, "./rl.mjs", "GetRenderWidth")
pub fn get_render_width() -> Int

@external(javascript, "./rl.mjs", "GetScreenHeight")
pub fn get_screen_height() -> Int

@external(javascript, "./rl.mjs", "GetScreenWidth")
pub fn get_screen_width() -> Int

@external(javascript, "./rl.mjs", "GetShapesTexture")
pub fn get_shapes_texture() -> Texture

@external(javascript, "./rl.mjs", "GetShapesTextureRectangle")
pub fn get_shapes_texture_rectangle() -> Rectangle

@external(javascript, "./rl.mjs", "GetTime")
pub fn get_time() -> Float

@external(javascript, "./rl.mjs", "GetWindowPosition")
pub fn get_window_position() -> Vector2

@external(javascript, "./rl.mjs", "GetWindowScaleDPI")
pub fn get_window_scale_dpi() -> Vector2

@external(javascript, "./rl.mjs", "HideCursor")
pub fn hide_cursor() -> Nil

@external(javascript, "./rl.mjs", "InitWindow")
pub fn init_window(
  width width: Int,
  height height: Int,
  titled title: String,
) -> Nil

@external(javascript, "./rl.mjs", "CloseWindow")
pub fn close_window() -> Nil

@external(javascript, "./rl.mjs", "IsCursorHidden")
pub fn is_cursor_hidden() -> Bool

@external(javascript, "./rl.mjs", "IsCursorOnScreen")
pub fn is_cursor_on_screen() -> Bool

@external(javascript, "./rl.mjs", "IsKeyDown")
pub fn is_key_down(code code: Int) -> Bool

@external(javascript, "./rl.mjs", "IsKeyPressed")
pub fn is_key_pressed(code code: Int) -> Bool

@external(javascript, "./rl.mjs", "IsKeyPressedRepeat")
pub fn is_key_pressed_repeat(code code: Int) -> Bool

@external(javascript, "./rl.mjs", "IsKeyReleased")
pub fn is_key_released(code code: Int) -> Bool

@external(javascript, "./rl.mjs", "IsKeyUp")
pub fn is_key_up(code code: Int) -> Bool

@external(javascript, "./rl.mjs", "IsMouseButtonDown")
pub fn is_mouse_button_down(code code: Int) -> Bool

@external(javascript, "./rl.mjs", "IsMouseButtonPressed")
pub fn is_mouse_button_pressed(code code: Int) -> Bool

@external(javascript, "./rl.mjs", "IsMouseButtonReleased")
pub fn is_mouse_button_released(code code: Int) -> Bool

@external(javascript, "./rl.mjs", "IsMouseButtonUp")
pub fn is_mouse_button_up(code code: Int) -> Bool

@external(javascript, "./rl.mjs", "IsWindowFocused")
pub fn is_window_focused() -> Bool

@external(javascript, "./rl.mjs", "IsWindowFullscreen")
pub fn is_window_fullscreen() -> Bool

@external(javascript, "./rl.mjs", "IsWindowHidden")
pub fn is_window_hidden() -> Bool

@external(javascript, "./rl.mjs", "IsWindowMaximized")
pub fn is_window_maximized() -> Bool

@external(javascript, "./rl.mjs", "IsWindowMinimized")
pub fn is_window_minimized() -> Bool

@external(javascript, "./rl.mjs", "IsWindowResized")
pub fn is_window_resized() -> Bool

@external(javascript, "./rl.mjs", "MaximizeWindow")
pub fn maximize_window() -> Nil

@external(javascript, "./rl.mjs", "MinimizeWindow")
pub fn minimize_window() -> Nil

@external(javascript, "./rl.mjs", "RestoreWindow")
pub fn restore_window() -> Nil

@external(javascript, "./rl.mjs", "SetClipboardText")
pub fn set_clipboard_text(to text: String) -> Nil

@external(javascript, "./rl.mjs", "SetExitKey")
pub fn set_exit_key(code code: Int) -> Nil

@external(javascript, "./rl.mjs", "SetMousePosition")
pub fn set_mouse_position(x x: Int, y y: Int) -> Nil

@external(javascript, "./rl.mjs", "SetMouseScale")
pub fn set_mouse_scale(x x: Float, y y: Float) -> Nil

@external(javascript, "./rl.mjs", "SetShapesTexture")
pub fn set_shapes_texture(to texture: Texture, source source: Rectangle) -> Nil

@external(javascript, "./rl.mjs", "SetTargetFPS")
pub fn set_target_fps(to fps: Int) -> Nil

@external(javascript, "./rl.mjs", "SetWindowFocused")
pub fn set_window_focused() -> Nil

@external(javascript, "./rl.mjs", "SetWindowIcon")
pub fn set_window_icon(to image: Image) -> Nil

@external(javascript, "./rl.mjs", "SetWindowMaxSize")
pub fn set_window_max_size(width width: Int, height height: Int) -> Nil

@external(javascript, "./rl.mjs", "SetWindowMinSize")
pub fn set_window_min_size(width width: Int, height height: Int) -> Nil

@external(javascript, "./rl.mjs", "SetWindowMonitor")
pub fn set_window_monitor(to monitor: Int) -> Nil

@external(javascript, "./rl.mjs", "SetWindowOpacity")
pub fn set_window_opacity(to opacity: Float) -> Nil

@external(javascript, "./rl.mjs", "SetWindowPosition")
pub fn set_window_position(x x: Int, y y: Int) -> Nil

@external(javascript, "./rl.mjs", "SetWindowSize")
pub fn set_window_size(width width: Int, height height: Int) -> Nil

@external(javascript, "./rl.mjs", "SetWindowTitle")
pub fn set_window_title(to title: String) -> Nil

@external(javascript, "./rl.mjs", "ShowCursor")
pub fn show_cursor() -> Nil

@external(javascript, "./rl.mjs", "TakeScreenshot")
pub fn take_screenshot(to file: String) -> Nil

@external(javascript, "./rl.mjs", "ToggleBorderlessWindowed")
pub fn toggle_borderless_windowed() -> Nil

@external(javascript, "./rl.mjs", "ToggleFullscreen")
pub fn toggle_fullscreen() -> Nil

@external(javascript, "./rl.mjs", "Vector2")
pub fn vector2(x: Float, y: Float) -> Vector2

@external(javascript, "./rl.mjs", "WindowShouldClose")
pub fn window_should_close() -> Bool