π©βπ¦° Aldrin Documentation
Table of Contents
Main data type of Aldrin that contains pixels, width and height properties of canvas.
Example:
#define WIDTH 200
#define HEIGHT 200
static uint32_t pixels [WIDTH * HEIGHT ];
Aldrin_Canvas ac = { pixels , WIDTH , HEIGHT };
Puts a pixel on the canvas.
Syntax: aldrin_put_pixel(ac, x, y, color)
Parameters:
ac: Aldrin_Canvas
x: uint32_t: x coordinate of pixel
y: uint32_t: y coordinate of pixel
color: uint32_t: color code of pixel
Example:
aldrin_put_pixel (ac , 100 , 100 , 0x00ff00 );
Fills canvas with color.
Syntax: aldrin_fill(ac, fill_color)
Parameters:
ac: Aldrin_Canvas
fill_color: uint32_t: color code of fill
Example:
aldrin_fill (ac , 0x00ff00 );
Draws a line on the canvas.
Syntax: aldrin_draw_line(ac, x1, y1, x2, y2, line_color, thickness)
Parameters:
ac: Aldrin_Canvas
x1: uint32_t: x coordinate of first point
y1: uint32_t: y coordinate of first point
x2: uint32_t: x coordinate of second point
y2: uint32_t: y coordinate of second point
line_color: uint32_t: color code of line
thickness: "uint32_t`: thickness of line
Example:
aldrin_draw_line (ac , 0 , 0 , 200 , 200 , 0xff0000 , 5 );
Draws a triangle on the canvas.
Syntax: aldrin_draw_triangle(ac, x1, y1, x2, y2, x3, y3, line_color, thickness)
Parameters:
ac: Aldrin_Canvas
x1: uint32_t: x coordinate of first point
y1: uint32_t: y coordinate of first point
x2: uint32_t: x coordinate of second point
y2: uint32_t: y coordinate of second point
x3: uint32_t: x coordinate of third point
y3: uint32_t: y coordinate of third point
line_color: uint32_t: color code of line
thickness: "uint32_t`: thickness of line
Example:
aldrin_draw_triangle (ac , 5 , 10 , 5 , 100 , 120 , 10 , 0xff0000 , 1 );
Draws and fills a triangle on the canvas.
Syntax: aldrin_fill_triangle(ac, x1, y1, x2, y2, x3, y3, fill_color)
Parameters:
ac: Aldrin_Canvas
x1: uint32_t: x coordinate of first point
y1: uint32_t: y coordinate of first point
x2: uint32_t: x coordinate of second point
y2: uint32_t: y coordinate of second point
x3: uint32_t: x coordinate of third point
y3: uint32_t: y coordinate of third point
fill_color: uint32_t: color code of fill
Example:
aldrin_fill_triangle (ac , 5 , 10 , 5 , 100 , 120 , 10 , 0xff0000 );
Draws a ellipse on the canvas.
Syntax: aldrin_draw_ellipse(ac, x, y, rx, ry, line_color)
Parameters:
ac: Aldrin_Canvas
x: uint32_t: x coordinate of top-left corner of ellipse
y: uint32_t: y coordinate of top-left corner of ellipse
rx: uint32_t: x radius of ellipse
ry: uint32_t: y radius of ellipse
line_color: uint32_t: color code of line
Example:
aldrin_draw_ellipse (ac , 0 , 0 , 90 , 50 , 0xff0000 );
Draws and fills a ellipse on the canvas.
Syntax: aldrin_fill_ellipse(ac, x, y, rx, ry, fill_color)
Parameters:
ac: Aldrin_Canvas
x: uint32_t: x coordinate of top-left corner of ellipse
y: uint32_t: y coordinate of top-left corner of ellipse
rx: uint32_t: x radius of ellipse
ry: uint32_t: y radius of ellipse
fill_color: uint32_t: color code of fill
Example:
aldrin_fill_ellipse (ac , 0 , 0 , 90 , 50 , 0xff0000 );
Draws a circle on the canvas.
Syntax: aldrin_draw_circle(ac, x, y, r, line_color)
Parameters:
ac: Aldrin_Canvas
x: uint32_t: x coordinate of top-left corner of circle
y: uint32_t: y coordinate of top-left corner of circle
r: uint32_t: radius of circle
line_color: uint32_t: color code of line
Example:
aldrin_draw_circle (ac , 0 , 0 , 50 , 0xff0000 );
Draws and fills a circle on the canvas.
Syntax: aldrin_fill_circle(ac, x, y, r, fill_color)
Parameters:
ac: Aldrin_Canvas
x: uint32_t: x coordinate of top-left corner of circle
y: uint32_t: y coordinate of top-left corner of circle
r: uint32_t: radius of circle
fill_color: uint32_t: color code of fill
Example:
aldrin_fill_circle (ac , 0 , 0 , 50 , 0xff0000 );
Draws a rectangle on the canvas.
Syntax: aldrin_draw_rectangle(ac, x, y, w, h, line_color, thickness)
Parameters:
ac: Aldrin_Canvas
x: uint32_t: x coordinate of top-left corner of rectangle
y: uint32_t: y coordinate of top-left corner of rectangle
w: uint32_t: width of rectangle
h: uint32_t: height of rectangle
line_color: uint32_t: color code of line
thickness: "uint32_t`: thickness of line
Example:
aldrin_draw_rectangle (ac , 0 , 0 , 50 , 100 , 0xff0000 , 1 );
Draws and fills a rectangle on the canvas.
Syntax: aldrin_fill_rectangle(ac, x, y, w, h, line_color, thickness)
Parameters:
ac: Aldrin_Canvas
x: uint32_t: x coordinate of top-left corner of rectangle
y: uint32_t: y coordinate of top-left corner of rectangle
w: uint32_t: width of rectangle
h: uint32_t: height of rectangle
fill_color: uint32_t: color code of fill
Example:
aldrin_fill_rectangle (ac , 0 , 0 , 50 , 100 , 0xff0000 );
Draws a square on the canvas.
Syntax: aldrin_draw_square(ac, x, y, l, line_color, thickness)
Parameters:
ac: Aldrin_Canvas
x: uint32_t: x coordinate of top-left corner of rectangle
y: uint32_t: y coordinate of top-left corner of rectangle
l: uint32_t: lenght (width and height) of rectangle
line_color: uint32_t: color code of line
thickness: uint32_t: thickness of line
Example:
aldrin_draw_square (ac , 0 , 0 , 100 , 0xff0000 , 1 );
Draws and fills a square on the canvas.
Syntax: aldrin_fill_square(ac, x, y, l, fill_color)
Parameters:
ac: Aldrin_Canvas
x: uint32_t: x coordinate of top-left corner of rectangle
y: uint32_t: y coordinate of top-left corner of rectangle
l: uint32_t: lenght (width and height) of rectangle
fill_color: uint32_t: color code of fill
Example:
aldrin_fill_square (ac , 0 , 0 , 100 , 0xff0000 );
Writes text on the canvas.
Syntax: aldrin_text(ac, x, y, text, text_color, text_size)
Parameters:
ac: Aldrin_Canvas
x: uint32_t: x coordinate of top-left corner of text
y: uint32_t: y coordinate of top-left corner of text
text: char[]: text to write
text_color: uint32_t: color code of text
text_size: uint32_t: size of text
Example:
aldrin_text (ac , 0 , 0 , "Lorem ipsum dolor! 012." , 0xffffff , 2 );
Returns the pixels of the Aldrin_Canvas.
Syntax: aldrin_get_pixels(ac)
Parameters:
Note: This function makes sense with WASM.
Example:
Returns the width of the Aldrin_Canvas.
Syntax: aldrin_get_width(ac)
Parameters:
Note: This function makes sense with WASM.
Example:
Returns the height of the Aldrin_Canvas.
Syntax: aldrin_get_height(ac)
Parameters:
Note: This function makes sense with WASM.
Example:
Saves the Aldrin_Canvas as a ppm file.
Syntax: aldrin_save_ppm(ac, filename)
Parameters:
ac: Aldrin_Canvas
filename: char[]: filename of the ppm file
β Note: This function is not available with WASM.
Example:
aldrin_save_ppm (ac , "output.ppm" );