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.
- data/README +66 -0
- data/Rakefile +65 -0
- data/doc/classes/Fractals.html +169 -0
- data/doc/classes/Fractals/Algorithms.html +125 -0
- data/doc/classes/Fractals/BurningShip.html +172 -0
- data/doc/classes/Fractals/Fractal.html +261 -0
- data/doc/classes/Fractals/Julia.html +171 -0
- data/doc/classes/Fractals/Mandelbrot.html +172 -0
- data/doc/classes/Fractals/Newton.html +173 -0
- data/doc/classes/Fractals/Renderers.html +118 -0
- data/doc/classes/Fractals/Renderers/Base.html +496 -0
- data/doc/classes/Fractals/Renderers/JRubyRenderer.html +178 -0
- data/doc/classes/Fractals/Renderers/PNGRenderer.html +202 -0
- data/doc/classes/Fractals/Renderers/RMagickRenderer.html +210 -0
- data/doc/classes/Fractals/Themes.html +131 -0
- data/doc/created.rid +1 -0
- data/doc/files/README.html +180 -0
- data/doc/files/examples_rb.html +122 -0
- data/doc/files/gpl-2_0_txt.html +522 -0
- data/doc/files/lib/fractals/algorithms_rb.html +90 -0
- data/doc/files/lib/fractals/renderers_rb.html +104 -0
- data/doc/files/lib/fractals/themes_rb.html +90 -0
- data/doc/files/lib/fractals_rb.html +114 -0
- data/doc/fr_class_index.html +49 -0
- data/doc/fr_file_index.html +37 -0
- data/doc/fr_method_index.html +57 -0
- data/doc/index.html +21 -0
- data/doc/rdoc-style.css +299 -0
- data/examples.rb +101 -0
- data/gpl-2.0.txt +339 -0
- data/lib/fractals.rb +105 -0
- data/lib/fractals/algorithms.rb +35 -0
- data/lib/fractals/renderers.rb +169 -0
- data/lib/fractals/themes.rb +48 -0
- data/test/burning_ship_test.rb +19 -0
- data/test/julia_test.rb +20 -0
- data/test/mandelbrot_test.rb +19 -0
- data/test/newton_test.rb +20 -0
- data/test/renderer_test.rb +21 -0
- metadata +104 -0
@@ -0,0 +1,178 @@
|
|
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::Renderers::JRubyRenderer [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::Renderers::JRubyRenderer</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/renderers_rb.html">
|
57
|
+
|
58
|
+
lib/fractals/renderers.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
|
+
Renders fractals using native Java libraries.
|
80
|
+
</p>
|
81
|
+
|
82
|
+
</div>
|
83
|
+
|
84
|
+
</div>
|
85
|
+
|
86
|
+
|
87
|
+
<div id="method-list">
|
88
|
+
<h3 class="section-bar">Methods</h3>
|
89
|
+
|
90
|
+
<div class="name-list">
|
91
|
+
|
92
|
+
<a href="#M000005">write</a>
|
93
|
+
|
94
|
+
</div>
|
95
|
+
</div>
|
96
|
+
|
97
|
+
</div>
|
98
|
+
|
99
|
+
<!-- if includes -->
|
100
|
+
|
101
|
+
<div id="includes">
|
102
|
+
<h3 class="section-bar">Included Modules</h3>
|
103
|
+
|
104
|
+
<div id="includes-list">
|
105
|
+
|
106
|
+
<span class="include-name">Java</span>
|
107
|
+
|
108
|
+
</div>
|
109
|
+
</div>
|
110
|
+
|
111
|
+
<div id="section">
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
<!-- if method_list -->
|
117
|
+
|
118
|
+
<div id="methods">
|
119
|
+
|
120
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
121
|
+
|
122
|
+
|
123
|
+
<div id="method-M000005" class="method-detail">
|
124
|
+
<a name="M000005"></a>
|
125
|
+
|
126
|
+
<div class="method-heading">
|
127
|
+
|
128
|
+
<a href="#M000005" class="method-signature">
|
129
|
+
|
130
|
+
<span class="method-name">write</span><span class="method-args">(file_path='fractal.png')</span>
|
131
|
+
|
132
|
+
</a>
|
133
|
+
|
134
|
+
</div>
|
135
|
+
|
136
|
+
<div class="method-description">
|
137
|
+
|
138
|
+
<p>
|
139
|
+
Writes the image to the specified file path.
|
140
|
+
</p>
|
141
|
+
|
142
|
+
<p><a class="source-toggle" href="#"
|
143
|
+
onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
|
144
|
+
<div class="method-source-code" id="M000005-source">
|
145
|
+
<pre>
|
146
|
+
<span class="ruby-comment cmt"># File lib/fractals/renderers.rb, line 151</span>
|
147
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">write</span>(<span class="ruby-identifier">file_path</span>=<span class="ruby-value str">'fractal.png'</span>)
|
148
|
+
<span class="ruby-identifier">import</span> <span class="ruby-identifier">java</span>.<span class="ruby-identifier">awt</span>.<span class="ruby-identifier">image</span>.<span class="ruby-constant">BufferedImage</span>
|
149
|
+
<span class="ruby-identifier">import</span> <span class="ruby-identifier">javax</span>.<span class="ruby-identifier">imageio</span>.<span class="ruby-constant">ImageIO</span>
|
150
|
+
|
151
|
+
<span class="ruby-identifier">buffered_image</span> = <span class="ruby-constant">BufferedImage</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@width</span>, <span class="ruby-ivar">@height</span>, <span class="ruby-constant">BufferedImage</span><span class="ruby-operator">::</span><span class="ruby-constant">TYPE_INT_RGB</span>)
|
152
|
+
<span class="ruby-identifier">render</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">x</span>, <span class="ruby-identifier">y</span>, <span class="ruby-identifier">color</span><span class="ruby-operator">|</span>
|
153
|
+
<span class="ruby-identifier">buffered_image</span>.<span class="ruby-identifier">setRGB</span>(<span class="ruby-identifier">x</span>, <span class="ruby-identifier">y</span>, <span class="ruby-identifier">to_rgb</span>(<span class="ruby-identifier">color</span>))
|
154
|
+
<span class="ruby-keyword kw">end</span>
|
155
|
+
|
156
|
+
<span class="ruby-constant">ImageIO</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">buffered_image</span>, <span class="ruby-identifier">file_path</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">'.'</span>).<span class="ruby-identifier">last</span>, <span class="ruby-identifier">java</span>.<span class="ruby-identifier">io</span>.<span class="ruby-constant">File</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">file_path</span>))
|
157
|
+
<span class="ruby-keyword kw">end</span>
|
158
|
+
</pre>
|
159
|
+
</div>
|
160
|
+
|
161
|
+
</div>
|
162
|
+
</div>
|
163
|
+
|
164
|
+
|
165
|
+
|
166
|
+
</div>
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
</div>
|
172
|
+
|
173
|
+
<div id="validator-badges">
|
174
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
175
|
+
</div>
|
176
|
+
|
177
|
+
</body>
|
178
|
+
</html>
|
@@ -0,0 +1,202 @@
|
|
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::Renderers::PNGRenderer [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::Renderers::PNGRenderer</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/renderers_rb.html">
|
57
|
+
|
58
|
+
lib/fractals/renderers.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
|
+
Renders fractals using the PNG library. <a
|
80
|
+
href="PNGRenderer.html">PNGRenderer</a> is the default renderer.
|
81
|
+
</p>
|
82
|
+
|
83
|
+
</div>
|
84
|
+
|
85
|
+
</div>
|
86
|
+
|
87
|
+
|
88
|
+
<div id="method-list">
|
89
|
+
<h3 class="section-bar">Methods</h3>
|
90
|
+
|
91
|
+
<div class="name-list">
|
92
|
+
|
93
|
+
<a href="#M000001">to_blob</a>
|
94
|
+
|
95
|
+
<a href="#M000002">write</a>
|
96
|
+
|
97
|
+
</div>
|
98
|
+
</div>
|
99
|
+
|
100
|
+
</div>
|
101
|
+
|
102
|
+
<!-- if includes -->
|
103
|
+
|
104
|
+
<div id="section">
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
<!-- if method_list -->
|
110
|
+
|
111
|
+
<div id="methods">
|
112
|
+
|
113
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
114
|
+
|
115
|
+
|
116
|
+
<div id="method-M000001" class="method-detail">
|
117
|
+
<a name="M000001"></a>
|
118
|
+
|
119
|
+
<div class="method-heading">
|
120
|
+
|
121
|
+
<a href="#M000001" class="method-signature">
|
122
|
+
|
123
|
+
<span class="method-name">to_blob</span><span class="method-args">()</span>
|
124
|
+
|
125
|
+
</a>
|
126
|
+
|
127
|
+
</div>
|
128
|
+
|
129
|
+
<div class="method-description">
|
130
|
+
|
131
|
+
<p>
|
132
|
+
Returns the fractal image as a BLOB.
|
133
|
+
</p>
|
134
|
+
|
135
|
+
<p><a class="source-toggle" href="#"
|
136
|
+
onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
|
137
|
+
<div class="method-source-code" id="M000001-source">
|
138
|
+
<pre>
|
139
|
+
<span class="ruby-comment cmt"># File lib/fractals/renderers.rb, line 104</span>
|
140
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_blob</span>()
|
141
|
+
<span class="ruby-identifier">canvas</span> = <span class="ruby-constant">PNG</span><span class="ruby-operator">::</span><span class="ruby-constant">Canvas</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@width</span>, <span class="ruby-ivar">@height</span>)
|
142
|
+
<span class="ruby-identifier">render</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">x</span>, <span class="ruby-identifier">y</span>, <span class="ruby-identifier">color</span><span class="ruby-operator">|</span>
|
143
|
+
<span class="ruby-identifier">canvas</span>[<span class="ruby-identifier">x</span>, (<span class="ruby-identifier">y</span> <span class="ruby-operator">-</span> <span class="ruby-ivar">@height</span>).<span class="ruby-identifier">abs</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>] = <span class="ruby-constant">PNG</span><span class="ruby-operator">::</span><span class="ruby-constant">Color</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">color</span>[<span class="ruby-value">0</span>], <span class="ruby-identifier">color</span>[<span class="ruby-value">1</span>], <span class="ruby-identifier">color</span>[<span class="ruby-value">2</span>], <span class="ruby-value">255</span>)
|
144
|
+
<span class="ruby-keyword kw">end</span>
|
145
|
+
|
146
|
+
<span class="ruby-constant">PNG</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">canvas</span>).<span class="ruby-identifier">to_blob</span>
|
147
|
+
<span class="ruby-keyword kw">end</span>
|
148
|
+
</pre>
|
149
|
+
</div>
|
150
|
+
|
151
|
+
</div>
|
152
|
+
</div>
|
153
|
+
|
154
|
+
|
155
|
+
<div id="method-M000002" class="method-detail">
|
156
|
+
<a name="M000002"></a>
|
157
|
+
|
158
|
+
<div class="method-heading">
|
159
|
+
|
160
|
+
<a href="#M000002" class="method-signature">
|
161
|
+
|
162
|
+
<span class="method-name">write</span><span class="method-args">(file_path='fractal.png')</span>
|
163
|
+
|
164
|
+
</a>
|
165
|
+
|
166
|
+
</div>
|
167
|
+
|
168
|
+
<div class="method-description">
|
169
|
+
|
170
|
+
<p>
|
171
|
+
Writes the image to the specifiec file path.
|
172
|
+
</p>
|
173
|
+
|
174
|
+
<p><a class="source-toggle" href="#"
|
175
|
+
onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
|
176
|
+
<div class="method-source-code" id="M000002-source">
|
177
|
+
<pre>
|
178
|
+
<span class="ruby-comment cmt"># File lib/fractals/renderers.rb, line 114</span>
|
179
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">write</span>(<span class="ruby-identifier">file_path</span>=<span class="ruby-value str">'fractal.png'</span>)
|
180
|
+
<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">file_path</span>, <span class="ruby-value str">'wb'</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">file</span><span class="ruby-operator">|</span> <span class="ruby-identifier">file</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">to_blob</span>) }
|
181
|
+
<span class="ruby-keyword kw">end</span>
|
182
|
+
</pre>
|
183
|
+
</div>
|
184
|
+
|
185
|
+
</div>
|
186
|
+
</div>
|
187
|
+
|
188
|
+
|
189
|
+
|
190
|
+
</div>
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
</div>
|
196
|
+
|
197
|
+
<div id="validator-badges">
|
198
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
199
|
+
</div>
|
200
|
+
|
201
|
+
</body>
|
202
|
+
</html>
|
@@ -0,0 +1,210 @@
|
|
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::Renderers::RMagickRenderer [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::Renderers::RMagickRenderer</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/renderers_rb.html">
|
57
|
+
|
58
|
+
lib/fractals/renderers.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
|
+
Renders fractals using the RMagick library.
|
80
|
+
</p>
|
81
|
+
|
82
|
+
</div>
|
83
|
+
|
84
|
+
</div>
|
85
|
+
|
86
|
+
|
87
|
+
<div id="method-list">
|
88
|
+
<h3 class="section-bar">Methods</h3>
|
89
|
+
|
90
|
+
<div class="name-list">
|
91
|
+
|
92
|
+
<a href="#M000003">to_blob</a>
|
93
|
+
|
94
|
+
<a href="#M000004">write</a>
|
95
|
+
|
96
|
+
</div>
|
97
|
+
</div>
|
98
|
+
|
99
|
+
</div>
|
100
|
+
|
101
|
+
<!-- if includes -->
|
102
|
+
|
103
|
+
<div id="section">
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
<!-- if method_list -->
|
109
|
+
|
110
|
+
<div id="methods">
|
111
|
+
|
112
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
113
|
+
|
114
|
+
|
115
|
+
<div id="method-M000003" class="method-detail">
|
116
|
+
<a name="M000003"></a>
|
117
|
+
|
118
|
+
<div class="method-heading">
|
119
|
+
|
120
|
+
<a href="#M000003" class="method-signature">
|
121
|
+
|
122
|
+
<span class="method-name">to_blob</span><span class="method-args">(file_format)</span>
|
123
|
+
|
124
|
+
</a>
|
125
|
+
|
126
|
+
</div>
|
127
|
+
|
128
|
+
<div class="method-description">
|
129
|
+
|
130
|
+
<p>
|
131
|
+
Returns the fractal image as a BLOB of the specified file format.
|
132
|
+
</p>
|
133
|
+
<h1>Example:</h1>
|
134
|
+
<p>
|
135
|
+
mandelbrot = <a href="../Mandelbrot.html#M000016">Mandelbrot.new</a><br />
|
136
|
+
mandelbrot.renderer = Renderers::RMagickRenderer<br /> blob =
|
137
|
+
mandelbrot.<b><a
|
138
|
+
href="RMagickRenderer.html#M000003">to_blob</a>(‘jpg’)</b>
|
139
|
+
</p>
|
140
|
+
|
141
|
+
<p><a class="source-toggle" href="#"
|
142
|
+
onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
|
143
|
+
<div class="method-source-code" id="M000003-source">
|
144
|
+
<pre>
|
145
|
+
<span class="ruby-comment cmt"># File lib/fractals/renderers.rb, line 129</span>
|
146
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_blob</span>(<span class="ruby-identifier">file_format</span>)
|
147
|
+
<span class="ruby-identifier">image</span> = <span class="ruby-constant">Magick</span><span class="ruby-operator">::</span><span class="ruby-constant">Image</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@width</span>, <span class="ruby-ivar">@height</span>)
|
148
|
+
<span class="ruby-identifier">render</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">x</span>, <span class="ruby-identifier">y</span>, <span class="ruby-identifier">color</span><span class="ruby-operator">|</span>
|
149
|
+
<span class="ruby-identifier">image</span>.<span class="ruby-identifier">pixel_color</span>(<span class="ruby-identifier">x</span>, <span class="ruby-identifier">y</span>, <span class="ruby-node">"rgb(#{color.join(',')})"</span>)
|
150
|
+
<span class="ruby-keyword kw">end</span>
|
151
|
+
|
152
|
+
<span class="ruby-identifier">image</span>.<span class="ruby-identifier">to_blob</span> { <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">format</span> = <span class="ruby-identifier">file_format</span>; <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">quality</span> = <span class="ruby-value">100</span> }
|
153
|
+
<span class="ruby-keyword kw">end</span>
|
154
|
+
</pre>
|
155
|
+
</div>
|
156
|
+
|
157
|
+
</div>
|
158
|
+
</div>
|
159
|
+
|
160
|
+
|
161
|
+
<div id="method-M000004" class="method-detail">
|
162
|
+
<a name="M000004"></a>
|
163
|
+
|
164
|
+
<div class="method-heading">
|
165
|
+
|
166
|
+
<a href="#M000004" class="method-signature">
|
167
|
+
|
168
|
+
<span class="method-name">write</span><span class="method-args">(file_path='fractal.png')</span>
|
169
|
+
|
170
|
+
</a>
|
171
|
+
|
172
|
+
</div>
|
173
|
+
|
174
|
+
<div class="method-description">
|
175
|
+
|
176
|
+
<p>
|
177
|
+
Writes the image to the specified file path.
|
178
|
+
</p>
|
179
|
+
|
180
|
+
<p><a class="source-toggle" href="#"
|
181
|
+
onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
|
182
|
+
<div class="method-source-code" id="M000004-source">
|
183
|
+
<pre>
|
184
|
+
<span class="ruby-comment cmt"># File lib/fractals/renderers.rb, line 139</span>
|
185
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">write</span>(<span class="ruby-identifier">file_path</span>=<span class="ruby-value str">'fractal.png'</span>)
|
186
|
+
<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">file_path</span>, <span class="ruby-value str">'wb'</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">file</span><span class="ruby-operator">|</span>
|
187
|
+
<span class="ruby-identifier">file</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">to_blob</span>(<span class="ruby-identifier">file_path</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">'.'</span>).<span class="ruby-identifier">last</span>))
|
188
|
+
<span class="ruby-keyword kw">end</span>
|
189
|
+
<span class="ruby-keyword kw">end</span>
|
190
|
+
</pre>
|
191
|
+
</div>
|
192
|
+
|
193
|
+
</div>
|
194
|
+
</div>
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
</div>
|
199
|
+
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
</div>
|
204
|
+
|
205
|
+
<div id="validator-badges">
|
206
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
207
|
+
</div>
|
208
|
+
|
209
|
+
</body>
|
210
|
+
</html>
|