Skip to content

AnonMiraj/fig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FIG

FIG is a Fortran library designed to offer intuitive vector graphics capabilities. It supports a variety of shapes, paths, and text, with output options including PNG, PPM, and SVG.

Features

  • Shape Drawing: Easily draw paths, shapes, and curves.
  • Styling: Apply stroking, dashing, and other styles to shapes.
  • Text Support: Render fonts and text with customizable attributes.
  • Export Options: Save your graphics in PNG, PPM, or SVG formats.

Requirements

  • A modern Fortran compiler (such as gfortran).
  • libcairo and its dependencies for rendering. Install libcairo.

Example program

Here’s a simple example to get you started:

program test_fig
   use fig
   implicit none
   type(drawing) :: canva
   type(circle) :: circ

   call canva%init()
   canva%background = FIG_COLOR_BLACK

   circ%c%x = 0.5
   circ%c%y = 0.5

   circ%r = 25
   circ%stroke_color = FIG_COLOR_TAN
   circ%fill_color = FIG_COLOR_RED
   circ%stroke_width = 3
   call canva%add_shape(circ)

   circ%r = 15
   circ%stroke_color = FIG_COLOR_CYAN
   circ%fill_color = FIG_COLOR_GRAY
   circ%stroke_width = 2
   call canva%add_shape(circ)

   ! Export the drawing to PNG and SVG formats
   call draw_to_png(canva, 100, 100, "png_test")
   call draw_to_svg(canva, 200, 300, "svg_test")

end program test_fig

result :

Note: FIG uses relative coordinates by default. To use absolute coordinates, set FIG_ABSOLUTE_COORDINATES = .true..

For a comprehensive list of shapes and their attributes, refer to the Shapes source file and Path source file.

Gallery

Below are some examples of images created using FIG.

Test All

More Examples

Radial Lines

Circles Pattern

Fortran Logo

Checker Pattern

Triangles

Cool Triangle Pattern

fpm

To use fig within your own fpm project, add the following dependency to your project fpm.toml file:

[dependencies]
fig= {git = "https://github.com/AnonMiraj/fig" }

To-Do List

  • Add support for additional backends, making cairo optional.
  • Implement gradient support.
  • Add PNG file reading capability.
  • Implement transformations (rotations, scaling, etc.).

Releases

No releases published

Packages

No packages published