update circle to use svg_attributes
Johnathon E. Wright
committed Nov 10, 2011
commit 1f9ceaf312d368a271677327dbc3f13a1425fb0e
Showing 2
changed files with
20 additions
and 2 deletions
sketch/circle.rb b/lib/sketch/circle.rb
+8
-2
| @@ | @@ -4,11 +4,17 @@ class Sketch::Circle < Sketch::Element |
| has_value :cy | |
| has_value :r, :alias => :radius | |
| has_value :fill | |
| + | has_value :fill_opacity |
| has_value :stroke | |
| has_value :stroke_width | |
| - | def draw(canvas) |
| - | canvas.circle(:cx => self.cx, :cy => self.cy, :r => self.radius, :fill => self.fill, :stroke => self.stroke, 'stroke_width' => self.stroke_width) |
| + | def point=(coordinates) |
| + | self.cx, self.cy = *coordinates |
| end | |
| + | |
| + | def point |
| + | [self.cx, self.cy] |
| + | end |
| + | |
| end | |
test/circle_test.rb
+12
-0
| @@ | @@ -0,0 +1,12 @@ |
| + | require 'helper' |
| + | |
| + | class CircleTest < Test::Unit::TestCase |
| + | |
| + | def test_that_point_is_broken_into_coordinates |
| + | c = Sketch::Circle.new(:point => [10, 20]) |
| + | assert_equal 10, c.cx |
| + | assert_equal 20, c.cy |
| + | end |
| + | |
| + | end |
| + | |