silicium 0.0.15 → 0.0.20
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.
- checksums.yaml +4 -4
- data/.codeclimate.yml +4 -0
- data/.gitignore +3 -1
- data/.travis.yml +12 -1
- data/Gemfile +4 -0
- data/Makefile +269 -0
- data/README.md +2 -0
- data/Rakefile +7 -0
- data/docs/Object.html +117 -0
- data/docs/README_md.html +142 -0
- data/docs/Silicium.html +101 -0
- data/docs/Silicium/Combinatorics.html +270 -0
- data/docs/Silicium/Dice.html +99 -0
- data/docs/Silicium/Dice/Polyhedron.html +315 -0
- data/docs/Silicium/Dice/PolyhedronSet.html +321 -0
- data/docs/Silicium/Error.html +106 -0
- data/docs/Silicium/Geometry.html +940 -0
- data/docs/Silicium/Geometry/Line2dCanon.html +243 -0
- data/docs/Silicium/Geometry/VariablesOrderException.html +106 -0
- data/docs/Silicium/Graphs.html +164 -0
- data/docs/Silicium/Graphs/GraphError.html +106 -0
- data/docs/Silicium/Graphs/OrientedGraph.html +775 -0
- data/docs/Silicium/Graphs/UnorientedGraph.html +284 -0
- data/docs/Silicium/IntegralDoesntExistError.html +106 -0
- data/docs/Silicium/NumericalIntegration.html +521 -0
- data/docs/Silicium/Optimization.html +639 -0
- data/docs/Silicium/Plotter.html +186 -0
- data/docs/Silicium/Plotter/Image.html +297 -0
- data/docs/created.rid +9 -0
- data/docs/css/fonts.css +167 -0
- data/docs/css/rdoc.css +619 -0
- data/docs/fonts/Lato-Light.ttf +0 -0
- data/docs/fonts/Lato-LightItalic.ttf +0 -0
- data/docs/fonts/Lato-Regular.ttf +0 -0
- data/docs/fonts/Lato-RegularItalic.ttf +0 -0
- data/docs/fonts/SourceCodePro-Bold.ttf +0 -0
- data/docs/fonts/SourceCodePro-Regular.ttf +0 -0
- data/docs/images/add.png +0 -0
- data/docs/images/arrow_up.png +0 -0
- data/docs/images/brick.png +0 -0
- data/docs/images/brick_link.png +0 -0
- data/docs/images/bug.png +0 -0
- data/docs/images/bullet_black.png +0 -0
- data/docs/images/bullet_toggle_minus.png +0 -0
- data/docs/images/bullet_toggle_plus.png +0 -0
- data/docs/images/date.png +0 -0
- data/docs/images/delete.png +0 -0
- data/docs/images/find.png +0 -0
- data/docs/images/loadingAnimation.gif +0 -0
- data/docs/images/macFFBgHack.png +0 -0
- data/docs/images/package.png +0 -0
- data/docs/images/page_green.png +0 -0
- data/docs/images/page_white_text.png +0 -0
- data/docs/images/page_white_width.png +0 -0
- data/docs/images/plugin.png +0 -0
- data/docs/images/ruby.png +0 -0
- data/docs/images/tag_blue.png +0 -0
- data/docs/images/tag_green.png +0 -0
- data/docs/images/transparent.png +0 -0
- data/docs/images/wrench.png +0 -0
- data/docs/images/wrench_orange.png +0 -0
- data/docs/images/zoom.png +0 -0
- data/docs/index.html +132 -0
- data/docs/js/darkfish.js +84 -0
- data/docs/js/navigation.js +105 -0
- data/docs/js/navigation.js.gz +0 -0
- data/docs/js/search.js +110 -0
- data/docs/js/search_index.js +1 -0
- data/docs/js/search_index.js.gz +0 -0
- data/docs/js/searcher.js +229 -0
- data/docs/js/searcher.js.gz +0 -0
- data/docs/table_of_contents.html +608 -0
- data/lib/geometry.rb +236 -0
- data/lib/graph.rb +164 -0
- data/lib/numerical_integration.rb +147 -0
- data/lib/optimization.rb +144 -0
- data/lib/plotter.rb +96 -0
- data/lib/silicium.rb +0 -1
- data/lib/silicium/version.rb +1 -1
- data/lib/theory_of_probability.rb +227 -0
- data/silicium.gemspec +4 -2
- metadata +90 -3
@@ -0,0 +1,186 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta charset="UTF-8">
|
6
|
+
|
7
|
+
<title>module Silicium::Plotter - 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="module">
|
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
|
+
|
63
|
+
|
64
|
+
|
65
|
+
<!-- Method Quickref -->
|
66
|
+
<div id="method-list-section" class="nav-section">
|
67
|
+
<h3>Methods</h3>
|
68
|
+
|
69
|
+
<ul class="link-list" role="directory">
|
70
|
+
|
71
|
+
<li ><a href="#method-i-color">#color</a>
|
72
|
+
|
73
|
+
</ul>
|
74
|
+
</div>
|
75
|
+
|
76
|
+
</div>
|
77
|
+
</nav>
|
78
|
+
|
79
|
+
<main role="main" aria-labelledby="module-Silicium::Plotter">
|
80
|
+
<h1 id="module-Silicium::Plotter" class="module">
|
81
|
+
module Silicium::Plotter
|
82
|
+
</h1>
|
83
|
+
|
84
|
+
<section class="description">
|
85
|
+
|
86
|
+
</section>
|
87
|
+
|
88
|
+
|
89
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
<section id="public-instance-5Buntitled-5D-method-details" class="method-section">
|
100
|
+
<header>
|
101
|
+
<h3>Public Instance Methods</h3>
|
102
|
+
</header>
|
103
|
+
|
104
|
+
|
105
|
+
<div id="method-i-color" class="method-detail ">
|
106
|
+
|
107
|
+
<div class="method-heading">
|
108
|
+
<span class="method-name">color</span><span
|
109
|
+
class="method-args">(*args)</span>
|
110
|
+
|
111
|
+
<span class="method-click-advice">click to toggle source</span>
|
112
|
+
|
113
|
+
</div>
|
114
|
+
|
115
|
+
|
116
|
+
<div class="method-description">
|
117
|
+
|
118
|
+
<p>Factory method to return a color value, based on the arguments given.</p>
|
119
|
+
|
120
|
+
<p>@overload Color(r, g, b, a)</p>
|
121
|
+
|
122
|
+
<pre>@param (see ChunkyPNG::Color.rgba)
|
123
|
+
@return [Integer] The rgba color value.</pre>
|
124
|
+
|
125
|
+
<p>@overload Color(r, g, b)</p>
|
126
|
+
|
127
|
+
<pre>@param (see ChunkyPNG::Color.rgb)
|
128
|
+
@return [Integer] The rgb color value.</pre>
|
129
|
+
|
130
|
+
<p>@overload Color(hex_value, opacity = nil)</p>
|
131
|
+
|
132
|
+
<pre>@param (see ChunkyPNG::Color.from_hex)
|
133
|
+
@return [Integer] The hex color value, with the opacity applied if one
|
134
|
+
was given.</pre>
|
135
|
+
|
136
|
+
<p>@overload Color(color_name, opacity = nil)</p>
|
137
|
+
|
138
|
+
<pre>@param (see ChunkyPNG::Color.html_color)
|
139
|
+
@return [Integer] The hex color value, with the opacity applied if one
|
140
|
+
was given.</pre>
|
141
|
+
|
142
|
+
<p>@overload Color(color_value, opacity = nil)</p>
|
143
|
+
|
144
|
+
<pre>@param [Integer, :to_i] The color value.
|
145
|
+
@return [Integer] The color value, with the opacity applied if one was
|
146
|
+
given.</pre>
|
147
|
+
|
148
|
+
<p>@return [Integer] The determined color value as RGBA integer. @raise [ArgumentError] if the arguments weren't understood as a color.</p>
|
149
|
+
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
<div class="method-source-code" id="color-source">
|
154
|
+
<pre><span class="ruby-comment"># File lib/plotter.rb, line 34</span>
|
155
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">color</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
|
156
|
+
<span class="ruby-keyword">case</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">length</span>
|
157
|
+
<span class="ruby-keyword">when</span> <span class="ruby-value">1</span>; <span class="ruby-constant">ChunkyPNG</span><span class="ruby-operator">::</span><span class="ruby-constant">Color</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">args</span>.<span class="ruby-identifier">first</span>)
|
158
|
+
<span class="ruby-keyword">when</span> <span class="ruby-value">2</span>; (<span class="ruby-constant">ChunkyPNG</span><span class="ruby-operator">::</span><span class="ruby-constant">Color</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">args</span>.<span class="ruby-identifier">first</span>) <span class="ruby-operator">&</span> <span class="ruby-value">0xffffff00</span>) <span class="ruby-operator">|</span> <span class="ruby-identifier">args</span>[<span class="ruby-value">1</span>].<span class="ruby-identifier">to_i</span>
|
159
|
+
<span class="ruby-keyword">when</span> <span class="ruby-value">3</span>; <span class="ruby-constant">ChunkyPNG</span><span class="ruby-operator">::</span><span class="ruby-constant">Color</span>.<span class="ruby-identifier">rgb</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
|
160
|
+
<span class="ruby-keyword">when</span> <span class="ruby-value">4</span>; <span class="ruby-constant">ChunkyPNG</span><span class="ruby-operator">::</span><span class="ruby-constant">Color</span>.<span class="ruby-identifier">rgba</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
|
161
|
+
<span class="ruby-keyword">else</span> <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">"Don't know how to create a color from #{args.inspect}!"</span>
|
162
|
+
<span class="ruby-keyword">end</span>
|
163
|
+
<span class="ruby-keyword">end</span></pre>
|
164
|
+
</div>
|
165
|
+
|
166
|
+
</div>
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
</div>
|
172
|
+
|
173
|
+
|
174
|
+
</section>
|
175
|
+
|
176
|
+
</section>
|
177
|
+
|
178
|
+
</main>
|
179
|
+
|
180
|
+
|
181
|
+
<footer id="validator-badges" role="contentinfo">
|
182
|
+
<p><a href="https://validator.w3.org/check/referer">Validate</a>
|
183
|
+
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.2.0.
|
184
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
185
|
+
</footer>
|
186
|
+
|
@@ -0,0 +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('red @ 1.0'), 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">'red @ 1.0'</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">></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">'Not enough big size of image to plot these number of bars'</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">=></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
|
+
|