Easy_Graphics is a simple library for generating graphical output from your Ada program.
Typical use cases might be educational projects, prototyping, programming challenges, or simply when you want to visualise something quickly in a larger system.
The logo on the right is created with just a few lines of code, see this program
The package is free to use, with no warranty, under the MIT license.
- Image output as portable PPM, PAM, and GIF files (other formats to follow)
- Images of any size using whatever (integer) coordinate ranges you like
- Simple set of graphics primitives provided
- Basic turtle graphics are supported
- Images are 24-bit colour + 8-bit alpha
- Basic (HTML/CSS) colours predefined as constants, as is TRANSPARENT
New_Imagecreate a new image ("canvas"), prefilled with a colour or transparentWrite_PPMcreate "raw" or "plain" NetPBM PPM file from image, Alpha is ignoredWrite_GIFcreate GIF file - only partially implemented at the momentWrite_PAMcreate NetPBM PAM file from image, includes transparency. N.B. Convert to PNG withconvert img.pam img.pngor view directly withpqivHSV_To_RGBconvert colour values
Plota point on the imageSet_Alphachanges the transparency of a pointFillan entire image with a colourLinedraw a line between twoPointsRect(filled or outline)Triangle(filled or outline)Circle(filled or outline)Chardraw a character using a simple built-in fontTextdraw a string
New_Turtlecreates a virtual turtle for an imageHomecentres the turtleGo_Toa specific coordinatePen_Up,Pen_DownandPen_ColorForward,BackLeftandRightturn relative to the current headingTurn_Toturns to an absolute heading
There are several example programs using Easy_Graphics in the tests/src directory.
The tests.adb file is intended to demonstrate all features
that are currently implemented.
