Skip to content

Instantly share code, notes, and snippets.

@AnonMiraj
Last active March 1, 2026 22:04
Show Gist options
  • Select an option

  • Save AnonMiraj/ab524953c8580ed6d34ad5545963b934 to your computer and use it in GitHub Desktop.

Select an option

Save AnonMiraj/ab524953c8580ed6d34ad5545963b934 to your computer and use it in GitHub Desktop.

Designing a graphics library in Fortran

GSoC'24 Report


  • Organization: Fortran-Lang
  • Mentors: Brad Richardson, Federico Perini
  • Contributor: Ezz el-din Ibrahim

Project Goals:

  • Design and implement a platform-agnostic graphics library for Fortran, including a graphics canvas API, basic graphics primitives, and support for multiple backend implementations.
  • Implement a basic 2D plotting framework utilizing the graphics library.

Accomplishments

  • Drawing Class: Developed a drawing class to store and manage attributes of various shapes.

  • Abstract Canvas Class: Implemented an abstract canvas class supporting multiple backends, allowing easy addition of new ones. It processes shape details from the drawing class and exports them to the desired file format. Currently, the library supports SVG and BITMAP (PNG and PPM) formats.

    • Integrated libcairo as the primary backend.
  • Shape Implementations: Added support for a variety of shapes, including:

    • Basic shapes: rectangles, triangles, circles, ellipses, arcs.
    • Text and font handling with multiple attributes.
    • Path shapes with functions such as move_to, cubic_curve, quad_curve_to, line_to, and arc_to.
      • Support for direct SVG command strings.
    • Polyline and polygon shapes.
      • Support for direct SVG command strings.
    • All shapes support filling, stroking, and dashing.
  • 2D Plotting Framework: Established the foundation of a 2D plotting framework utilizing the graphics library.

Future Work:

  • Plotting Framework: I plan to continue working on the 2D plotting framework, with a focus on implementing legends, additional plot types, and further customization options.
  • The main library still needs some features.
    • Gradient support.
    • I plan on adding another backend and making Cairo an optional dependency.
    • Supporting animated gif and opengl as a backend.

Challenges

  • There were a lot of changes in plans at the start of GSoC I had to research a lot more than expected during the coding phase.
    • a lot of parts of vector graphics are really hard to research and obscure.
  • I faced a compiler bug while working on gradients which caused me to delay working on it until after my GSoC period.
  • My final exams conflicted with the first two weeks of my coding periods.

My Learnings

  • Vector Graphics: I learned a lot a about how vector graphcis works in a low level Before I only had a surface understanding.

  • Git: I developed a strong workflow using Git, significantly improving from my basic prior experience. This has proven useful in other projects during GSoC.

  • CI: I also got the opportunity to more about CI (Continuous Integration) during my project, particularly GitHub Actions, and can now confidently use them for testing and automation in my projects.

  • OOP in Fortran: The project deepened my understanding of Object-Oriented Programming (OOP) in Fortran, and I now feel more comfortable applying these paradigms in future work.

  • Fortran: I learned a lot about Fortran and now I can understand why Fortran is the most prominent language in scientific Computing.

Acknowledgement

I would like to thank Brad Richardson, Federico Perini, and Johann Andreas for helping me and guiding me through this project, and thank the Fortran community for this opportunity i certainly learned a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment