Skip to content

This is a graphics library capable of "drawing" figures such as point, line, circle and triangle on a 2D plane. These figures are written to a buffer (ideally implemented as a 2D matrix), which are later printed on the screen or other output.

tomasszu/agra

Repository files navigation

Description of the graphics library "agra"

Course project supervised by Dr. sc. comp Leo Seļāvo at the University of Latvia.

(Latviski apraksts pieejams repozitorijā esošajā failā apraksts.pdf)


This is a graphics library capable of "drawing" figures such as point, line, circle and triangle on a 2D plane. These figures are written to a buffer (ideally implemented as a 2D matrix), which are later printed on the screen or other output.

Functionality implemented in the library (written in C and Assembly):

  1. Color installation. The color is set using a defined struct and sent to the assembler file, where the color is used to fill in the pixels in the buffer until replaced.
  2. Pixel drawing. Gets its x and y coordinates and places it in the buffer. Takes into account the color and draw operation. Drawing operations are able to modify the output of the buffer using the logical operations mentioned in the requirements. In my implementation, this function also checks if it is not drawn for the first time, because the buffer must be cleared before the first drawing (for which a separate function is created).
  3. Drawing a line. Gets the coordinates of the start and end points. The line itself is drawn using an advanced Bresenham line drawing algorithm. For this most widely available algorithm I had to look for improvements, because at a certain slope of the line (greater slope of y than slope of x) an incorrect line was drawn that did not go to the end point.
  4. Drawing a circle. Also used is Bresenham's "Midpoint circle algorithm", which physically marks the circle using a sub-function that after each calculation marks 8 pixels of the surrounding configuration. The function receives the center point (x,y) and radius of the circle.
  5. Filling a triangle. This, the longest algorithm, fills the contours of the triangle by drawing horizontal lines in several steps (configurations) until the entire area is filled. A sub-function SWAP is often used, which swaps two variables (eg x1 and x2) for places. The coordinates of the three vertices are received as parameters.
  6. Returning the address of the buffer so that it can be accessed in the assembler. Returning the width and length of the buffer to be able to control the walking around the buffer and printing a Frame that prints the buffer to the screen.

About

This is a graphics library capable of "drawing" figures such as point, line, circle and triangle on a 2D plane. These figures are written to a buffer (ideally implemented as a 2D matrix), which are later printed on the screen or other output.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published