fractals 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -0,0 +1,37 @@
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
+ <!--
5
+
6
+ Files [Ruby Fractal Library - 1.2.0]
7
+
8
+ -->
9
+ <head>
10
+ <title>Files [Ruby Fractal Library - 1.2.0]</title>
11
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
12
+ <link rel="stylesheet" href="rdoc-style.css" type="text/css" />
13
+ <base target="docwin" />
14
+ </head>
15
+ <body>
16
+ <div class="index">
17
+ <h1 class="section-bar">Files</h1>
18
+ <div id="index-entries">
19
+
20
+ <a href="files/README.html">README</a><br />
21
+
22
+ <a href="files/examples_rb.html">examples.rb</a><br />
23
+
24
+ <a href="files/gpl-2_0_txt.html">gpl-2.0.txt</a><br />
25
+
26
+ <a href="files/lib/fractals_rb.html">lib/fractals.rb</a><br />
27
+
28
+ <a href="files/lib/fractals/algorithms_rb.html">lib/fractals/algorithms.rb</a><br />
29
+
30
+ <a href="files/lib/fractals/renderers_rb.html">lib/fractals/renderers.rb</a><br />
31
+
32
+ <a href="files/lib/fractals/themes_rb.html">lib/fractals/themes.rb</a><br />
33
+
34
+ </div>
35
+ </div>
36
+ </body>
37
+ </html>
@@ -0,0 +1,57 @@
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
+ <!--
5
+
6
+ Methods [Ruby Fractal Library - 1.2.0]
7
+
8
+ -->
9
+ <head>
10
+ <title>Methods [Ruby Fractal Library - 1.2.0]</title>
11
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
12
+ <link rel="stylesheet" href="rdoc-style.css" type="text/css" />
13
+ <base target="docwin" />
14
+ </head>
15
+ <body>
16
+ <div class="index">
17
+ <h1 class="section-bar">Methods</h1>
18
+ <div id="index-entries">
19
+
20
+ <a href="classes/Fractals/Renderers/Base.html#M000010">acts_as_renderer (Fractals::Renderers::Base)</a><br />
21
+
22
+ <a href="classes/Fractals/Renderers/Base.html#M000007">in_set? (Fractals::Renderers::Base)</a><br />
23
+
24
+ <a href="classes/Fractals/Fractal.html#M000013">iterate (Fractals::Fractal)</a><br />
25
+
26
+ <a href="classes/Fractals/Renderers/Base.html#M000006">new (Fractals::Renderers::Base)</a><br />
27
+
28
+ <a href="classes/Fractals/Julia.html#M000015">new (Fractals::Julia)</a><br />
29
+
30
+ <a href="classes/Fractals/BurningShip.html#M000014">new (Fractals::BurningShip)</a><br />
31
+
32
+ <a href="classes/Fractals/Mandelbrot.html#M000016">new (Fractals::Mandelbrot)</a><br />
33
+
34
+ <a href="classes/Fractals/Fractal.html#M000012">new (Fractals::Fractal)</a><br />
35
+
36
+ <a href="classes/Fractals/Newton.html#M000017">new (Fractals::Newton)</a><br />
37
+
38
+ <a href="classes/Fractals/Renderers/Base.html#M000008">render (Fractals::Renderers::Base)</a><br />
39
+
40
+ <a href="classes/Fractals/Renderers/Base.html#M000009">renderer= (Fractals::Renderers::Base)</a><br />
41
+
42
+ <a href="classes/Fractals/Renderers/PNGRenderer.html#M000001">to_blob (Fractals::Renderers::PNGRenderer)</a><br />
43
+
44
+ <a href="classes/Fractals/Renderers/RMagickRenderer.html#M000003">to_blob (Fractals::Renderers::RMagickRenderer)</a><br />
45
+
46
+ <a href="classes/Fractals/Renderers/Base.html#M000011">where_is? (Fractals::Renderers::Base)</a><br />
47
+
48
+ <a href="classes/Fractals/Renderers/PNGRenderer.html#M000002">write (Fractals::Renderers::PNGRenderer)</a><br />
49
+
50
+ <a href="classes/Fractals/Renderers/JRubyRenderer.html#M000005">write (Fractals::Renderers::JRubyRenderer)</a><br />
51
+
52
+ <a href="classes/Fractals/Renderers/RMagickRenderer.html#M000004">write (Fractals::Renderers::RMagickRenderer)</a><br />
53
+
54
+ </div>
55
+ </div>
56
+ </body>
57
+ </html>
data/doc/index.html ADDED
@@ -0,0 +1,21 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <!--
5
+
6
+ Ruby Fractal Library - 1.2.0
7
+
8
+ -->
9
+ <head>
10
+ <title>Ruby Fractal Library - 1.2.0</title>
11
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
12
+ </head>
13
+ <frameset rows="20%, 80%">
14
+ <frameset cols="25%,35%,45%">
15
+ <frame src="fr_file_index.html" title="Files" name="Files" />
16
+ <frame src="fr_class_index.html" name="Classes" />
17
+ <frame src="fr_method_index.html" name="Methods" />
18
+ </frameset>
19
+ <frame src="files/README.html" name="docwin" />
20
+ </frameset>
21
+ </html>
@@ -0,0 +1,299 @@
1
+ body {
2
+ font-family: Verdana,Arial,Helvetica,sans-serif;
3
+ font-size: 90%;
4
+ margin: 0;
5
+ margin-left: 40px;
6
+ padding: 0;
7
+ background: white;
8
+ color: black;
9
+ }
10
+
11
+ h1, h2, h3, h4 {
12
+ margin: 0;
13
+ background: transparent;
14
+ }
15
+
16
+ h1 {
17
+ font-size: 150%;
18
+ }
19
+
20
+ h2,h3,h4 {
21
+ margin-top: 1em;
22
+ }
23
+
24
+ :link, :visited {
25
+ background: #eef;
26
+ color: #039;
27
+ text-decoration: none;
28
+ }
29
+
30
+ :link:hover, :visited:hover {
31
+ background: #039;
32
+ color: #eef;
33
+ }
34
+
35
+ /* Override the base stylesheet's Anchor inside a table cell */
36
+ td > :link, td > :visited {
37
+ background: transparent;
38
+ color: #039;
39
+ text-decoration: none;
40
+ }
41
+
42
+ /* and inside a section title */
43
+ .section-title > :link, .section-title > :visited {
44
+ background: transparent;
45
+ color: #eee;
46
+ text-decoration: none;
47
+ }
48
+
49
+ /* === Structural elements =================================== */
50
+
51
+ .index {
52
+ margin: 0;
53
+ margin-left: -40px;
54
+ padding: 0;
55
+ font-size: 90%;
56
+ }
57
+
58
+ .index :link, .index :visited {
59
+ margin-left: 0.7em;
60
+ }
61
+
62
+ .index .section-bar {
63
+ margin-left: 0px;
64
+ padding-left: 0.7em;
65
+ background: #ccc;
66
+ font-size: small;
67
+ }
68
+
69
+ #classHeader, #fileHeader {
70
+ width: auto;
71
+ color: white;
72
+ padding: 0.5em 1.5em 0.5em 1.5em;
73
+ margin: 0;
74
+ margin-left: -40px;
75
+ border-bottom: 3px solid #006;
76
+ }
77
+
78
+ #classHeader :link, #fileHeader :link,
79
+ #classHeader :visited, #fileHeader :visited {
80
+ background: inherit;
81
+ color: white;
82
+ }
83
+
84
+ #classHeader td, #fileHeader td {
85
+ background: inherit;
86
+ color: white;
87
+ }
88
+
89
+ #fileHeader {
90
+ background: #057;
91
+ }
92
+
93
+ #classHeader {
94
+ background: #048;
95
+ }
96
+
97
+ .class-name-in-header {
98
+ font-size: 180%;
99
+ font-weight: bold;
100
+ }
101
+
102
+ #bodyContent {
103
+ padding: 0 1.5em 0 1.5em;
104
+ }
105
+
106
+ #description {
107
+ padding: 0.5em 1.5em;
108
+ background: #efefef;
109
+ border: 1px dotted #999;
110
+ }
111
+
112
+ #description h1, #description h2, #description h3,
113
+ #description h4, #description h5, #description h6 {
114
+ color: #125;
115
+ background: transparent;
116
+ }
117
+
118
+ #validator-badges {
119
+ text-align: center;
120
+ }
121
+
122
+ #validator-badges img {
123
+ border: 0;
124
+ }
125
+
126
+ #copyright {
127
+ color: #333;
128
+ background: #efefef;
129
+ font: 0.75em sans-serif;
130
+ margin-top: 5em;
131
+ margin-bottom: 0;
132
+ padding: 0.5em 2em;
133
+ }
134
+
135
+ /* === Classes =================================== */
136
+
137
+ table.header-table {
138
+ color: white;
139
+ font-size: small;
140
+ }
141
+
142
+ .type-note {
143
+ font-size: small;
144
+ color: #dedede;
145
+ }
146
+
147
+ .section-bar {
148
+ color: #333;
149
+ border-bottom: 1px solid #999;
150
+ margin-left: -20px;
151
+ }
152
+
153
+ .section-title {
154
+ background: #79a;
155
+ color: #eee;
156
+ padding: 3px;
157
+ margin-top: 2em;
158
+ margin-left: -30px;
159
+ border: 1px solid #999;
160
+ }
161
+
162
+ .top-aligned-row {
163
+ vertical-align: top
164
+ }
165
+
166
+ .bottom-aligned-row {
167
+ vertical-align: bottom
168
+ }
169
+
170
+ #diagram img {
171
+ border: 0;
172
+ }
173
+
174
+ /* --- Context section classes ----------------------- */
175
+
176
+ .context-row { }
177
+
178
+ .context-item-name {
179
+ font-family: monospace;
180
+ font-weight: bold;
181
+ color: black;
182
+ }
183
+
184
+ .context-item-value {
185
+ font-size: small;
186
+ color: #448;
187
+ }
188
+
189
+ .context-item-desc {
190
+ color: #333;
191
+ padding-left: 2em;
192
+ }
193
+
194
+ /* --- Method classes -------------------------- */
195
+
196
+ .method-detail {
197
+ background: #efefef;
198
+ padding: 0;
199
+ margin-top: 0.5em;
200
+ margin-bottom: 1em;
201
+ border: 1px dotted #ccc;
202
+ }
203
+
204
+ .method-heading {
205
+ color: black;
206
+ background: #ccc;
207
+ border-bottom: 1px solid #666;
208
+ padding: 0.2em 0.5em 0 0.5em;
209
+ }
210
+
211
+ .method-signature {
212
+ color: black;
213
+ background: inherit;
214
+ }
215
+
216
+ .method-name {
217
+ font-weight: bold;
218
+ }
219
+
220
+ .method-args {
221
+ font-style: italic;
222
+ }
223
+
224
+ .method-description {
225
+ padding: 0 0.5em 0 0.5em;
226
+ }
227
+
228
+ /* --- Source code sections -------------------- */
229
+
230
+ :link.source-toggle, :visited.source-toggle {
231
+ font-size: 90%;
232
+ }
233
+
234
+ div.method-source-code {
235
+ background: #262626;
236
+ color: #ffdead;
237
+ margin: 1em;
238
+ padding: 0.5em;
239
+ border: 1px dashed #999;
240
+ overflow: auto;
241
+ }
242
+
243
+ div.method-source-code pre {
244
+ color: #ffdead;
245
+ }
246
+
247
+ /* --- Ruby keyword styles --------------------- */
248
+
249
+ .standalone-code {
250
+ background: #221111;
251
+ color: #ffdead;
252
+ overflow: auto;
253
+ }
254
+
255
+ .ruby-constant {
256
+ color: #7fffd4;
257
+ background: transparent;
258
+ }
259
+
260
+ .ruby-keyword {
261
+ color: #00ffff;
262
+ background: transparent;
263
+ }
264
+
265
+ .ruby-ivar {
266
+ color: #eedd82;
267
+ background: transparent;
268
+ }
269
+
270
+ .ruby-operator {
271
+ color: #00ffee;
272
+ background: transparent;
273
+ }
274
+
275
+ .ruby-identifier {
276
+ color: #ffdead;
277
+ background: transparent;
278
+ }
279
+
280
+ .ruby-node {
281
+ color: #ffa07a;
282
+ background: transparent;
283
+ }
284
+
285
+ .ruby-comment {
286
+ color: #b22222;
287
+ font-weight: bold;
288
+ background: transparent;
289
+ }
290
+
291
+ .ruby-regexp {
292
+ color: #ffa07a;
293
+ background: transparent;
294
+ }
295
+
296
+ .ruby-value {
297
+ color: #7fffd4;
298
+ background: transparent;
299
+ }
data/examples.rb ADDED
@@ -0,0 +1,101 @@
1
+ # This file contains a few examples. View the source code for more information.
2
+
3
+ require 'rubygems'
4
+ require 'fractals'
5
+ require 'RMagick'
6
+
7
+ include Fractals
8
+
9
+ # Just as version 1.0.0, creating a fractal is as easy as:
10
+ mandelbrot = Mandelbrot.new
11
+ mandelbrot.write
12
+
13
+ # Or...
14
+ Mandelbrot.new.write
15
+
16
+
17
+ # Each of the expression's arguments can be modified using a Hash.
18
+ newton = Newton.new
19
+ newton.args = {:a => -0.5, :pz => lambda { |z| z**3 - 1 }}
20
+ newton.write('newton.png')
21
+
22
+
23
+ # New orbits fractals can be constructed by either inheriting from Fractal or
24
+ # instantiating it directly. The complex number args[:c] is added to the
25
+ # argument Hash during iteration.
26
+ fractal = Fractal.new(Complex(0.0, 0.0), {:p => 2}) do |args|
27
+ args[:z] = args[:z]**args[:p] +
28
+ Math.sqrt(args[:c])
29
+ end
30
+ fractal.write('new.png')
31
+
32
+
33
+ # Every property has a default value. In this example I've chosen to override
34
+ # quite a few of them. The result produces an image that looks similar to a
35
+ # snowflake.
36
+ snowflakes = Julia.new(Complex(-0.3007, 0.6601))
37
+ snowflakes.bailout = 5
38
+ snowflakes.max_iterations = 100
39
+ snowflakes.algorithm = Algorithms::NormalizedIterationCount
40
+ snowflakes.theme = Themes::Winter
41
+ snowflakes.set_color = [255, 255, 255]
42
+ snowflakes.write('snowflakes.png')
43
+
44
+
45
+ # Here I'm creating an animated fractal using RMagick and the RMagickRenderer's
46
+ # to_blob method. This is both CPU and memory intensive so act accordingly.
47
+ # This is about as complicated as it gets.
48
+ feigenbaum = Mandelbrot.new(Complex(-0.1528, 1.0397))
49
+ feigenbaum.max_iterations = 100
50
+ feigenbaum.renderer = Renderers::RMagickRenderer
51
+ feigenbaum.width = 150
52
+ feigenbaum.height = 150
53
+ feigenbaum.magnification = 25
54
+ feigenbaum.algorithm = Algorithms::NormalizedIterationCount
55
+ feigenbaum.theme = Themes::Water
56
+
57
+ image_list = Magick::ImageList.new
58
+ image_list.delay = 100
59
+ image_list.iterations = 1
60
+
61
+ (0...50).each { |i|
62
+ feigenbaum.magnification += (i**2)
63
+ image_list << Magick::Image.from_blob(feigenbaum.to_blob('gif'))[0]
64
+ }
65
+
66
+ image_list.write('feigenbaum.gif')
67
+
68
+
69
+ # Some interesting fractals:
70
+
71
+ # The Mandelbrot "satellite".
72
+ satellite = Mandelbrot.new(Complex(-0.743643135, 0.131825963))
73
+ satellite.max_iterations = 1500
74
+ satellite.magnification = 200000
75
+ satellite.renderer = Renderers::RMagickRenderer
76
+ satellite.write('satellite.jpg')
77
+
78
+ # The Feigenbaum Point.
79
+ feigenbaum = Mandelbrot.new(Complex(-0.1528, 1.0397))
80
+ feigenbaum.magnification = 25
81
+ feigenbaum.algorithm = Algorithms::NormalizedIterationCount
82
+ feigenbaum.theme = Themes::Water
83
+ feigenbaum.write('feigenbaum.png')
84
+
85
+ # The Misiurewicz Point.
86
+ misiurewicz = Mandelbrot.new(Complex(-0.1011, 0.9563))
87
+ misiurewicz.magnification = 50
88
+ misiurewicz.algorithm = Algorithms::NormalizedIterationCount
89
+ misiurewicz.write('misiurewicz.png')
90
+
91
+ # Seahorse Valley.
92
+ seahorse_valley = Mandelbrot.new(Complex(-0.8759, 0.2046))
93
+ seahorse_valley.magnification = 6
94
+ seahorse_valley.algorithm = Algorithms::NormalizedIterationCount
95
+ seahorse_valley.theme = Themes::Water
96
+ seahorse_valley.write('seahorse_valley.png')
97
+
98
+ # The classic Burning Ship.
99
+ burning_ship = BurningShip.new(Complex(-1.75, -0.04))
100
+ burning_ship.magnification = 32
101
+ burning_ship.write('burning_ship.png')