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 coordinatey(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 coordinatey1(number) - Starting Y coordinatex2(number) - Ending X coordinatey2(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 coordinatey(number) - Top-left Y coordinatewidth(number) - Rectangle widthheight(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 coordinatey(number) - Top-left Y coordinatewidth(number) - Rectangle widthheight(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 coordinatey(number) - Center Y coordinateradius(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 coordinatey(number) - Center Y coordinateradius(number) - Circle radius
Returns: null
Example:
sdl2.set_draw_color(255, 0, 255);
sdl2.fill_circle(400, 300, 50);