forked from joshuaclayton/blueprint-css
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved compress.rb to standard options using OptionParse, added code t…
…o generate grid if ImageMagick and RMagick are installed, cleaned up classes
- Loading branch information
1 parent
709c173
commit 9fb4e04
Showing
7 changed files
with
143 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
begin | ||
require 'rubygems' | ||
gem 'rmagick' | ||
require 'rvg/rvg' | ||
rescue | ||
end | ||
|
||
class GridBuilder < Blueprint | ||
# included modules | ||
begin | ||
include Magick | ||
rescue | ||
end | ||
|
||
|
||
# properties | ||
attr_reader :column_width, :gutter_width, :output_path, :able_to_generate | ||
|
||
# constructor | ||
def initialize(options={}) | ||
@able_to_generate = Magick::Long_version rescue false | ||
return unless @able_to_generate | ||
@column_width = options[:column_width] || Blueprint::COLUMN_WIDTH | ||
@gutter_width = options[:gutter_width] || Blueprint::GUTTER_WIDTH | ||
@output_path = options[:output_path] || Blueprint::SOURCE_PATH | ||
end | ||
|
||
# instance methods | ||
def generate! | ||
return false unless self.able_to_generate | ||
total_width = self.column_width + self.gutter_width | ||
height = 20 | ||
RVG::dpi = 100 | ||
|
||
rvg = RVG.new((total_width.to_f/RVG::dpi).in, (height.to_f/RVG::dpi).in).viewbox(0, 0, total_width, height) do |canvas| | ||
canvas.background_fill = 'white' | ||
|
||
canvas.g do |column| | ||
column.rect(self.column_width, height).styles(:fill => "#e8effb") | ||
end | ||
|
||
canvas.g do |baseline| | ||
baseline.line(0, (height - 1), total_width, (height- 1)).styles(:fill => "#e9e9e9") | ||
end | ||
end | ||
FileUtils.mkdir self.output_path unless File.exists? self.output_path | ||
rvg.draw.write(File.join(self.output_path, "grid.png")) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters