silicium 0.0.20 → 0.0.21

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +3 -3
  3. data/.gitignore +13 -13
  4. data/.rakeTasks +8 -0
  5. data/.travis.yml +28 -25
  6. data/CODE_OF_CONDUCT.md +74 -74
  7. data/Gemfile +8 -8
  8. data/LICENSE.txt +21 -21
  9. data/Makefile +269 -269
  10. data/README.md +588 -46
  11. data/Rakefile +16 -16
  12. data/bin/console +14 -14
  13. data/bin/setup +8 -8
  14. data/docs/Object.html +117 -117
  15. data/docs/README_md.html +142 -142
  16. data/docs/Silicium/Combinatorics.html +270 -270
  17. data/docs/Silicium/Dice/Polyhedron.html +315 -315
  18. data/docs/Silicium/Dice/PolyhedronSet.html +321 -321
  19. data/docs/Silicium/Dice.html +99 -99
  20. data/docs/Silicium/Error.html +106 -106
  21. data/docs/Silicium/Geometry/Line2dCanon.html +243 -243
  22. data/docs/Silicium/Geometry/VariablesOrderException.html +106 -106
  23. data/docs/Silicium/Geometry.html +940 -940
  24. data/docs/Silicium/GraphVisualizer.html +226 -0
  25. data/docs/Silicium/Graphs/GraphError.html +106 -106
  26. data/docs/Silicium/Graphs/OrientedGraph.html +901 -775
  27. data/docs/Silicium/Graphs/UnorientedGraph.html +237 -284
  28. data/docs/Silicium/Graphs.html +374 -164
  29. data/docs/Silicium/IntegralDoesntExistError.html +106 -106
  30. data/docs/Silicium/NumericalIntegration.html +521 -521
  31. data/docs/Silicium/Optimization.html +629 -639
  32. data/docs/Silicium/Plotter/Image.html +297 -297
  33. data/docs/Silicium/Plotter.html +186 -186
  34. data/docs/Silicium.html +101 -101
  35. data/docs/created.rid +9 -9
  36. data/docs/css/fonts.css +167 -167
  37. data/docs/css/rdoc.css +619 -619
  38. data/docs/index.html +134 -132
  39. data/docs/js/darkfish.js +84 -84
  40. data/docs/js/navigation.js +105 -105
  41. data/docs/js/search.js +110 -110
  42. data/docs/js/search_index.js +1 -1
  43. data/docs/js/search_index.js.gz +0 -0
  44. data/docs/js/searcher.js +229 -229
  45. data/docs/table_of_contents.html +697 -608
  46. data/lib/algebra.rb +452 -0
  47. data/lib/algebra_diff.rb +258 -0
  48. data/lib/geometry/figure.rb +62 -0
  49. data/lib/geometry.rb +290 -236
  50. data/lib/geometry3d.rb +270 -0
  51. data/lib/graph/dfs.rb +42 -0
  52. data/lib/graph/kruskal.rb +36 -0
  53. data/lib/graph/scc.rb +97 -0
  54. data/lib/graph.rb +350 -164
  55. data/lib/graph_visualizer.rb +287 -0
  56. data/lib/ml_algorithms.rb +181 -0
  57. data/lib/numerical_integration.rb +184 -147
  58. data/lib/optimization.rb +209 -144
  59. data/lib/plotter.rb +256 -96
  60. data/lib/polynomial_division.rb +132 -0
  61. data/lib/polynomial_interpolation.rb +94 -0
  62. data/lib/regression.rb +120 -0
  63. data/lib/silicium/adding.rb +37 -0
  64. data/lib/silicium/conversions.rb +23 -0
  65. data/lib/silicium/multi.rb +82 -0
  66. data/lib/silicium/sparse.rb +76 -0
  67. data/lib/silicium/sugar.rb +37 -0
  68. data/lib/silicium/trans.rb +26 -0
  69. data/lib/silicium/version.rb +3 -3
  70. data/lib/silicium.rb +5 -5
  71. data/lib/theory_of_probability.rb +240 -226
  72. data/lib/topological_sort.rb +50 -0
  73. data/oriented_graph.png +0 -0
  74. data/plot.png +0 -0
  75. data/silicium.gemspec +38 -39
  76. metadata +38 -16
@@ -1,297 +1,297 @@
1
- <!DOCTYPE html>
2
-
3
- <html>
4
- <head>
5
- <meta charset="UTF-8">
6
-
7
- <title>class Silicium::Plotter::Image - RDoc Documentation</title>
8
-
9
- <script type="text/javascript">
10
- var rdoc_rel_prefix = "../../";
11
- var index_rel_prefix = "../../";
12
- </script>
13
-
14
- <script src="../../js/navigation.js" defer></script>
15
- <script src="../../js/search.js" defer></script>
16
- <script src="../../js/search_index.js" defer></script>
17
- <script src="../../js/searcher.js" defer></script>
18
- <script src="../../js/darkfish.js" defer></script>
19
-
20
- <link href="../../css/fonts.css" rel="stylesheet">
21
- <link href="../../css/rdoc.css" rel="stylesheet">
22
-
23
-
24
-
25
-
26
- <body id="top" role="document" class="class">
27
- <nav role="navigation">
28
- <div id="project-navigation">
29
- <div id="home-section" role="region" title="Quick navigation" class="nav-section">
30
- <h2>
31
- <a href="../../index.html" rel="home">Home</a>
32
- </h2>
33
-
34
- <div id="table-of-contents-navigation">
35
- <a href="../../table_of_contents.html#pages">Pages</a>
36
- <a href="../../table_of_contents.html#classes">Classes</a>
37
- <a href="../../table_of_contents.html#methods">Methods</a>
38
- </div>
39
- </div>
40
-
41
- <div id="search-section" role="search" class="project-section initially-hidden">
42
- <form action="#" method="get" accept-charset="utf-8">
43
- <div id="search-field-wrapper">
44
- <input id="search-field" role="combobox" aria-label="Search"
45
- aria-autocomplete="list" aria-controls="search-results"
46
- type="text" name="search" placeholder="Search" spellcheck="false"
47
- title="Type to search, Up and Down to navigate, Enter to load">
48
- </div>
49
-
50
- <ul id="search-results" aria-label="Search Results"
51
- aria-busy="false" aria-expanded="false"
52
- aria-atomic="false" class="initially-hidden"></ul>
53
- </form>
54
- </div>
55
-
56
- </div>
57
-
58
-
59
-
60
- <div id="class-metadata">
61
-
62
- <div id="parent-class-section" class="nav-section">
63
- <h3>Parent</h3>
64
-
65
-
66
- <p class="link"><a href="../../Object.html">Object</a>
67
-
68
- </div>
69
-
70
-
71
-
72
- <!-- Method Quickref -->
73
- <div id="method-list-section" class="nav-section">
74
- <h3>Methods</h3>
75
-
76
- <ul class="link-list" role="directory">
77
-
78
- <li ><a href="#method-c-new">::new</a>
79
-
80
- <li ><a href="#method-i-bar_chart">#bar_chart</a>
81
-
82
- <li ><a href="#method-i-export">#export</a>
83
-
84
- <li ><a href="#method-i-rectangle">#rectangle</a>
85
-
86
- </ul>
87
- </div>
88
-
89
- </div>
90
- </nav>
91
-
92
- <main role="main" aria-labelledby="class-Silicium::Plotter::Image">
93
- <h1 id="class-Silicium::Plotter::Image" class="class">
94
- class Silicium::Plotter::Image
95
- </h1>
96
-
97
- <section class="description">
98
-
99
- <p>A class representing canvas for plotting bar charts and function graphs</p>
100
-
101
- </section>
102
-
103
-
104
- <section id="5Buntitled-5D" class="documentation-section">
105
-
106
-
107
-
108
-
109
-
110
-
111
-
112
-
113
-
114
- <section id="public-class-5Buntitled-5D-method-details" class="method-section">
115
- <header>
116
- <h3>Public Class Methods</h3>
117
- </header>
118
-
119
-
120
- <div id="method-c-new" class="method-detail ">
121
-
122
- <div class="method-heading">
123
- <span class="method-name">new</span><span
124
- class="method-args">(width, height, bg_color = ChunkyPNG::Color::TRANSPARENT)</span>
125
-
126
- <span class="method-click-advice">click to toggle source</span>
127
-
128
- </div>
129
-
130
-
131
- <div class="method-description">
132
-
133
- <p>Creates a new plot with chosen <code>width</code> and <code>height</code> parameters with background colored <code>bg_color</code></p>
134
-
135
-
136
-
137
-
138
- <div class="method-source-code" id="new-source">
139
- <pre><span class="ruby-comment"># File lib/plotter.rb, line 49</span>
140
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-identifier">width</span>, <span class="ruby-identifier">height</span>, <span class="ruby-identifier">bg_color</span> = <span class="ruby-constant">ChunkyPNG</span><span class="ruby-operator">::</span><span class="ruby-constant">Color</span><span class="ruby-operator">::</span><span class="ruby-constant">TRANSPARENT</span>)
141
- <span class="ruby-ivar">@image</span> = <span class="ruby-constant">ChunkyPNG</span><span class="ruby-operator">::</span><span class="ruby-constant">Image</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">width</span>, <span class="ruby-identifier">height</span>, <span class="ruby-identifier">bg_color</span>)
142
- <span class="ruby-keyword">end</span></pre>
143
- </div>
144
-
145
- </div>
146
-
147
-
148
-
149
-
150
- </div>
151
-
152
-
153
- </section>
154
-
155
- <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
156
- <header>
157
- <h3>Public Instance Methods</h3>
158
- </header>
159
-
160
-
161
- <div id="method-i-bar_chart" class="method-detail ">
162
-
163
- <div class="method-heading">
164
- <span class="method-name">bar_chart</span><span
165
- class="method-args">(bars, bar_width, bars_color = ChunkyPNG::Color(&#39;red @ 1.0&#39;), axis_color = ChunkyPNG::Color::BLACK)</span>
166
-
167
- <span class="method-click-advice">click to toggle source</span>
168
-
169
- </div>
170
-
171
-
172
- <div class="method-description">
173
-
174
- <p>Draws a bar chart in the plot using provided <code>bars</code>, each of them has width of <code>bar_width</code> and colored <code>bars_color</code></p>
175
-
176
-
177
-
178
-
179
- <div class="method-source-code" id="bar_chart-source">
180
- <pre><span class="ruby-comment"># File lib/plotter.rb, line 66</span>
181
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">bar_chart</span>(<span class="ruby-identifier">bars</span>, <span class="ruby-identifier">bar_width</span>, <span class="ruby-identifier">bars_color</span> = <span class="ruby-constant">ChunkyPNG</span><span class="ruby-operator">::</span><span class="ruby-constant">Color</span>(<span class="ruby-string">&#39;red @ 1.0&#39;</span>), <span class="ruby-identifier">axis_color</span> = <span class="ruby-constant">ChunkyPNG</span><span class="ruby-operator">::</span><span class="ruby-constant">Color</span><span class="ruby-operator">::</span><span class="ruby-constant">BLACK</span>)
182
- <span class="ruby-keyword">if</span> <span class="ruby-identifier">bars</span>.<span class="ruby-identifier">count</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">bar_width</span> <span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@image</span>.<span class="ruby-identifier">width</span>
183
- <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-string">&#39;Not enough big size of image to plot these number of bars&#39;</span>
184
- <span class="ruby-keyword">end</span>
185
-
186
- <span class="ruby-identifier">padding</span> = <span class="ruby-value">5</span>
187
- <span class="ruby-comment"># Values of x and y on borders of plot</span>
188
- <span class="ruby-identifier">minx</span> = [<span class="ruby-identifier">bars</span>.<span class="ruby-identifier">collect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>, <span class="ruby-identifier">_</span><span class="ruby-operator">|</span> <span class="ruby-identifier">k</span> }.<span class="ruby-identifier">min</span>, <span class="ruby-value">0</span>].<span class="ruby-identifier">min</span>
189
- <span class="ruby-identifier">maxx</span> = [<span class="ruby-identifier">bars</span>.<span class="ruby-identifier">collect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>, <span class="ruby-identifier">_</span><span class="ruby-operator">|</span> <span class="ruby-identifier">k</span> }.<span class="ruby-identifier">max</span>, <span class="ruby-value">0</span>].<span class="ruby-identifier">max</span>
190
- <span class="ruby-identifier">miny</span> = [<span class="ruby-identifier">bars</span>.<span class="ruby-identifier">collect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">_</span>, <span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">v</span> }.<span class="ruby-identifier">min</span>, <span class="ruby-value">0</span>].<span class="ruby-identifier">min</span>
191
- <span class="ruby-identifier">maxy</span> = [<span class="ruby-identifier">bars</span>.<span class="ruby-identifier">collect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">_</span>, <span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">v</span> }.<span class="ruby-identifier">max</span>, <span class="ruby-value">0</span>].<span class="ruby-identifier">max</span>
192
- <span class="ruby-identifier">dpux</span> = <span class="ruby-constant">Float</span>((<span class="ruby-ivar">@image</span>.<span class="ruby-identifier">width</span> <span class="ruby-operator">-</span> <span class="ruby-value">2</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">padding</span>)) <span class="ruby-operator">/</span> (<span class="ruby-identifier">maxx</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">minx</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">bar_width</span>) <span class="ruby-comment"># Dots per unit for X</span>
193
- <span class="ruby-identifier">dpuy</span> = <span class="ruby-constant">Float</span>((<span class="ruby-ivar">@image</span>.<span class="ruby-identifier">height</span> <span class="ruby-operator">-</span> <span class="ruby-value">2</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">padding</span>)) <span class="ruby-operator">/</span> (<span class="ruby-identifier">maxy</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">miny</span>) <span class="ruby-comment"># Dots per unit for Y</span>
194
- <span class="ruby-identifier">rectangle</span>(<span class="ruby-identifier">padding</span>, <span class="ruby-ivar">@image</span>.<span class="ruby-identifier">height</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">padding</span> <span class="ruby-operator">-</span> (<span class="ruby-identifier">miny</span>.<span class="ruby-identifier">abs</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">dpuy</span>).<span class="ruby-identifier">ceil</span>, <span class="ruby-ivar">@image</span>.<span class="ruby-identifier">width</span> <span class="ruby-operator">-</span> <span class="ruby-value">2</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">padding</span>, <span class="ruby-value">1</span>, <span class="ruby-identifier">axis_color</span>) <span class="ruby-comment"># Axis OX</span>
195
- <span class="ruby-identifier">rectangle</span>(<span class="ruby-identifier">padding</span> <span class="ruby-operator">+</span> (<span class="ruby-identifier">minx</span>.<span class="ruby-identifier">abs</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">dpux</span>).<span class="ruby-identifier">ceil</span>, <span class="ruby-identifier">padding</span>, <span class="ruby-value">1</span>, <span class="ruby-ivar">@image</span>.<span class="ruby-identifier">height</span> <span class="ruby-operator">-</span> <span class="ruby-value">2</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">padding</span>, <span class="ruby-identifier">axis_color</span>) <span class="ruby-comment"># Axis OY</span>
196
-
197
- <span class="ruby-identifier">bars</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">x</span>, <span class="ruby-identifier">y</span><span class="ruby-operator">|</span> <span class="ruby-comment"># Cycle drawing bars</span>
198
- <span class="ruby-identifier">rectangle</span>(<span class="ruby-identifier">padding</span> <span class="ruby-operator">+</span> ((<span class="ruby-identifier">x</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">minx</span>.<span class="ruby-identifier">abs</span>) <span class="ruby-operator">*</span> <span class="ruby-identifier">dpux</span>).<span class="ruby-identifier">floor</span>,
199
- <span class="ruby-ivar">@image</span>.<span class="ruby-identifier">height</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">padding</span> <span class="ruby-operator">-</span> (([<span class="ruby-identifier">y</span>, <span class="ruby-value">0</span>].<span class="ruby-identifier">max</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">miny</span>.<span class="ruby-identifier">abs</span>) <span class="ruby-operator">*</span> <span class="ruby-identifier">dpuy</span>).<span class="ruby-identifier">ceil</span> <span class="ruby-operator">+</span> (<span class="ruby-identifier">y</span>.<span class="ruby-identifier">negative?</span> <span class="ruby-operator">?</span> <span class="ruby-value">1</span> <span class="ruby-operator">:</span> <span class="ruby-value">0</span>),
200
- <span class="ruby-identifier">bar_width</span>, (<span class="ruby-identifier">y</span>.<span class="ruby-identifier">abs</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">dpuy</span>).<span class="ruby-identifier">ceil</span>, <span class="ruby-identifier">bars_color</span>)
201
- <span class="ruby-keyword">end</span>
202
- <span class="ruby-keyword">end</span></pre>
203
- </div>
204
-
205
- </div>
206
-
207
-
208
-
209
-
210
- </div>
211
-
212
-
213
- <div id="method-i-export" class="method-detail ">
214
-
215
- <div class="method-heading">
216
- <span class="method-name">export</span><span
217
- class="method-args">(filename)</span>
218
-
219
- <span class="method-click-advice">click to toggle source</span>
220
-
221
- </div>
222
-
223
-
224
- <div class="method-description">
225
-
226
- <p>Exports plotted image to file <code>filename</code></p>
227
-
228
-
229
-
230
-
231
- <div class="method-source-code" id="export-source">
232
- <pre><span class="ruby-comment"># File lib/plotter.rb, line 91</span>
233
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">export</span>(<span class="ruby-identifier">filename</span>)
234
- <span class="ruby-ivar">@image</span>.<span class="ruby-identifier">save</span>(<span class="ruby-identifier">filename</span>, <span class="ruby-value">:interlace</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-keyword">true</span>)
235
- <span class="ruby-keyword">end</span></pre>
236
- </div>
237
-
238
- </div>
239
-
240
-
241
-
242
-
243
- </div>
244
-
245
-
246
- <div id="method-i-rectangle" class="method-detail ">
247
-
248
- <div class="method-heading">
249
- <span class="method-name">rectangle</span><span
250
- class="method-args">(x, y, width, height, color)</span>
251
-
252
- <span class="method-click-advice">click to toggle source</span>
253
-
254
- </div>
255
-
256
-
257
- <div class="method-description">
258
-
259
-
260
-
261
-
262
-
263
-
264
- <div class="method-source-code" id="rectangle-source">
265
- <pre><span class="ruby-comment"># File lib/plotter.rb, line 53</span>
266
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">rectangle</span>(<span class="ruby-identifier">x</span>, <span class="ruby-identifier">y</span>, <span class="ruby-identifier">width</span>, <span class="ruby-identifier">height</span>, <span class="ruby-identifier">color</span>)
267
- <span class="ruby-identifier">x_end</span> = <span class="ruby-identifier">x</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">width</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>
268
- <span class="ruby-identifier">y_end</span> = <span class="ruby-identifier">y</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">height</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>
269
- (<span class="ruby-identifier">x</span><span class="ruby-operator">..</span><span class="ruby-identifier">x_end</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
270
- (<span class="ruby-identifier">y</span><span class="ruby-operator">..</span><span class="ruby-identifier">y_end</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">j</span><span class="ruby-operator">|</span>
271
- <span class="ruby-ivar">@image</span>[<span class="ruby-identifier">i</span>, <span class="ruby-identifier">j</span>] = <span class="ruby-identifier">color</span>
272
- <span class="ruby-keyword">end</span>
273
- <span class="ruby-keyword">end</span>
274
- <span class="ruby-keyword">end</span></pre>
275
- </div>
276
-
277
- </div>
278
-
279
-
280
-
281
-
282
- </div>
283
-
284
-
285
- </section>
286
-
287
- </section>
288
-
289
- </main>
290
-
291
-
292
- <footer id="validator-badges" role="contentinfo">
293
- <p><a href="https://validator.w3.org/check/referer">Validate</a>
294
- <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.2.0.
295
- <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
296
- </footer>
297
-
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <meta charset="UTF-8">
6
+
7
+ <title>class Silicium::Plotter::Image - RDoc Documentation</title>
8
+
9
+ <script type="text/javascript">
10
+ var rdoc_rel_prefix = "../../";
11
+ var index_rel_prefix = "../../";
12
+ </script>
13
+
14
+ <script src="../../js/navigation.js" defer></script>
15
+ <script src="../../js/search.js" defer></script>
16
+ <script src="../../js/search_index.js" defer></script>
17
+ <script src="../../js/searcher.js" defer></script>
18
+ <script src="../../js/darkfish.js" defer></script>
19
+
20
+ <link href="../../css/fonts.css" rel="stylesheet">
21
+ <link href="../../css/rdoc.css" rel="stylesheet">
22
+
23
+
24
+
25
+
26
+ <body id="top" role="document" class="class">
27
+ <nav role="navigation">
28
+ <div id="project-navigation">
29
+ <div id="home-section" role="region" title="Quick navigation" class="nav-section">
30
+ <h2>
31
+ <a href="../../index.html" rel="home">Home</a>
32
+ </h2>
33
+
34
+ <div id="table-of-contents-navigation">
35
+ <a href="../../table_of_contents.html#pages">Pages</a>
36
+ <a href="../../table_of_contents.html#classes">Classes</a>
37
+ <a href="../../table_of_contents.html#methods">Methods</a>
38
+ </div>
39
+ </div>
40
+
41
+ <div id="search-section" role="search" class="project-section initially-hidden">
42
+ <form action="#" method="get" accept-charset="utf-8">
43
+ <div id="search-field-wrapper">
44
+ <input id="search-field" role="combobox" aria-label="Search"
45
+ aria-autocomplete="list" aria-controls="search-results"
46
+ type="text" name="search" placeholder="Search" spellcheck="false"
47
+ title="Type to search, Up and Down to navigate, Enter to load">
48
+ </div>
49
+
50
+ <ul id="search-results" aria-label="Search Results"
51
+ aria-busy="false" aria-expanded="false"
52
+ aria-atomic="false" class="initially-hidden"></ul>
53
+ </form>
54
+ </div>
55
+
56
+ </div>
57
+
58
+
59
+
60
+ <div id="class-metadata">
61
+
62
+ <div id="parent-class-section" class="nav-section">
63
+ <h3>Parent</h3>
64
+
65
+
66
+ <p class="link"><a href="../../Object.html">Object</a>
67
+
68
+ </div>
69
+
70
+
71
+
72
+ <!-- Method Quickref -->
73
+ <div id="method-list-section" class="nav-section">
74
+ <h3>Methods</h3>
75
+
76
+ <ul class="link-list" role="directory">
77
+
78
+ <li ><a href="#method-c-new">::new</a>
79
+
80
+ <li ><a href="#method-i-bar_chart">#bar_chart</a>
81
+
82
+ <li ><a href="#method-i-export">#export</a>
83
+
84
+ <li ><a href="#method-i-rectangle">#rectangle</a>
85
+
86
+ </ul>
87
+ </div>
88
+
89
+ </div>
90
+ </nav>
91
+
92
+ <main role="main" aria-labelledby="class-Silicium::Plotter::Image">
93
+ <h1 id="class-Silicium::Plotter::Image" class="class">
94
+ class Silicium::Plotter::Image
95
+ </h1>
96
+
97
+ <section class="description">
98
+
99
+ <p>A class representing canvas for plotting bar charts and function graphs</p>
100
+
101
+ </section>
102
+
103
+
104
+ <section id="5Buntitled-5D" class="documentation-section">
105
+
106
+
107
+
108
+
109
+
110
+
111
+
112
+
113
+
114
+ <section id="public-class-5Buntitled-5D-method-details" class="method-section">
115
+ <header>
116
+ <h3>Public Class Methods</h3>
117
+ </header>
118
+
119
+
120
+ <div id="method-c-new" class="method-detail ">
121
+
122
+ <div class="method-heading">
123
+ <span class="method-name">new</span><span
124
+ class="method-args">(width, height, bg_color = ChunkyPNG::Color::TRANSPARENT)</span>
125
+
126
+ <span class="method-click-advice">click to toggle source</span>
127
+
128
+ </div>
129
+
130
+
131
+ <div class="method-description">
132
+
133
+ <p>Creates a new plot with chosen <code>width</code> and <code>height</code> parameters with background colored <code>bg_color</code></p>
134
+
135
+
136
+
137
+
138
+ <div class="method-source-code" id="new-source">
139
+ <pre><span class="ruby-comment"># File lib/plotter.rb, line 49</span>
140
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-identifier">width</span>, <span class="ruby-identifier">height</span>, <span class="ruby-identifier">bg_color</span> = <span class="ruby-constant">ChunkyPNG</span><span class="ruby-operator">::</span><span class="ruby-constant">Color</span><span class="ruby-operator">::</span><span class="ruby-constant">TRANSPARENT</span>)
141
+ <span class="ruby-ivar">@image</span> = <span class="ruby-constant">ChunkyPNG</span><span class="ruby-operator">::</span><span class="ruby-constant">Image</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">width</span>, <span class="ruby-identifier">height</span>, <span class="ruby-identifier">bg_color</span>)
142
+ <span class="ruby-keyword">end</span></pre>
143
+ </div>
144
+
145
+ </div>
146
+
147
+
148
+
149
+
150
+ </div>
151
+
152
+
153
+ </section>
154
+
155
+ <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
156
+ <header>
157
+ <h3>Public Instance Methods</h3>
158
+ </header>
159
+
160
+
161
+ <div id="method-i-bar_chart" class="method-detail ">
162
+
163
+ <div class="method-heading">
164
+ <span class="method-name">bar_chart</span><span
165
+ class="method-args">(bars, bar_width, bars_color = ChunkyPNG::Color(&#39;red @ 1.0&#39;), axis_color = ChunkyPNG::Color::BLACK)</span>
166
+
167
+ <span class="method-click-advice">click to toggle source</span>
168
+
169
+ </div>
170
+
171
+
172
+ <div class="method-description">
173
+
174
+ <p>Draws a bar chart in the plot using provided <code>bars</code>, each of them has width of <code>bar_width</code> and colored <code>bars_color</code></p>
175
+
176
+
177
+
178
+
179
+ <div class="method-source-code" id="bar_chart-source">
180
+ <pre><span class="ruby-comment"># File lib/plotter.rb, line 66</span>
181
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">bar_chart</span>(<span class="ruby-identifier">bars</span>, <span class="ruby-identifier">bar_width</span>, <span class="ruby-identifier">bars_color</span> = <span class="ruby-constant">ChunkyPNG</span><span class="ruby-operator">::</span><span class="ruby-constant">Color</span>(<span class="ruby-string">&#39;red @ 1.0&#39;</span>), <span class="ruby-identifier">axis_color</span> = <span class="ruby-constant">ChunkyPNG</span><span class="ruby-operator">::</span><span class="ruby-constant">Color</span><span class="ruby-operator">::</span><span class="ruby-constant">BLACK</span>)
182
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">bars</span>.<span class="ruby-identifier">count</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">bar_width</span> <span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@image</span>.<span class="ruby-identifier">width</span>
183
+ <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-string">&#39;Not enough big size of image to plot these number of bars&#39;</span>
184
+ <span class="ruby-keyword">end</span>
185
+
186
+ <span class="ruby-identifier">padding</span> = <span class="ruby-value">5</span>
187
+ <span class="ruby-comment"># Values of x and y on borders of plot</span>
188
+ <span class="ruby-identifier">minx</span> = [<span class="ruby-identifier">bars</span>.<span class="ruby-identifier">collect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>, <span class="ruby-identifier">_</span><span class="ruby-operator">|</span> <span class="ruby-identifier">k</span> }.<span class="ruby-identifier">min</span>, <span class="ruby-value">0</span>].<span class="ruby-identifier">min</span>
189
+ <span class="ruby-identifier">maxx</span> = [<span class="ruby-identifier">bars</span>.<span class="ruby-identifier">collect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>, <span class="ruby-identifier">_</span><span class="ruby-operator">|</span> <span class="ruby-identifier">k</span> }.<span class="ruby-identifier">max</span>, <span class="ruby-value">0</span>].<span class="ruby-identifier">max</span>
190
+ <span class="ruby-identifier">miny</span> = [<span class="ruby-identifier">bars</span>.<span class="ruby-identifier">collect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">_</span>, <span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">v</span> }.<span class="ruby-identifier">min</span>, <span class="ruby-value">0</span>].<span class="ruby-identifier">min</span>
191
+ <span class="ruby-identifier">maxy</span> = [<span class="ruby-identifier">bars</span>.<span class="ruby-identifier">collect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">_</span>, <span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">v</span> }.<span class="ruby-identifier">max</span>, <span class="ruby-value">0</span>].<span class="ruby-identifier">max</span>
192
+ <span class="ruby-identifier">dpux</span> = <span class="ruby-constant">Float</span>((<span class="ruby-ivar">@image</span>.<span class="ruby-identifier">width</span> <span class="ruby-operator">-</span> <span class="ruby-value">2</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">padding</span>)) <span class="ruby-operator">/</span> (<span class="ruby-identifier">maxx</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">minx</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">bar_width</span>) <span class="ruby-comment"># Dots per unit for X</span>
193
+ <span class="ruby-identifier">dpuy</span> = <span class="ruby-constant">Float</span>((<span class="ruby-ivar">@image</span>.<span class="ruby-identifier">height</span> <span class="ruby-operator">-</span> <span class="ruby-value">2</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">padding</span>)) <span class="ruby-operator">/</span> (<span class="ruby-identifier">maxy</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">miny</span>) <span class="ruby-comment"># Dots per unit for Y</span>
194
+ <span class="ruby-identifier">rectangle</span>(<span class="ruby-identifier">padding</span>, <span class="ruby-ivar">@image</span>.<span class="ruby-identifier">height</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">padding</span> <span class="ruby-operator">-</span> (<span class="ruby-identifier">miny</span>.<span class="ruby-identifier">abs</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">dpuy</span>).<span class="ruby-identifier">ceil</span>, <span class="ruby-ivar">@image</span>.<span class="ruby-identifier">width</span> <span class="ruby-operator">-</span> <span class="ruby-value">2</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">padding</span>, <span class="ruby-value">1</span>, <span class="ruby-identifier">axis_color</span>) <span class="ruby-comment"># Axis OX</span>
195
+ <span class="ruby-identifier">rectangle</span>(<span class="ruby-identifier">padding</span> <span class="ruby-operator">+</span> (<span class="ruby-identifier">minx</span>.<span class="ruby-identifier">abs</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">dpux</span>).<span class="ruby-identifier">ceil</span>, <span class="ruby-identifier">padding</span>, <span class="ruby-value">1</span>, <span class="ruby-ivar">@image</span>.<span class="ruby-identifier">height</span> <span class="ruby-operator">-</span> <span class="ruby-value">2</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">padding</span>, <span class="ruby-identifier">axis_color</span>) <span class="ruby-comment"># Axis OY</span>
196
+
197
+ <span class="ruby-identifier">bars</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">x</span>, <span class="ruby-identifier">y</span><span class="ruby-operator">|</span> <span class="ruby-comment"># Cycle drawing bars</span>
198
+ <span class="ruby-identifier">rectangle</span>(<span class="ruby-identifier">padding</span> <span class="ruby-operator">+</span> ((<span class="ruby-identifier">x</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">minx</span>.<span class="ruby-identifier">abs</span>) <span class="ruby-operator">*</span> <span class="ruby-identifier">dpux</span>).<span class="ruby-identifier">floor</span>,
199
+ <span class="ruby-ivar">@image</span>.<span class="ruby-identifier">height</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">padding</span> <span class="ruby-operator">-</span> (([<span class="ruby-identifier">y</span>, <span class="ruby-value">0</span>].<span class="ruby-identifier">max</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">miny</span>.<span class="ruby-identifier">abs</span>) <span class="ruby-operator">*</span> <span class="ruby-identifier">dpuy</span>).<span class="ruby-identifier">ceil</span> <span class="ruby-operator">+</span> (<span class="ruby-identifier">y</span>.<span class="ruby-identifier">negative?</span> <span class="ruby-operator">?</span> <span class="ruby-value">1</span> <span class="ruby-operator">:</span> <span class="ruby-value">0</span>),
200
+ <span class="ruby-identifier">bar_width</span>, (<span class="ruby-identifier">y</span>.<span class="ruby-identifier">abs</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">dpuy</span>).<span class="ruby-identifier">ceil</span>, <span class="ruby-identifier">bars_color</span>)
201
+ <span class="ruby-keyword">end</span>
202
+ <span class="ruby-keyword">end</span></pre>
203
+ </div>
204
+
205
+ </div>
206
+
207
+
208
+
209
+
210
+ </div>
211
+
212
+
213
+ <div id="method-i-export" class="method-detail ">
214
+
215
+ <div class="method-heading">
216
+ <span class="method-name">export</span><span
217
+ class="method-args">(filename)</span>
218
+
219
+ <span class="method-click-advice">click to toggle source</span>
220
+
221
+ </div>
222
+
223
+
224
+ <div class="method-description">
225
+
226
+ <p>Exports plotted image to file <code>filename</code></p>
227
+
228
+
229
+
230
+
231
+ <div class="method-source-code" id="export-source">
232
+ <pre><span class="ruby-comment"># File lib/plotter.rb, line 91</span>
233
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">export</span>(<span class="ruby-identifier">filename</span>)
234
+ <span class="ruby-ivar">@image</span>.<span class="ruby-identifier">save</span>(<span class="ruby-identifier">filename</span>, <span class="ruby-value">:interlace</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-keyword">true</span>)
235
+ <span class="ruby-keyword">end</span></pre>
236
+ </div>
237
+
238
+ </div>
239
+
240
+
241
+
242
+
243
+ </div>
244
+
245
+
246
+ <div id="method-i-rectangle" class="method-detail ">
247
+
248
+ <div class="method-heading">
249
+ <span class="method-name">rectangle</span><span
250
+ class="method-args">(x, y, width, height, color)</span>
251
+
252
+ <span class="method-click-advice">click to toggle source</span>
253
+
254
+ </div>
255
+
256
+
257
+ <div class="method-description">
258
+
259
+
260
+
261
+
262
+
263
+
264
+ <div class="method-source-code" id="rectangle-source">
265
+ <pre><span class="ruby-comment"># File lib/plotter.rb, line 53</span>
266
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">rectangle</span>(<span class="ruby-identifier">x</span>, <span class="ruby-identifier">y</span>, <span class="ruby-identifier">width</span>, <span class="ruby-identifier">height</span>, <span class="ruby-identifier">color</span>)
267
+ <span class="ruby-identifier">x_end</span> = <span class="ruby-identifier">x</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">width</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>
268
+ <span class="ruby-identifier">y_end</span> = <span class="ruby-identifier">y</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">height</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>
269
+ (<span class="ruby-identifier">x</span><span class="ruby-operator">..</span><span class="ruby-identifier">x_end</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
270
+ (<span class="ruby-identifier">y</span><span class="ruby-operator">..</span><span class="ruby-identifier">y_end</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">j</span><span class="ruby-operator">|</span>
271
+ <span class="ruby-ivar">@image</span>[<span class="ruby-identifier">i</span>, <span class="ruby-identifier">j</span>] = <span class="ruby-identifier">color</span>
272
+ <span class="ruby-keyword">end</span>
273
+ <span class="ruby-keyword">end</span>
274
+ <span class="ruby-keyword">end</span></pre>
275
+ </div>
276
+
277
+ </div>
278
+
279
+
280
+
281
+
282
+ </div>
283
+
284
+
285
+ </section>
286
+
287
+ </section>
288
+
289
+ </main>
290
+
291
+
292
+ <footer id="validator-badges" role="contentinfo">
293
+ <p><a href="https://validator.w3.org/check/referer">Validate</a>
294
+ <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.2.0.
295
+ <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
296
+ </footer>
297
+