Giter Club home page Giter Club logo

tomasszu / agra Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 135 KB

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.

Makefile 4.50% C 12.56% Assembly 82.93%
assembler assembly c c-language framebuffer graphics-library graphics2d makefile makefile-generation

agra's Introduction

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.

agra's People

Contributors

tomasszu avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.