{"id":13526955,"url":"https://github.com/llgcode/draw2d","last_synced_at":"2025-05-15T02:08:55.783Z","repository":{"id":28623019,"uuid":"32141743","full_name":"llgcode/draw2d","owner":"llgcode","description":"2D rendering for different output (raster, pdf, svg)","archived":false,"fork":false,"pushed_at":"2024-06-27T06:29:29.000Z","size":10147,"stargazers_count":1113,"open_issues_count":39,"forks_count":105,"subscribers_count":32,"default_branch":"master","last_synced_at":"2025-04-11T14:17:06.939Z","etag":null,"topics":["2d","draw2d","freetype","go","graphics","postscript"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/llgcode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-03-13T08:07:25.000Z","updated_at":"2025-04-03T02:49:16.000Z","dependencies_parsed_at":"2022-07-26T07:17:04.068Z","dependency_job_id":"2c74079b-c2e3-48ef-9861-2d89cf8e6ec8","html_url":"https://github.com/llgcode/draw2d","commit_stats":{"total_commits":438,"total_committers":33,"mean_commits":"13.272727272727273","dds":0.6004566210045662,"last_synced_commit":"ee6987bd01dcb3b218814bd717b8f8cba56153d3"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/llgcode%2Fdraw2d","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/llgcode%2Fdraw2d/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/llgcode%2Fdraw2d/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/llgcode%2Fdraw2d/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/llgcode","download_url":"https://codeload.github.com/llgcode/draw2d/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254259384,"owners_count":22040820,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["2d","draw2d","freetype","go","graphics","postscript"],"created_at":"2024-08-01T06:01:38.296Z","updated_at":"2025-05-15T02:08:55.493Z","avatar_url":"https://github.com/llgcode.png","language":"Go","readme":"draw2d\n======\n[![Coverage](http://gocover.io/_badge/github.com/llgcode/draw2d?0)](http://gocover.io/github.com/llgcode/draw2d)\n[![GoDoc](https://godoc.org/github.com/llgcode/draw2d?status.svg)](https://godoc.org/github.com/llgcode/draw2d)\n[![BuyMeaBeer](https://img.shields.io/badge/buy_me-a_beer-orange)](https://www.buymeacoffee.com/llgcoffee)\n\nPackage draw2d is a [go](http://golang.org) 2D vector graphics library with support for multiple outputs such as [images](http://golang.org/pkg/image) (draw2d), pdf documents (draw2dpdf), opengl (draw2dgl) and svg (draw2dsvg). \nThere's also a [Postscript reader](https://github.com/llgcode/ps) that uses draw2d.\ndraw2d is released under the BSD license. \nSee the [documentation](http://godoc.org/github.com/llgcode/draw2d) for more details.\n\n[![geometry](https://raw.githubusercontent.com/llgcode/draw2d/master/output/samples/geometry.png)](https://raw.githubusercontent.com/llgcode/draw2d/master/resource/image/geometry.pdf)[![postscript](https://raw.githubusercontent.com/llgcode/draw2d/master/output/samples/postscript.png)](https://raw.githubusercontent.com/llgcode/draw2d/master/resource/image/postscript.pdf)\n\nClick on an image above to get the pdf, generated with exactly the same draw2d code. The first image is the output of `samples/geometry`. The second image is the result of `samples/postcript`, which demonstrates that draw2d can draw postscript files into images or pdf documents with the [ps](https://github.com/llgcode/ps) package.\n\nFeatures\n--------\n\nOperations in draw2d include stroking and filling polygons, arcs, Bézier curves, drawing images and text rendering with truetype fonts. All drawing operations can be transformed by affine transformations (scale, rotation, translation).\n\nPackage draw2d follows the conventions of the [HTML Canvas 2D Context](http://www.w3.org/TR/2dcontext/) for coordinate system, angles, etc...\n\nInstallation\n------------\n\nInstall [golang](http://golang.org/doc/install). To install or update the package draw2d on your system, run:\n\nStable release\n```\ngo get -u gopkg.in/llgcode/draw2d.v1\n```\n\nor Current release\n```\ngo get -u github.com/llgcode/draw2d\n```\n\n\nQuick Start\n-----------\n\nThe following Go code generates a simple drawing and saves it to an image file with package draw2d:\n\n```go\npackage main\n\nimport (\n\t\"github.com/llgcode/draw2d/draw2dimg\"\n\t\"image\"\n\t\"image/color\"\n)\n\nfunc main() {\n\t// Initialize the graphic context on an RGBA image\n\tdest := image.NewRGBA(image.Rect(0, 0, 297, 210.0))\n\tgc := draw2dimg.NewGraphicContext(dest)\n\n\t// Set some properties\n\tgc.SetFillColor(color.RGBA{0x44, 0xff, 0x44, 0xff})\n\tgc.SetStrokeColor(color.RGBA{0x44, 0x44, 0x44, 0xff})\n\tgc.SetLineWidth(5)\n\n\t// Draw a closed shape\n\tgc.BeginPath() // Initialize a new path\n\tgc.MoveTo(10, 10) // Move to a position to start the new path\n\tgc.LineTo(100, 50)\n\tgc.QuadCurveTo(100, 10, 10, 10)\n\tgc.Close()\n\tgc.FillStroke()\n\n\t// Save to file\n\tdraw2dimg.SaveToPngFile(\"hello.png\", dest)\n}\n```\n\nThe same Go code can also generate a pdf document with package draw2dpdf:\n\n```go\npackage main\n\nimport (\n\t\"github.com/llgcode/draw2d/draw2dpdf\"\n\t\"image/color\"\n)\n\nfunc main() {\n\t// Initialize the graphic context on an RGBA image\n\tdest := draw2dpdf.NewPdf(\"L\", \"mm\", \"A4\")\n\tgc := draw2dpdf.NewGraphicContext(dest)\n\n\t// Set some properties\n\tgc.SetFillColor(color.RGBA{0x44, 0xff, 0x44, 0xff})\n\tgc.SetStrokeColor(color.RGBA{0x44, 0x44, 0x44, 0xff})\n\tgc.SetLineWidth(5)\n\n\t// Draw a closed shape\n\tgc.MoveTo(10, 10) // should always be called first for a new path\n\tgc.LineTo(100, 50)\n\tgc.QuadCurveTo(100, 10, 10, 10)\n\tgc.Close()\n\tgc.FillStroke()\n\n\t// Save to file\n\tdraw2dpdf.SaveToPdfFile(\"hello.pdf\", dest)\n}\n```\n\nThere are more examples here: https://github.com/llgcode/draw2d/tree/master/samples\n\nDrawing on opengl is provided by the draw2dgl package.\n\nTesting\n-------\n\nThe samples are run as tests from the root package folder `draw2d` by:\n```\ngo test ./...\n```\nOr if you want to run with test coverage:\n```\ngo test -cover ./... | grep -v \"no test\"\n```\nThis will generate output by the different backends in the output folder.\n\nAcknowledgments\n---------------\n\n[Laurent Le Goff](https://github.com/llgcode) wrote this library, inspired by [Postscript](http://www.tailrecursive.org/postscript) and [HTML5 canvas](http://www.w3.org/TR/2dcontext/). He implemented the image and opengl backend with the [freetype-go](https://code.google.com/p/freetype-go/) package. Also he created a pure go [Postscript interpreter](https://github.com/llgcode/ps), which can read postscript images and draw to a draw2d graphic context. [Stani Michiels](https://github.com/stanim) implemented the pdf backend with the [gofpdf](https://github.com/jung-kurt/gofpdf) package.\n\n\n\nPackages using draw2d\n---------------------\n\n - [ps](https://github.com/llgcode/ps): Postscript interpreter written in Go\n - [go.uik](https://github.com/skelterjohn/go.uik): a concurrent UI kit written in pure go.\n - [smartcrop](https://github.com/muesli/smartcrop): content aware image cropping\n - [karta](https://github.com/peterhellberg/karta): drawing Voronoi diagrams\n - [chart](https://github.com/vdobler/chart): basic charts in Go\n - [hilbert](https://github.com/google/hilbert): package for drawing Hilbert curves\n\nReferences\n---------\n\n - [antigrain.com](http://www.antigrain.com)\n - [freetype-go](http://code.google.com/p/freetype-go)\n -\n","funding_links":["https://www.buymeacoffee.com/llgcoffee"],"categories":["Go","Repositories","Geospatial Library","Programming Languages"],"sub_categories":["Go"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fllgcode%2Fdraw2d","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fllgcode%2Fdraw2d","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fllgcode%2Fdraw2d/lists"}