Skip to content

Instantly share code, notes, and snippets.

@rhyhann
Created September 9, 2010 00:08
Show Gist options
  • Save rhyhann/571108 to your computer and use it in GitHub Desktop.
Save rhyhann/571108 to your computer and use it in GitHub Desktop.
# API Showcase
svg = Ralphy::Container.new(width:300,height:200)
# Drawing a simple circle within a rectangle:
# All of Ralphy's classes derive from Nokogiri's
circle = Ralphy::Circle.new # Can't be added to svg until all its required arguments are passed (center and radius)
rectangle = Ralphy::Rectangle.new # required: center || (top|bottom)-(left|right) position, height, and width
rectangle.center = circle.center = svg.center # svg.center is generated
circle.center = (rectangle.width = svg.width/2)/2
rectangle.height = svg.height/2
svg += [rectangle, circle] # OR svg << rectangle; svg << circle
svg.to_svg # OR svg.to_png, which will use ImageMagick.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment