36 lines
5 KiB
HTML
36 lines
5 KiB
HTML
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
||
|
<!DOCTYPE html
|
||
|
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||
|
|
||
|
<html>
|
||
|
<head>
|
||
|
<title>generate! (Blueprint::GridBuilder)</title>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
||
|
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
||
|
</head>
|
||
|
<body class="standalone-code">
|
||
|
<pre><span class="ruby-comment cmt"># File lib/blueprint/grid_builder.rb, line 32</span>
|
||
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">generate!</span>
|
||
|
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">able_to_generate</span>
|
||
|
<span class="ruby-identifier">total_width</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">column_width</span> <span class="ruby-operator">+</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">gutter_width</span>
|
||
|
<span class="ruby-identifier">height</span> = <span class="ruby-value">20</span>
|
||
|
<span class="ruby-constant">RVG</span><span class="ruby-operator">::</span><span class="ruby-identifier">dpi</span> = <span class="ruby-value">100</span>
|
||
|
|
||
|
<span class="ruby-identifier">rvg</span> = <span class="ruby-constant">RVG</span>.<span class="ruby-identifier">new</span>((<span class="ruby-identifier">total_width</span>.<span class="ruby-identifier">to_f</span><span class="ruby-operator">/</span><span class="ruby-constant">RVG</span><span class="ruby-operator">::</span><span class="ruby-identifier">dpi</span>).<span class="ruby-identifier">in</span>, (<span class="ruby-identifier">height</span>.<span class="ruby-identifier">to_f</span><span class="ruby-operator">/</span><span class="ruby-constant">RVG</span><span class="ruby-operator">::</span><span class="ruby-identifier">dpi</span>).<span class="ruby-identifier">in</span>).<span class="ruby-identifier">viewbox</span>(<span class="ruby-value">0</span>, <span class="ruby-value">0</span>, <span class="ruby-identifier">total_width</span>, <span class="ruby-identifier">height</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">canvas</span><span class="ruby-operator">|</span>
|
||
|
<span class="ruby-identifier">canvas</span>.<span class="ruby-identifier">background_fill</span> = <span class="ruby-value str">'white'</span>
|
||
|
|
||
|
<span class="ruby-identifier">canvas</span>.<span class="ruby-identifier">g</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">column</span><span class="ruby-operator">|</span>
|
||
|
<span class="ruby-identifier">column</span>.<span class="ruby-identifier">rect</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">column_width</span>, <span class="ruby-identifier">height</span>).<span class="ruby-identifier">styles</span>(<span class="ruby-identifier">:fill</span> =<span class="ruby-operator">></span> <span class="ruby-value str">"#e8effb"</span>)
|
||
|
<span class="ruby-keyword kw">end</span>
|
||
|
|
||
|
<span class="ruby-identifier">canvas</span>.<span class="ruby-identifier">g</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">baseline</span><span class="ruby-operator">|</span>
|
||
|
<span class="ruby-identifier">baseline</span>.<span class="ruby-identifier">line</span>(<span class="ruby-value">0</span>, (<span class="ruby-identifier">height</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>), <span class="ruby-identifier">total_width</span>, (<span class="ruby-identifier">height</span><span class="ruby-operator">-</span> <span class="ruby-value">1</span>)).<span class="ruby-identifier">styles</span>(<span class="ruby-identifier">:fill</span> =<span class="ruby-operator">></span> <span class="ruby-value str">"#e9e9e9"</span>)
|
||
|
<span class="ruby-keyword kw">end</span>
|
||
|
<span class="ruby-keyword kw">end</span>
|
||
|
|
||
|
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">output_path</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exists?</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">output_path</span>
|
||
|
<span class="ruby-identifier">rvg</span>.<span class="ruby-identifier">draw</span>.<span class="ruby-identifier">write</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">output_path</span>, <span class="ruby-value str">"grid.png"</span>))
|
||
|
<span class="ruby-keyword kw">end</span></pre>
|
||
|
</body>
|
||
|
</html>
|