Permalink
Browse files

added tdd-esque dots output. refactored to more OO approach, more use…

…ful for having multiple objects in the system
  • Loading branch information...
gilesbowkett committed Jul 24, 2009
1 parent d9cc86b commit ef5cef9889b14d2db894f1fa997c633eeec6a021
Showing with 19 additions and 6 deletions.
  1. +3 −1 svg.erb
  2. +16 −5 tweenr.rb
View
@@ -4,7 +4,9 @@
<svg width="1028" height="720" viewBox="0 0 1028 720"
xmlns="http://www.w3.org/2000/svg" version="1.1">
<desc>tweeeeeen</desc>
- <circle cx="<%= @circle.x %>" cy="<%= @circle.y %>" r="100"
+ <% @circles.each do |circle| %>
+ <circle cx="<%= circle.x %>" cy="<%= circle.y %>" r="100"
fill="blue" stroke="blue" stroke-width="10" />
+ <% end %>
</svg>
View
@@ -1,10 +1,15 @@
require 'erb'
-@template = "svg.erb"
+@template = "bit101_style.erb"
-Circle = Struct.new(:x, :y)
+Circle = Struct.new(:x, :y) do
+ def move(number)
+ self.x = number * 9
+ self.y = number * 7
+ end
+end
-@circle = Circle.new(0, 0)
+@circles = [Circle.new(0, 0)]
def frame_id(number)
"output/tween#{sprintf("%.4d", number)}"
@@ -19,12 +24,18 @@ def graphic(number)
File.open("#{frame_id(number)}.svg", "w") do |file|
file.write render(@template)
end
+ print "+"
system("convert #{frame_id(number)}.svg #{frame_id(number)}.jpg")
+ print "|"
File.unlink("#{frame_id(number)}.svg")
+ print "/"
end
(0..100).each do |number|
- @circle.x = number * 9
- @circle.y = number * 7
+ @circles.each do |circle|
+ circle.move(number)
+ print "."
+ end
graphic(number)
+ puts
end

0 comments on commit ef5cef9

Please sign in to comment.