Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rplot

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rplot

  • 0.0.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

= rplot

rplot is a C extension for Ruby of GNU libplot.

{GNU libplot}[http://www.gnu.org/software/plotutils/manual/html_mono/plotutils.html#SEC45] is a free function library for drawing two-dimensional vector graphics. It can produce smooth, double-buffered animations for the X Window System, and can export files in many graphics file formats. It is `device-independent' in the sense that its API (application programming interface) is to a large extent independent of the display type or output format. Rplot is a C extension for Ruby of GNU libplot.

== Requirements

  • libplot-dev

For Debian/Ubuntu users: apt-get install libplot-dev.

For Max OS X users use {port}[http://www.macports.org/]: port install plotutils.

== Installation

gem install rplot

== Usage

Here two little examples.

The first invokes rplot operations to draw vector graphics. It draws an intricate and beautiful path (Bill Gosper's "C" curve, discussed as Item #135 in HAKMEM, MIT Artificial Intelligence Laboratory Memo #239, 1972). As the numeric constant MAXORDER (here equal to 12) is increased, the path will take on the shape of a curly letter "C", which is the envelope of a myriad of epicyclic octagons.

require 'rubygems'
require 'rplot'

module MyCurve
  MAXORDER = 12
  def draw_curve(dx, dy, order)
    if order >= MAXORDER
      self.cont(dx, dy, :rel => true)
    else
      self.draw_curve(0.5*(dx-dy), 0.5*(dx+dy), order+1)
      self.draw_curve(0.5*(dx+dy), 0.5*(dy-dx), order+1)
    end
  end
end
Plotter.send(:include, MyCurve)

Plotter.params(:pagesize => 'letter')

Plotter.draw('png', 'RUBYtest3.png')do |p|
  p.space(0,0, 1000,1000)
  p.linewidth(0.25)
  p.pencolor('red')
  p.move(600, 300)
  p.draw_curve(0, 400, 0)
end

The second example creates a simple animated pseudo-GIF, 150 pixels wide and 100 pixels high.

require 'rubygems'
require 'rplot'

Plotter.params(:bitmapsize => '150x100',
               :bg_color => 'orange',
               :transparent_color => 'orange',
               :gif_iterations => 100,
               :gif_delay => 5)
p = Plotter.new('gif', 'image.gif')
p.open
p.space(0,0,149,99)
p.pencolor('red')
p.linewidth(5)
p.filltype(1)
p.fillcolor('black')
i = 0
while i < 180
  p.erase
  p.erase
  p.ellipse(75,50,40,20,i)
  i += 15
end
p.delete

{Here the complete documentation with API}[http://pioz.github.com/rplot/Plotter.html].

== Questions or problems?

If you have any issues with rplot please add an {issue on GitHub}[https://github.com/pioz/rplot/issues] or fork the project and send a pull request.

== Copyright

Copyright (c) 2010 Enrico Pilotto. See {LICENSE}[http://github.com/pioz/rplot/blob/master/LICENSE] for details.

FAQs

Package last updated on 25 Jan 2011

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc