Permalink
Browse files

Fixed the circle command

  • Loading branch information...
1 parent 95d8b2c commit 5a47bdfe580ab767ebd8b3091758d81b3429f436 @bfoz committed Apr 21, 2012
Showing with 28 additions and 3 deletions.
  1. +13 −0 README.markdown
  2. +7 −3 lib/sketch.rb
  3. +8 −0 test/sketch.rb
View
@@ -18,3 +18,16 @@ License
Copyright 2012 Brandon Fosdick <bfoz@bfoz.net> and released under the BSD
license.
+
+Examples
+--------
+
+A basic sketch with a single circle
+
+```ruby
+require 'sketch'
+
+sketch = Sketch do
+ circle [0,0], 5 # Center = [0,0], Radius = 5
+end
+```
View
@@ -9,6 +9,7 @@
class Sketch
attr_reader :elements
+ Circle = Geometry::Circle
Line = Geometry::Line
def initialize
@@ -20,9 +21,12 @@ def geometry
@elements
end
- # Create a new Circle with the given center and radius
- def circle(*center, radius)
- @elements.push Circle.new(0,0,radius)
+ # Create and append a new {Circle} object given a center point and radius
+ # @param [Point] center The circle's center point
+ # @param [Number] radius The circle's radius
+ # @return [Circle] A new {Circle}
+ def circle(*args)
+ @elements.push Circle.new(*args)
@elements.last
end
View
@@ -13,6 +13,14 @@ class SketchTest < Test::Unit::TestCase
assert(sketch.public_methods.include?(:elements))
end
+ must "have a circle command that makes a new circle from a center point and radius" do
+ sketch = Sketch.new
+ circle = sketch.circle [1,2], 3
+ assert_kind_of(Geometry::Circle, circle)
+ assert_equal(circle.center, [1,2])
+ assert_equal(3, circle.radius)
+ end
+
must "have a point creation method" do
sketch = Sketch.new
point = sketch.point(5,6)

0 comments on commit 5a47bdf

Please sign in to comment.