Skip to content

akerl-archived/svgplot

Repository files navigation

svgplot

Gem Version Build Status Coverage Status Code Quality MIT Licensed

SVG creation library forked from xytis's Rasem fork.

Usage

Create an SVG object by initializing it with a size:

plot = SVGPlot.new(width: 100, height: 100)

SVGPlot is based directly on the SVG spec. Add children by calling their methods on the plot:

# Add the text 'foo' at position (1, 2)
plot.text(1, 2) { 'foo' }
# Add a rectangle
plot.rectangle(1, 1, 10, 10)

A good example of the SVG library in practice is GithubChart

Transformations

To do an SVG transform on an object, just call the desired transform method on it:

plot = SVGPlot.new(width: 100, height: 100)
plot.text(1, 1) { 'foobar' }.translate(5, 5)

You can call transforms after the fact as well:

plot = SVGPlot.new(width: 100, height: 100)
text = plot.text(1, 1) { 'foobar' }
text.scale(2)

The list of available transforms:

  • translate(x, y = 0)
  • scale(x, y = 1)
  • rotate(angle, x = nil, y = nil)
  • skew_x(angle)
  • skew_y(angle)
  • matrix(a, b, c, d, e, f)

Installation

gem install svgplot

License

svgplot is released under the MIT License. See the bundled LICENSE file for details.

About

Ruby SVG generation library

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages