XDPXI's Documentation
SDL2

Drawing Primitives

Required version: Sponge >=1.0.4

sdl2.draw_point(x, y)

Draws a single pixel at the specified coordinates.

Parameters:

  • x (number) - X coordinate
  • y (number) - Y coordinate

Returns: null

Example:

sdl2.set_draw_color(255, 255, 255);
sdl2.draw_point(100, 100);

sdl2.draw_line(x1, y1, x2, y2)

Draws a line from point (x1, y1) to point (x2, y2).

Parameters:

  • x1 (number) - Starting X coordinate
  • y1 (number) - Starting Y coordinate
  • x2 (number) - Ending X coordinate
  • y2 (number) - Ending Y coordinate

Returns: null

Example:

sdl2.set_draw_color(255, 0, 0);
sdl2.draw_line(0, 0, 800, 600);

sdl2.draw_rect(x, y, width, height)

Draws a rectangle outline at the specified position and size.

Parameters:

  • x (number) - Top-left X coordinate
  • y (number) - Top-left Y coordinate
  • width (number) - Rectangle width
  • height (number) - Rectangle height

Returns: null

Example:

sdl2.set_draw_color(0, 255, 0);
sdl2.draw_rect(100, 100, 200, 150);

sdl2.fill_rect(x, y, width, height)

Draws a filled rectangle at the specified position and size.

Parameters:

  • x (number) - Top-left X coordinate
  • y (number) - Top-left Y coordinate
  • width (number) - Rectangle width
  • height (number) - Rectangle height

Returns: null

Example:

sdl2.set_draw_color(0, 0, 255);
sdl2.fill_rect(100, 100, 200, 150);

sdl2.draw_circle(x, y, radius)

Draws a circle outline centered at (x, y) with the specified radius.

Parameters:

  • x (number) - Center X coordinate
  • y (number) - Center Y coordinate
  • radius (number) - Circle radius

Returns: null

Example:

sdl2.set_draw_color(255, 255, 0);
sdl2.draw_circle(400, 300, 50);

sdl2.fill_circle(x, y, radius)

Draws a filled circle centered at (x, y) with the specified radius.

Parameters:

  • x (number) - Center X coordinate
  • y (number) - Center Y coordinate
  • radius (number) - Circle radius

Returns: null

Example:

sdl2.set_draw_color(255, 0, 255);
sdl2.fill_circle(400, 300, 50);