fractals 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. data/README +66 -0
  2. data/Rakefile +65 -0
  3. data/doc/classes/Fractals.html +169 -0
  4. data/doc/classes/Fractals/Algorithms.html +125 -0
  5. data/doc/classes/Fractals/BurningShip.html +172 -0
  6. data/doc/classes/Fractals/Fractal.html +261 -0
  7. data/doc/classes/Fractals/Julia.html +171 -0
  8. data/doc/classes/Fractals/Mandelbrot.html +172 -0
  9. data/doc/classes/Fractals/Newton.html +173 -0
  10. data/doc/classes/Fractals/Renderers.html +118 -0
  11. data/doc/classes/Fractals/Renderers/Base.html +496 -0
  12. data/doc/classes/Fractals/Renderers/JRubyRenderer.html +178 -0
  13. data/doc/classes/Fractals/Renderers/PNGRenderer.html +202 -0
  14. data/doc/classes/Fractals/Renderers/RMagickRenderer.html +210 -0
  15. data/doc/classes/Fractals/Themes.html +131 -0
  16. data/doc/created.rid +1 -0
  17. data/doc/files/README.html +180 -0
  18. data/doc/files/examples_rb.html +122 -0
  19. data/doc/files/gpl-2_0_txt.html +522 -0
  20. data/doc/files/lib/fractals/algorithms_rb.html +90 -0
  21. data/doc/files/lib/fractals/renderers_rb.html +104 -0
  22. data/doc/files/lib/fractals/themes_rb.html +90 -0
  23. data/doc/files/lib/fractals_rb.html +114 -0
  24. data/doc/fr_class_index.html +49 -0
  25. data/doc/fr_file_index.html +37 -0
  26. data/doc/fr_method_index.html +57 -0
  27. data/doc/index.html +21 -0
  28. data/doc/rdoc-style.css +299 -0
  29. data/examples.rb +101 -0
  30. data/gpl-2.0.txt +339 -0
  31. data/lib/fractals.rb +105 -0
  32. data/lib/fractals/algorithms.rb +35 -0
  33. data/lib/fractals/renderers.rb +169 -0
  34. data/lib/fractals/themes.rb +48 -0
  35. data/test/burning_ship_test.rb +19 -0
  36. data/test/julia_test.rb +20 -0
  37. data/test/mandelbrot_test.rb +19 -0
  38. data/test/newton_test.rb +20 -0
  39. data/test/renderer_test.rb +21 -0
  40. metadata +104 -0
data/README ADDED
@@ -0,0 +1,66 @@
1
+ Fractals is a library for creating fractal images in your Ruby programs. It
2
+ currently renders the Burning Ship, Julia Set, Mandelbrot, and Newton fractals
3
+ using the Escape Time or Normalized Iteration Count algorithm. The Themes
4
+ module contains a few predefined coloring palettes, but the Fractal type will
5
+ also accept any user-defined algorithm or theme.
6
+
7
+ Changes:
8
+ There have been a few changes since version 1.1.0. I've removed
9
+ most of the duplicate code, added Procs where appropriate, and
10
+ made the syntax more consistent. The result is much more
11
+ readable and should be easier to maintain.
12
+
13
+ 1. The source code has been split into multiple files. One for
14
+ each module.
15
+ 2. Each of the fractals has been distilled to a single block
16
+ passed to the Fractal base class' constructor. This makes
17
+ it easy to construct new orbits fractals by either
18
+ inheriting from Fractal or instantiating it directly.
19
+ 3. Classes have been added for the Burning Ship and Newton
20
+ fractals.
21
+ 4. A 'Winter' theme has been added.
22
+ 5. Users can now choose which dependancy nightmare they'd
23
+ prefer. PNG, RMagick and JRuby each have their own renderer.
24
+ PNGRenderer is the default, but is easy to override with the
25
+ renderer= method.
26
+ 6. bailout and max_iterations are no longer constructor
27
+ parameters. This is the biggest breaking change.
28
+ 7. Unit tests have been added for each fractal.
29
+ 8. Several rake tasks have been added to make installation and
30
+ gem creation easier.
31
+
32
+ See the documentation for a complete API reference.
33
+
34
+ Installation:
35
+ sudo gem install fractals-1.2.0.gem
36
+
37
+ Installing from source:
38
+ svn checkout http://svn.ryanbaxter.net/fractals/tags/1.2.0 fractals-1.2.0
39
+ cd fractals-1.2.0
40
+ rake install
41
+
42
+ Using Fractals:
43
+ require 'rubygems'
44
+ require 'fractals'
45
+
46
+ mandelbrot = Fractals::Mandelbrot.new
47
+ mandelbrot.write
48
+
49
+ Examples can be found in the examples.rb file.
50
+
51
+ License:
52
+ Copyright (c) 2009 Ryan Baxter
53
+
54
+ This program is free software; you can redistribute it and/or
55
+ modify it under the terms of the GNU General Public License
56
+ as published by the Free Software Foundation; either version 2
57
+ of the License, or (at your option) any later version.
58
+
59
+ This program is distributed in the hope that it will be useful,
60
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
61
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
62
+ GNU General Public License for more details.
63
+
64
+ You should have received a copy of the GNU General Public License
65
+ along with this program; if not, write to the Free Software
66
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
data/Rakefile ADDED
@@ -0,0 +1,65 @@
1
+ require 'rake'
2
+ require 'rake/clean'
3
+ require 'rake/gempackagetask'
4
+ require 'rake/rdoctask'
5
+ require 'rake/testtask'
6
+
7
+ NAME = 'fractals'
8
+ VERS = '1.2.0'
9
+ RDOC_FILES = ['examples.rb', 'gpl-2.0.txt', 'README']
10
+
11
+ CLEAN.include ['doc/**/*', 'pkg/**/*']
12
+
13
+ task :default => [:test_units]
14
+
15
+ desc 'Cleans directories, creates documentation and gem.'
16
+ task :package => [:clean, :rdoc, :gem]
17
+
18
+ desc 'Packages and installs the gem.'
19
+ task :install do
20
+ sh %{rake package}
21
+ sh %{sudo gem install pkg/#{NAME}-#{VERS}}
22
+ end
23
+
24
+ desc 'Uninstalls the gem'
25
+ task :uninstall => [:clean] do
26
+ sh %{sudo gem uninstall #{NAME}}
27
+ end
28
+
29
+ desc 'Runs unit tests.'
30
+ Rake::TestTask.new('test_units') do |test|
31
+ test.pattern = 'test/*_test.rb'
32
+ test.verbose = true
33
+ test.warning = true
34
+ end
35
+
36
+ desc 'Creates the documentation.'
37
+ Rake::RDocTask.new do |rdoc|
38
+ rdoc.rdoc_dir = 'doc'
39
+ rdoc.options = ['--title', "Ruby Fractal Library - #{VERS}", '--inline-source']
40
+ rdoc.main = 'README'
41
+ rdoc.rdoc_files.add RDOC_FILES
42
+ rdoc.rdoc_files.add 'lib/**/*.rb'
43
+ end
44
+
45
+ spec = Gem::Specification.new do |s|
46
+ s.name = NAME
47
+ s.version = VERS
48
+ s.author = 'Ryan Baxter'
49
+ s.email = 'rcbaxter@gmail.com'
50
+ s.homepage = 'http://ryanbaxter.net/pages/ruby_fractal_library'
51
+ s.platform = Gem::Platform::RUBY
52
+ s.summary = 'A library for creating fractals in the Ruby programming language.'
53
+ s.files = %w(examples.rb gpl-2.0.txt Rakefile README) +
54
+ Dir.glob("{doc,lib,test}/**/*")
55
+ s.test_files = FileList['test/**/*'].to_a
56
+ s.require_paths = ['lib']
57
+ s.has_rdoc = true
58
+ s.extra_rdoc_files = RDOC_FILES
59
+ end
60
+
61
+ desc 'Creates the gem.'
62
+ Rake::GemPackageTask.new(spec) do |pkg|
63
+ pkg.need_tar = true
64
+ pkg.need_zip = true
65
+ end
@@ -0,0 +1,169 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <title>Module: Fractals [Ruby Fractal Library - 1.2.0]</title>
6
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
7
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
8
+ <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
9
+ <script type="text/javascript">
10
+ // <![CDATA[
11
+
12
+ function popupCode( url ) {
13
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
14
+ }
15
+
16
+ function toggleCode( id ) {
17
+ if ( document.getElementById )
18
+ elem = document.getElementById( id );
19
+ else if ( document.all )
20
+ elem = eval( "document.all." + id );
21
+ else
22
+ return false;
23
+
24
+ elemStyle = elem.style;
25
+
26
+ if ( elemStyle.display != "block" ) {
27
+ elemStyle.display = "block"
28
+ } else {
29
+ elemStyle.display = "none"
30
+ }
31
+
32
+ return true;
33
+ }
34
+
35
+ // Make codeblocks hidden by default
36
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }<\/style>" )
37
+
38
+ // ]]>
39
+ </script>
40
+
41
+ </head>
42
+ <body>
43
+
44
+
45
+ <div id="classHeader">
46
+ <table class="header-table">
47
+ <tr class="top-aligned-row">
48
+ <td><strong>Module</strong></td>
49
+ <td class="class-name-in-header">Fractals</td>
50
+ </tr>
51
+ <tr class="top-aligned-row">
52
+ <td><strong>In:</strong></td>
53
+ <td>
54
+
55
+
56
+ <a href="../files/lib/fractals_rb.html">
57
+
58
+ lib/fractals.rb
59
+
60
+ </a>
61
+
62
+
63
+ <br />
64
+
65
+
66
+ <a href="../files/lib/fractals/algorithms_rb.html">
67
+
68
+ lib/fractals/algorithms.rb
69
+
70
+ </a>
71
+
72
+
73
+ <br />
74
+
75
+
76
+ <a href="../files/lib/fractals/themes_rb.html">
77
+
78
+ lib/fractals/themes.rb
79
+
80
+ </a>
81
+
82
+
83
+ <br />
84
+
85
+
86
+ <a href="../files/lib/fractals/renderers_rb.html">
87
+
88
+ lib/fractals/renderers.rb
89
+
90
+ </a>
91
+
92
+
93
+ <br />
94
+
95
+ </td>
96
+ </tr>
97
+
98
+
99
+ </table>
100
+ </div>
101
+ <!-- banner header -->
102
+
103
+ <div id="bodyContent">
104
+
105
+ <div id="contextContent">
106
+
107
+ <div id="description">
108
+ <p>
109
+ The root module of the <a href="Fractals.html">Fractals</a> namespace.
110
+ </p>
111
+ <h1>Example:</h1>
112
+ <p>
113
+ require &#8216;rubygems&#8217;<br /> require &#8216;fractals&#8217;<br />
114
+ </p>
115
+ <p>
116
+ include <b>Fractals</b><br /><br />
117
+ </p>
118
+ <hr size="1"></hr>
119
+ </div>
120
+
121
+ </div>
122
+
123
+
124
+ </div>
125
+
126
+ <!-- if includes -->
127
+
128
+ <div id="includes">
129
+ <h3 class="section-bar">Included Modules</h3>
130
+
131
+ <div id="includes-list">
132
+
133
+ <span class="include-name">Math</span>
134
+
135
+ </div>
136
+ </div>
137
+
138
+ <div id="section">
139
+
140
+ <div id="class-list">
141
+ <h3 class="section-bar">Classes and Modules</h3>
142
+
143
+ Module <a href="Fractals/Algorithms.html" class="link">Fractals::Algorithms</a><br />
144
+ Module <a href="Fractals/Renderers.html" class="link">Fractals::Renderers</a><br />
145
+ Module <a href="Fractals/Themes.html" class="link">Fractals::Themes</a><br />
146
+ Class <a href="Fractals/BurningShip.html" class="link">Fractals::BurningShip</a><br />
147
+ Class <a href="Fractals/Fractal.html" class="link">Fractals::Fractal</a><br />
148
+ Class <a href="Fractals/Julia.html" class="link">Fractals::Julia</a><br />
149
+ Class <a href="Fractals/Mandelbrot.html" class="link">Fractals::Mandelbrot</a><br />
150
+ Class <a href="Fractals/Newton.html" class="link">Fractals::Newton</a><br />
151
+
152
+ </div>
153
+
154
+
155
+
156
+
157
+ <!-- if method_list -->
158
+
159
+
160
+
161
+
162
+ </div>
163
+
164
+ <div id="validator-badges">
165
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
166
+ </div>
167
+
168
+ </body>
169
+ </html>
@@ -0,0 +1,125 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <title>Module: Fractals::Algorithms [Ruby Fractal Library - 1.2.0]</title>
6
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
7
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
8
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
9
+ <script type="text/javascript">
10
+ // <![CDATA[
11
+
12
+ function popupCode( url ) {
13
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
14
+ }
15
+
16
+ function toggleCode( id ) {
17
+ if ( document.getElementById )
18
+ elem = document.getElementById( id );
19
+ else if ( document.all )
20
+ elem = eval( "document.all." + id );
21
+ else
22
+ return false;
23
+
24
+ elemStyle = elem.style;
25
+
26
+ if ( elemStyle.display != "block" ) {
27
+ elemStyle.display = "block"
28
+ } else {
29
+ elemStyle.display = "none"
30
+ }
31
+
32
+ return true;
33
+ }
34
+
35
+ // Make codeblocks hidden by default
36
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }<\/style>" )
37
+
38
+ // ]]>
39
+ </script>
40
+
41
+ </head>
42
+ <body>
43
+
44
+
45
+ <div id="classHeader">
46
+ <table class="header-table">
47
+ <tr class="top-aligned-row">
48
+ <td><strong>Module</strong></td>
49
+ <td class="class-name-in-header">Fractals::Algorithms</td>
50
+ </tr>
51
+ <tr class="top-aligned-row">
52
+ <td><strong>In:</strong></td>
53
+ <td>
54
+
55
+
56
+ <a href="../../files/lib/fractals/algorithms_rb.html">
57
+
58
+ lib/fractals/algorithms.rb
59
+
60
+ </a>
61
+
62
+
63
+ <br />
64
+
65
+ </td>
66
+ </tr>
67
+
68
+
69
+ </table>
70
+ </div>
71
+ <!-- banner header -->
72
+
73
+ <div id="bodyContent">
74
+
75
+ <div id="contextContent">
76
+
77
+ <div id="description">
78
+ <p>
79
+ A renderer&#8217;s algorithm calculates the color index for complex
80
+ coordinates that lie outside of a fractal&#8217;s set.
81
+ </p>
82
+ <table>
83
+ <tr><td valign="top"><b>EscapeTime</b>:</td><td>The default algorithm for orbits fractals.
84
+
85
+ </td></tr>
86
+ <tr><td valign="top"><b>NormalizedIterationCount</b>:</td><td>Produces an image with less color banding than the Escape Time algorithm.
87
+
88
+ </td></tr>
89
+ </table>
90
+ <p>
91
+ <br />
92
+ </p>
93
+ <h1>Example:</h1>
94
+ <p>
95
+ mandelbrot = <a href="Mandelbrot.html#M000016">Mandelbrot.new</a><br />
96
+ mandelbrot.algorithm = <b>Algorithms::NormalizedIterationCount</b>
97
+ </p>
98
+
99
+ </div>
100
+
101
+ </div>
102
+
103
+
104
+ </div>
105
+
106
+ <!-- if includes -->
107
+
108
+ <div id="section">
109
+
110
+
111
+
112
+
113
+ <!-- if method_list -->
114
+
115
+
116
+
117
+
118
+ </div>
119
+
120
+ <div id="validator-badges">
121
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
122
+ </div>
123
+
124
+ </body>
125
+ </html>
@@ -0,0 +1,172 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <title>Class: Fractals::BurningShip [Ruby Fractal Library - 1.2.0]</title>
6
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
7
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
8
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
9
+ <script type="text/javascript">
10
+ // <![CDATA[
11
+
12
+ function popupCode( url ) {
13
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
14
+ }
15
+
16
+ function toggleCode( id ) {
17
+ if ( document.getElementById )
18
+ elem = document.getElementById( id );
19
+ else if ( document.all )
20
+ elem = eval( "document.all." + id );
21
+ else
22
+ return false;
23
+
24
+ elemStyle = elem.style;
25
+
26
+ if ( elemStyle.display != "block" ) {
27
+ elemStyle.display = "block"
28
+ } else {
29
+ elemStyle.display = "none"
30
+ }
31
+
32
+ return true;
33
+ }
34
+
35
+ // Make codeblocks hidden by default
36
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }<\/style>" )
37
+
38
+ // ]]>
39
+ </script>
40
+
41
+ </head>
42
+ <body>
43
+
44
+
45
+ <div id="classHeader">
46
+ <table class="header-table">
47
+ <tr class="top-aligned-row">
48
+ <td><strong>Class</strong></td>
49
+ <td class="class-name-in-header">Fractals::BurningShip</td>
50
+ </tr>
51
+ <tr class="top-aligned-row">
52
+ <td><strong>In:</strong></td>
53
+ <td>
54
+
55
+
56
+ <a href="../../files/lib/fractals_rb.html">
57
+
58
+ lib/fractals.rb
59
+
60
+ </a>
61
+
62
+
63
+ <br />
64
+
65
+ </td>
66
+ </tr>
67
+
68
+
69
+ <tr class="top-aligned-row">
70
+ <td><strong>Parent:</strong></td>
71
+ <td>
72
+
73
+ <a href="Fractal.html">
74
+
75
+ Fractals::Fractal
76
+
77
+ </a>
78
+
79
+ </td>
80
+ </tr>
81
+
82
+ </table>
83
+ </div>
84
+ <!-- banner header -->
85
+
86
+ <div id="bodyContent">
87
+
88
+ <div id="contextContent">
89
+
90
+ <div id="description">
91
+ <p>
92
+ Michael Michelitsch&#8217;s Burning Ship fractal.
93
+ </p>
94
+
95
+ </div>
96
+
97
+ </div>
98
+
99
+
100
+ <div id="method-list">
101
+ <h3 class="section-bar">Methods</h3>
102
+
103
+ <div class="name-list">
104
+
105
+ <a href="#M000014">new</a>&nbsp;&nbsp;
106
+
107
+ </div>
108
+ </div>
109
+
110
+ </div>
111
+
112
+ <!-- if includes -->
113
+
114
+ <div id="section">
115
+
116
+
117
+
118
+
119
+ <!-- if method_list -->
120
+
121
+ <div id="methods">
122
+
123
+ <h3 class="section-bar">Public Class methods</h3>
124
+
125
+
126
+ <div id="method-M000014" class="method-detail">
127
+ <a name="M000014"></a>
128
+
129
+ <div class="method-heading">
130
+
131
+ <a href="#M000014" class="method-signature">
132
+
133
+ <span class="method-name">new</span><span class="method-args">(c=Complex(-0.3, -0.5))</span>
134
+
135
+ </a>
136
+
137
+ </div>
138
+
139
+ <div class="method-description">
140
+
141
+ <p><a class="source-toggle" href="#"
142
+ onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
143
+ <div class="method-source-code" id="M000014-source">
144
+ <pre>
145
+ <span class="ruby-comment cmt"># File lib/fractals.rb, line 64</span>
146
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">c</span>=<span class="ruby-constant">Complex</span>(<span class="ruby-value">-0</span><span class="ruby-value">.3</span>, <span class="ruby-value">-0</span><span class="ruby-value">.5</span>))
147
+ <span class="ruby-keyword kw">super</span>(<span class="ruby-identifier">c</span>, {<span class="ruby-identifier">:p</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">2</span>}) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">args</span><span class="ruby-operator">|</span>
148
+ <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:z</span>] = (<span class="ruby-identifier">args</span>[<span class="ruby-identifier">:z</span>].<span class="ruby-identifier">real</span>.<span class="ruby-identifier">abs</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">sqrt</span>(<span class="ruby-value">-1</span>) <span class="ruby-operator">*</span>
149
+ <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:z</span>].<span class="ruby-identifier">image</span>.<span class="ruby-identifier">abs</span>)<span class="ruby-operator">**</span><span class="ruby-identifier">args</span>[<span class="ruby-identifier">:p</span>] <span class="ruby-operator">+</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:c</span>]
150
+ <span class="ruby-keyword kw">end</span>
151
+ <span class="ruby-keyword kw">end</span>
152
+ </pre>
153
+ </div>
154
+
155
+ </div>
156
+ </div>
157
+
158
+
159
+
160
+ </div>
161
+
162
+
163
+
164
+
165
+ </div>
166
+
167
+ <div id="validator-badges">
168
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
169
+ </div>
170
+
171
+ </body>
172
+ </html>