GSoC 2024: Graphics Library

Hello all,

I’m excited to share that I’ve been accepted as a GSoC contributor this year! I will be working on developing a graphics library in Fortran under the mentorship of @FedericoPerini and @everythingfunctional.

I will use this thread to keep you informed about my weekly progress.

Revised Plan

After some discussions with my mentors, we’ve made a few adjustments to my initial proposal. Here’s the updated plan:

  • Postpone support for OpenGL for now.

First Half of GSoC Period:

  • Focus solely on developing the core graphics library.
  • Ensure support for vector graphics, primarily SVG.

Second Half of GSoC Period:

  • Start developing a plotting framework utilizing FIG.

Current Progress

  • Library Primitives: I have already laid the groundwork for most of the primitives.
  • Refactoring: Currently, I am refactoring the library to support multiple backends more effectively.
  • Upcoming Tasks:
    • Implement drawing text and supporting TrueType fonts.
    • Add support for other raster file formats like PNG.

I hope you find this project interesting. If you have any notes or feedback, please let me know.

Best regards,
Ezz

22 Likes

Week #1 Progress

Hello,

My finals have started this week, so my free time has been limited.

However, I have done the following:

  • Improved how the shapes classes are handled across the different back ends.
  • Implemented the drawing class that is responsible for handling all the shapes and communicating with the back ends.

Now that the back end and the current design of the library are stable, I can proceed with implementing more primitives and adding more functionality.

4 Likes

This week, I plan to move all the primitives to the new design, including:

  • Lines
  • Ellipses
  • Triangles
  • Polygons
  • Polylines

All of these should support attributes such as stroke size, stroke color, fill color, and similar properties. Additionally, I plan to properly handle the alpha channel.

7 Likes

Congrats and thanks to you and mentors for working on this. Is there a GitHub repo we can follow the progress in and play with it as it matures?

2 Likes
4 Likes

Also, we’re meeting weekly on Thursdays at 10 am US Central Time. If anyone else would like to join the meetings just let me know and I’ll get you an invite.

1 Like

Week #2 Progress

Hello,

I have accomplished the following:

  • Implemented primitives for lines, triangles, and ellipses.
  • The alpha channel is now functioning correctly for the bitmap canvas.

I struggled a bit with implementing thick lines, so I will postpone handling stroke size and polygons for now. Here are some images generated by the library:

You can find the code for all of them in the repo (fig/test at main · AnonMiraj/fig · GitHub).

11 Likes

This week, I plan to address some issues and make general design improvements to the library:

3 Likes

Week #3 Progress

Hello,

I have accomplished the following:

  • Updated the drawing class to use relative coordinates in the [0.0, 1.0] range.
  • Various small fixes and improvements.

I finally finished my finals, so now I can commit more time to the project.

9 Likes

This week, I plan to continue working on the primitive and set up some CI and GitHub Actions in the repository for testing.

3 Likes

Week4 # Progress

Hello,

I have finished the CI pipeline and improved the testing system.

I have also done some work to allow thick lines, but I realized that due to poor planning (mainly the addition of vectors graphics), I can’t continue with the current design. I will need to change how primitives are currently being drawn, so that will be next week’s plan.

7 Likes

Week #5 Progress

Hello,

I have mostly spent the week researching and studying how vector graphics are internally rendered, and I was really surprised by the lack of actual resources and books on the subject. So, pretty much my only option was to understand how some libraries like Cairo work internally.

After that, I believe implementing it fully from scratch would be really complicated and time-consuming for now. So, my plan for now is to make bindings for a library to serve as the base of the bitmap backend.

I still want to do it from scratch eventually, but I’m going to leave this for a future project.

5 Likes

I like this idea @ezz: prioritizing productivity is very important.

@vmagnin’s Fortran bindings for Cairo would be a great starting point:

2 Likes

The Cairo code (C language) seems to be hosted here: cairo - cairo's central repository (mirrored from https://gitlab.freedesktop.org/cairo/cairo)

Maybe you could find interesting information in their bibliography page: Cairo bibliography

2 Likes

I’ve already decided to use plutovg as a base since Cairo seems like overkill, considering it already supports a lot of drivers for other output devices.

Thank you for sharing; it’s going to be really useful.

1 Like

Week #6 Progress

I faced problems with Plutovg, so I used Cairo instead.

The library can now draw shapes with anti-aliasing, strokes are drawn correctly, and you can output to png .

I encountered some issues with gradients, so I will be working on them. I will also implement drawing text and more properties of strokes.

8 Likes

For those interested, @ezz is making very good progress, essentially completed switching from a full-Fortran implementation to using Cairo as a backend.

Currently he’s hitting a compiler bug with finalization of the polymorphic entities, so we’ll be trying to understand wheteher it’s best to change something in the object-oriented pattern until the issue goes away, or just use an older version of the compiler for now.

6 Likes

Week #7 Progress

Hello,

I have accomplished the following:

  • You can now draw text, paths, polygons, polylines, and arcs.
  • It is also possible to directly use an SVG path to set the path, same with polygons and polylines.
    my_path%path_string = "M 0.03 0.03L 0.12 0.05C 0.08 0.10 0.15 0.12 0.20 0.08Z"
    

poly_example
text_examplepath_example

6 Likes