whatisgithub

What is gg?

fogleman/gg — explained in plain English

Analysis updated 2026-06-26

4,772GoAudience · developerComplexity · 2/5LicenseSetup · easy

In one sentence

gg is a Go library for drawing 2D graphics and saving them as PNG files. No external dependencies needed, just write Go code to draw shapes, text, gradients, and images onto a canvas, then save the result.

Mindmap

mindmap
  root((gg))
    Drawing Shapes
      Circles and arcs
      Rectangles
      Lines and polygons
      Ellipses
    Text and Fonts
      Draw text anywhere
      Word wrapping
      Custom font files
    Colors and Fills
      RGB and hex colors
      Linear gradients
      Radial gradients
      Conic gradients
    Transformations
      Translate and rotate
      Scale and shear
      Clipping regions
    State Management
      Push and pop state
      Temporary transforms
    Output
      Save as PNG
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Generate charts or data visualizations as image files from a Go program

USE CASE 2

Create automated thumbnails or banners without any graphics software

USE CASE 3

Build illustrations or diagrams in code and export them as PNGs

USE CASE 4

Produce animated or batch-generated graphics using loops and transformations

What is it built with?

Go

How does it compare?

fogleman/ggterraform-docs/terraform-docsconsensys/quorum
Stars4,7724,7724,771
LanguageGoGoGo
Setup difficultyeasyeasymoderate
Complexity2/52/54/5
Audiencedeveloperops devopspm founder

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

Pure Go, no external graphics dependencies. Install with go get github.com/fogleman/gg and import in your file. Font loading requires a local font file path.

MIT license, free to use in personal and commercial projects, no restrictions.

So what is it?

gg is a Go library for drawing 2D graphics and saving the results as image files. It is written entirely in Go, with no external graphics dependencies, and provides a straightforward API for drawing shapes, text, and images onto a canvas. You create a drawing context by specifying a width and height in pixels. From there you can draw circles, rectangles, lines, arcs, ellipses, and polygons using simple function calls. Colors are set with RGB or hex values. Text can be drawn at any position with optional anchoring and word wrapping. You can load custom fonts by specifying a path to a font file. The library also supports more advanced features. You can apply gradients: linear, radial, and conic. Transformations let you translate, scale, rotate, and shear the canvas, and each of these can be applied around an arbitrary point rather than just the origin. Clipping regions let you restrict drawing operations to a defined area. The Push and Pop functions save and restore the drawing state, making it easy to apply temporary transformations without affecting the rest of the image. When you are done drawing, you save the result as a PNG file with a single function call. The library is useful for generating images programmatically, such as creating charts, illustrations, visualizations, or automated thumbnails. The README includes short code examples that show how to draw a filled circle and how to draw overlapping ellipses using a rotation loop. A set of additional example programs is included in the repository for reference.

Copy-paste prompts

Prompt 1
Using the gg Go library, write a program that draws a bar chart from a slice of float values and saves it as chart.png.
Prompt 2
Using gg, create a Go program that generates a thumbnail image with a background color, centered title text, and a border, then saves it as thumbnail.png.
Prompt 3
Write a Go program with gg that draws 12 overlapping circles arranged in a clock pattern, each a different color, and saves the result as circles.png.
Prompt 4
Using gg in Go, show me how to apply a linear gradient background, draw white text on top of it, and save the image.
Prompt 5
With the gg library, write a Go function that takes a list of x y points and draws a smooth line chart, then exports it as a PNG.

Frequently asked questions

What is gg?

gg is a Go library for drawing 2D graphics and saving them as PNG files. No external dependencies needed, just write Go code to draw shapes, text, gradients, and images onto a canvas, then save the result.

What language is gg written in?

Mainly Go. The stack also includes Go.

What license does gg use?

MIT license, free to use in personal and commercial projects, no restrictions.

How hard is gg to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is gg for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.