All Projects → llgcode → Draw2d

llgcode / Draw2d

Licence: bsd-2-clause
2D rendering for different output (raster, pdf, svg)

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Draw2d

Citro2d
Library for drawing 2D graphics using the Nintendo 3DS's PICA200 GPU
Stars: ✭ 88 (-88.99%)
Mutual labels:  graphics, 2d
Wechart
Create all the [ch]arts by cax or three.js - Cax 和 three.js 创造一切图[表]
Stars: ✭ 152 (-80.98%)
Mutual labels:  graphics, 2d
Svg.skia
An SVG rendering library.
Stars: ✭ 122 (-84.73%)
Mutual labels:  graphics, 2d
Sketch
A Common Lisp framework for the creation of electronic art, visual design, game prototyping, game making, computer graphics, exploration of human-computer interaction, and more.
Stars: ✭ 1,026 (+28.41%)
Mutual labels:  graphics, 2d
Pixieditor
PixiEditor is a lightweight pixel art editor made with .NET 5
Stars: ✭ 210 (-73.72%)
Mutual labels:  graphics, 2d
Spatialmath Python
Create, manipulate and convert representations of position and orientation in 2D or 3D using Python
Stars: ✭ 78 (-90.24%)
Mutual labels:  graphics, 2d
Plutovg
Tiny 2D vector graphics library in C
Stars: ✭ 141 (-82.35%)
Mutual labels:  graphics, 2d
Sophus
C++ implementation of Lie Groups using Eigen.
Stars: ✭ 1,048 (+31.16%)
Mutual labels:  graphics, 2d
Picasso
Picasso is a high quality 2D vector graphic rendering library. It support path , matrix , gradient , pattern , image and truetype font.
Stars: ✭ 205 (-74.34%)
Mutual labels:  graphics, 2d
Rgx
Modern mid-level 2D graphics library
Stars: ✭ 172 (-78.47%)
Mutual labels:  graphics, 2d
Gcanvas
A lightweight cross-platform graphics rendering engine. (超轻量的跨平台图形引擎) https://alibaba.github.io/GCanvas
Stars: ✭ 1,705 (+113.39%)
Mutual labels:  graphics, 2d
Gg
Go Graphics - 2D rendering in Go with a simple API.
Stars: ✭ 3,162 (+295.74%)
Mutual labels:  graphics, 2d
Skija
Java bindings for Skia
Stars: ✭ 2,292 (+186.86%)
Mutual labels:  graphics, 2d
Graphics32
Graphics32 is a graphics library for Delphi and Lazarus. Optimized for 32-bit pixel formats, it provides fast operations with pixels and graphic primitives. In most cases Graphics32 considerably outperforms the standard TBitmap/TCanvas methods.
Stars: ✭ 238 (-70.21%)
Mutual labels:  graphics, 2d
Mathc
Pure C math library for 2D and 3D programming
Stars: ✭ 504 (-36.92%)
Mutual labels:  graphics, 2d
Bounty
Javascript and SVG odometer effect library with motion blur
Stars: ✭ 724 (-9.39%)
Mutual labels:  graphics
Futile
A super simple Unity 2D framework
Stars: ✭ 770 (-3.63%)
Mutual labels:  2d
Radialprogressbar
Customizable radial progress bar shader for Unity3D. Allows you to set arc range, minimum and maximum colors, textures, radius, and a few more things. Create HP Bars, Speedometers, rank progress, etc!
Stars: ✭ 714 (-10.64%)
Mutual labels:  graphics
Kinobloom
Bloom effect for Unity
Stars: ✭ 704 (-11.89%)
Mutual labels:  graphics
Opengraphic
Graphic Engine & Game Engine lists
Stars: ✭ 772 (-3.38%)
Mutual labels:  graphics

draw2d

Coverage GoDoc BuyMeaBeer

Package draw2d is a go 2D vector graphics library with support for multiple outputs such as images (draw2d), pdf documents (draw2dpdf), opengl (draw2dgl) and svg (draw2dsvg). There's also a Postscript reader that uses draw2d. draw2d is released under the BSD license. See the documentation for more details.

geometrypostscript

Click 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 package.

Features

Operations 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).

Package draw2d follows the conventions of the HTML Canvas 2D Context for coordinate system, angles, etc...

Installation

Install golang. To install or update the package draw2d on your system, run:

Stable release

go get -u gopkg.in/llgcode/draw2d.v1

or Current release

go get -u github.com/llgcode/draw2d

Quick Start

The following Go code generates a simple drawing and saves it to an image file with package draw2d:

package main

import (
	"github.com/llgcode/draw2d/draw2dimg"
	"image"
	"image/color"
)

func main() {
	// Initialize the graphic context on an RGBA image
	dest := image.NewRGBA(image.Rect(0, 0, 297, 210.0))
	gc := draw2dimg.NewGraphicContext(dest)

	// Set some properties
	gc.SetFillColor(color.RGBA{0x44, 0xff, 0x44, 0xff})
	gc.SetStrokeColor(color.RGBA{0x44, 0x44, 0x44, 0xff})
	gc.SetLineWidth(5)

	// Draw a closed shape
	gc.BeginPath() // Initialize a new path
	gc.MoveTo(10, 10) // Move to a position to start the new path
	gc.LineTo(100, 50)
	gc.QuadCurveTo(100, 10, 10, 10)
	gc.Close()
	gc.FillStroke()

	// Save to file
	draw2dimg.SaveToPngFile("hello.png", dest)
}

The same Go code can also generate a pdf document with package draw2dpdf:

package main

import (
	"github.com/llgcode/draw2d/draw2dpdf"
	"image/color"
)

func main() {
	// Initialize the graphic context on an RGBA image
	dest := draw2dpdf.NewPdf("L", "mm", "A4")
	gc := draw2dpdf.NewGraphicContext(dest)

	// Set some properties
	gc.SetFillColor(color.RGBA{0x44, 0xff, 0x44, 0xff})
	gc.SetStrokeColor(color.RGBA{0x44, 0x44, 0x44, 0xff})
	gc.SetLineWidth(5)

	// Draw a closed shape
	gc.MoveTo(10, 10) // should always be called first for a new path
	gc.LineTo(100, 50)
	gc.QuadCurveTo(100, 10, 10, 10)
	gc.Close()
	gc.FillStroke()

	// Save to file
	draw2dpdf.SaveToPdfFile("hello.pdf", dest)
}

There are more examples here: https://github.com/llgcode/draw2d/tree/master/samples

Drawing on opengl is provided by the draw2dgl package.

Testing

The samples are run as tests from the root package folder draw2d by:

go test ./...

Or if you want to run with test coverage:

go test -cover ./... | grep -v "no test"

This will generate output by the different backends in the output folder.

Acknowledgments

Laurent Le Goff wrote this library, inspired by Postscript and HTML5 canvas. He implemented the image and opengl backend with the freetype-go package. Also he created a pure go Postscript interpreter, which can read postscript images and draw to a draw2d graphic context. Stani Michiels implemented the pdf backend with the gofpdf package.

Packages using draw2d

  • ps: Postscript interpreter written in Go
  • gonum/plot: drawing plots in Go
  • go.uik: a concurrent UI kit written in pure go.
  • smartcrop: content aware image cropping
  • karta: drawing Voronoi diagrams
  • chart: basic charts in Go
  • hilbert: package for drawing Hilbert curves

References

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].