👮 spaces around operators
parent
5e09e0f1e1
commit
310030eee4
|
|
@ -9,7 +9,7 @@ module Squib
|
||||||
# DSL method. See http://squib.readthedocs.org
|
# DSL method. See http://squib.readthedocs.org
|
||||||
def set(opts = {})
|
def set(opts = {})
|
||||||
raise 'DEPRECATED: As of v0.7 img_dir is no longer supported in "set". Use config.yml instead.' if opts.key? :img_dir
|
raise 'DEPRECATED: As of v0.7 img_dir is no longer supported in "set". Use config.yml instead.' if opts.key? :img_dir
|
||||||
@font = (opts[:font] == :default) ? Squib::DEFAULT_FONT: opts[:font]
|
@font = (opts[:font] == :default) ? Squib::DEFAULT_FONT : opts[:font]
|
||||||
end
|
end
|
||||||
|
|
||||||
# DSL method. See http://squib.readthedocs.org
|
# DSL method. See http://squib.readthedocs.org
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ module Squib
|
||||||
range = Args::CardRange.new(opts[:range], deck_size: @deck_size)
|
range = Args::CardRange.new(opts[:range], deck_size: @deck_size)
|
||||||
paint = Args::Paint.new(@custom_colors).load!(opts, expand_by: @deck_size, layout: @layout)
|
paint = Args::Paint.new(@custom_colors).load!(opts, expand_by: @deck_size, layout: @layout)
|
||||||
box = Args::Box.new(self, { width: :native, height: :native }).load!(opts, expand_by: @deck_size, layout: @layout, dpi: @dpi)
|
box = Args::Box.new(self, { width: :native, height: :native }).load!(opts, expand_by: @deck_size, layout: @layout, dpi: @dpi)
|
||||||
adjust= Args::EmbedAdjust.new.load!(opts, expand_by: @deck_size, layout: @layout, dpi: @dpi)
|
adjust = Args::EmbedAdjust.new.load!(opts, expand_by: @deck_size, layout: @layout, dpi: @dpi)
|
||||||
trans = Args::Transform.new.load!(opts, expand_by: @deck_size, layout: @layout, dpi: @dpi)
|
trans = Args::Transform.new.load!(opts, expand_by: @deck_size, layout: @layout, dpi: @dpi)
|
||||||
ifile = Args::InputFile.new.load!(opts, expand_by: @deck_size, layout: @layout, dpi: @dpi)
|
ifile = Args::InputFile.new.load!(opts, expand_by: @deck_size, layout: @layout, dpi: @dpi)
|
||||||
svg_args = Args::SvgSpecial.new.load!(opts, expand_by: @deck_size, layout: @layout, dpi: @dpi)
|
svg_args = Args::SvgSpecial.new.load!(opts, expand_by: @deck_size, layout: @layout, dpi: @dpi)
|
||||||
|
|
@ -77,7 +77,7 @@ module Squib
|
||||||
range = Args::CardRange.new(opts[:range], deck_size: @deck_size)
|
range = Args::CardRange.new(opts[:range], deck_size: @deck_size)
|
||||||
paint = Args::Paint.new(@custom_colors).load!(opts, expand_by: @deck_size, layout: @layout)
|
paint = Args::Paint.new(@custom_colors).load!(opts, expand_by: @deck_size, layout: @layout)
|
||||||
box = Args::Box.new(self, { width: :native, height: :native }).load!(opts, expand_by: @deck_size, layout: @layout, dpi: @dpi)
|
box = Args::Box.new(self, { width: :native, height: :native }).load!(opts, expand_by: @deck_size, layout: @layout, dpi: @dpi)
|
||||||
adjust= Args::EmbedAdjust.new.load!(opts, expand_by: @deck_size, layout: @layout, dpi: @dpi)
|
adjust = Args::EmbedAdjust.new.load!(opts, expand_by: @deck_size, layout: @layout, dpi: @dpi)
|
||||||
trans = Args::Transform.new.load!(opts, expand_by: @deck_size, layout: @layout, dpi: @dpi)
|
trans = Args::Transform.new.load!(opts, expand_by: @deck_size, layout: @layout, dpi: @dpi)
|
||||||
ifile = Args::InputFile.new.load!(opts, expand_by: @deck_size, layout: @layout, dpi: @dpi)
|
ifile = Args::InputFile.new.load!(opts, expand_by: @deck_size, layout: @layout, dpi: @dpi)
|
||||||
rule = { type: :png, file: ifile, box: box, paint: paint, trans: trans, adjust: adjust }
|
rule = { type: :png, file: ifile, box: box, paint: paint, trans: trans, adjust: adjust }
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ module Squib
|
||||||
input = 0..(deck_size - 1) if input == :all
|
input = 0..(deck_size - 1) if input == :all
|
||||||
input = (input.to_i)..(input.to_i) if input.respond_to? :to_i
|
input = (input.to_i)..(input.to_i) if input.respond_to? :to_i
|
||||||
raise ArgumentError.new("#{input} must be Enumerable (i.e. respond_to :each).") unless input.respond_to? :each
|
raise ArgumentError.new("#{input} must be Enumerable (i.e. respond_to :each).") unless input.respond_to? :each
|
||||||
raise ArgumentError.new("#{input} is outside of deck range of 0..#{deck_size-1}") if (!input.max.nil?) && (input.max > (deck_size - 1))
|
raise ArgumentError.new("#{input} is outside of deck range of 0..#{deck_size - 1}") if (!input.max.nil?) && (input.max > (deck_size - 1))
|
||||||
input
|
input
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,8 @@ module Squib
|
||||||
'ellipsis' => "\u2026",
|
'ellipsis' => "\u2026",
|
||||||
'smart_quotes' => true,
|
'smart_quotes' => true,
|
||||||
'text_hint' => 'off',
|
'text_hint' => 'off',
|
||||||
'warn_ellipsize'=> true,
|
'warn_ellipsize' => true,
|
||||||
'warn_png_scale'=> true,
|
'warn_png_scale' => true,
|
||||||
}
|
}
|
||||||
|
|
||||||
#Translate the hints to the methods.
|
#Translate the hints to the methods.
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,7 @@ module Squib
|
||||||
v = vertical ? -1.0 : 1.0
|
v = vertical ? -1.0 : 1.0
|
||||||
h = horizontal ? -1.0 : 1.0
|
h = horizontal ? -1.0 : 1.0
|
||||||
transform Cairo::Matrix.new(v, 0.0, 0.0,
|
transform Cairo::Matrix.new(v, 0.0, 0.0,
|
||||||
h, x*(1-v), y*(1-h))
|
h, x * (1 - v), y * (1 - h))
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ module Squib
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
x, y, w, h = cxt.target.ink_extents # I love Ruby assignment ;)
|
x, y, w, h = cxt.target.ink_extents # I love Ruby assignment ;)
|
||||||
png_cxt = Squib::Graphics::CairoContextWrapper.new(Cairo::Context.new(Cairo::ImageSurface.new(w + 2*sheet.margin, h + 2*sheet.margin)))
|
png_cxt = Squib::Graphics::CairoContextWrapper.new(Cairo::Context.new(Cairo::ImageSurface.new(w + 2 * sheet.margin, h + 2 * sheet.margin)))
|
||||||
png_cxt.set_source_squibcolor(sheet.fill_color)
|
png_cxt.set_source_squibcolor(sheet.fill_color)
|
||||||
png_cxt.paint
|
png_cxt.paint
|
||||||
png_cxt.translate(-x + sheet.margin, -y + sheet.margin)
|
png_cxt.translate(-x + sheet.margin, -y + sheet.margin)
|
||||||
|
|
|
||||||
|
|
@ -32,10 +32,10 @@ module Squib
|
||||||
bar.increment
|
bar.increment
|
||||||
cc.reset_clip
|
cc.reset_clip
|
||||||
cc.translate(-x, -y)
|
cc.translate(-x, -y)
|
||||||
x += card.width + sheet.gap - 2*sheet.trim
|
x += card.width + sheet.gap - 2 * sheet.trim
|
||||||
if x > (sheet.width - card_width - sheet.margin)
|
if x > (sheet.width - card_width - sheet.margin)
|
||||||
x = sheet.margin
|
x = sheet.margin
|
||||||
y += card.height + sheet.gap - 2*sheet.trim
|
y += card.height + sheet.gap - 2 * sheet.trim
|
||||||
if y > (sheet.height - card_height - sheet.margin)
|
if y > (sheet.height - card_height - sheet.margin)
|
||||||
cc.show_page # next page
|
cc.show_page # next page
|
||||||
x, y = sheet.margin, sheet.margin
|
x, y = sheet.margin, sheet.margin
|
||||||
|
|
@ -90,9 +90,9 @@ module Squib
|
||||||
# @api private
|
# @api private
|
||||||
def trim(surface, trim, width, height)
|
def trim(surface, trim, width, height)
|
||||||
if trim > 0
|
if trim > 0
|
||||||
tmp = Cairo::ImageSurface.new(width-2*trim, height-2*trim)
|
tmp = Cairo::ImageSurface.new(width - 2 * trim, height - 2 * trim)
|
||||||
cc = Cairo::Context.new(tmp)
|
cc = Cairo::Context.new(tmp)
|
||||||
cc.set_source(surface, -1*trim, -1*trim)
|
cc.set_source(surface, -1 * trim, -1 * trim)
|
||||||
cc.paint
|
cc.paint
|
||||||
surface = tmp
|
surface = tmp
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ module Squib
|
||||||
end
|
end
|
||||||
|
|
||||||
def preprocessed_save(angle, trim, trim_radius)
|
def preprocessed_save(angle, trim, trim_radius)
|
||||||
new_width, new_height = @width - 2*trim, @height - 2*trim
|
new_width, new_height = @width - 2 * trim, @height - 2 * trim
|
||||||
new_cc = Cairo::Context.new(Cairo::ImageSurface.new(new_width, new_height))
|
new_cc = Cairo::Context.new(Cairo::ImageSurface.new(new_width, new_height))
|
||||||
new_cc.translate(new_width * 0.5, new_height * 0.5)
|
new_cc.translate(new_width * 0.5, new_height * 0.5)
|
||||||
new_cc.rotate(angle)
|
new_cc.rotate(angle)
|
||||||
|
|
|
||||||
|
|
@ -30,19 +30,19 @@ module Squib
|
||||||
def ellipse(box, draw)
|
def ellipse(box, draw)
|
||||||
x, y, w, h = box.x, box.y, box.width, box.height
|
x, y, w, h = box.x, box.y, box.width, box.height
|
||||||
use_cairo do |cc|
|
use_cairo do |cc|
|
||||||
cc.move_to(x, y + 0.5*h) # start west
|
cc.move_to(x, y + 0.5 * h) # start west
|
||||||
cc.curve_to(x, y + 0.25*h, # west to north
|
cc.curve_to(x, y + 0.25 * h, # west to north
|
||||||
x + 0.25*w, y,
|
x + 0.25 * w, y,
|
||||||
x + 0.5*w, y)
|
x + 0.5 * w, y)
|
||||||
cc.curve_to(x + 0.75*w, y, # north to east
|
cc.curve_to(x + 0.75 * w, y, # north to east
|
||||||
x + w, y + 0.25*h,
|
x + w, y + 0.25 * h,
|
||||||
x + w, y + 0.5*h)
|
x + w, y + 0.5 * h)
|
||||||
cc.curve_to(x + w, y + 0.75*h, # east to south
|
cc.curve_to(x + w, y + 0.75 * h, # east to south
|
||||||
x + 0.75*w, y + h,
|
x + 0.75 * w, y + h,
|
||||||
x + 0.5*w, y + h)
|
x + 0.5 * w, y + h)
|
||||||
cc.curve_to(x + 0.25*w, y + h, # south to west
|
cc.curve_to(x + 0.25 * w, y + h, # south to west
|
||||||
x, y + 0.75*h,
|
x, y + 0.75 * h,
|
||||||
x, y + 0.5*h)
|
x, y + 0.5 * h)
|
||||||
cc.fill_n_stroke(draw)
|
cc.fill_n_stroke(draw)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,8 @@ module Squib
|
||||||
# :nodoc:
|
# :nodoc:
|
||||||
# @api private
|
# @api private
|
||||||
def render_showcase(range, sheet, showcase)
|
def render_showcase(range, sheet, showcase)
|
||||||
out_width = range.size * ((@width - 2*sheet.trim) * showcase.scale * showcase.offset) + 2*sheet.margin
|
out_width = range.size * ((@width - 2 * sheet.trim) * showcase.scale * showcase.offset) + 2 * sheet.margin
|
||||||
out_height = showcase.reflect_offset + (1.0 + showcase.reflect_percent) * (@height - 2*sheet.trim) + 2*sheet.margin
|
out_height = showcase.reflect_offset + (1.0 + showcase.reflect_percent) * (@height - 2 * sheet.trim) + 2 * sheet.margin
|
||||||
out_cc = Cairo::Context.new(Cairo::ImageSurface.new(out_width, out_height))
|
out_cc = Cairo::Context.new(Cairo::ImageSurface.new(out_width, out_height))
|
||||||
wrapper = Squib::Graphics::CairoContextWrapper.new(out_cc)
|
wrapper = Squib::Graphics::CairoContextWrapper.new(out_cc)
|
||||||
wrapper.set_source_squibcolor(sheet.fill_color)
|
wrapper.set_source_squibcolor(sheet.fill_color)
|
||||||
|
|
@ -33,7 +33,7 @@ module Squib
|
||||||
# :nodoc:
|
# :nodoc:
|
||||||
# @api private
|
# @api private
|
||||||
def trim_rounded(src, trim, radius)
|
def trim_rounded(src, trim, radius)
|
||||||
trim_cc = Cairo::Context.new(Cairo::ImageSurface.new(src.width-2.0*trim, src.height-2.0*trim))
|
trim_cc = Cairo::Context.new(Cairo::ImageSurface.new(src.width - 2.0 * trim, src.height - 2.0 * trim))
|
||||||
trim_cc.rounded_rectangle(0, 0, trim_cc.target.width, trim_cc.target.height, radius, radius)
|
trim_cc.rounded_rectangle(0, 0, trim_cc.target.width, trim_cc.target.height, radius, radius)
|
||||||
trim_cc.set_source(src, -1 * trim, -1 * trim)
|
trim_cc.set_source(src, -1 * trim, -1 * trim)
|
||||||
trim_cc.clip
|
trim_cc.clip
|
||||||
|
|
|
||||||
|
|
@ -4,15 +4,15 @@ Squib::Deck.new(width: 825, height: 1125, cards: 1) do
|
||||||
background color: :white
|
background color: :white
|
||||||
|
|
||||||
y = 0
|
y = 0
|
||||||
text color: '#f00', str: '3-hex', x: 50, y: y+=50
|
text color: '#f00', str: '3-hex', x: 50, y: y += 50
|
||||||
text color: '#f00', str: '3-hex (alpha)', x: 50, y: y+=50
|
text color: '#f00', str: '3-hex (alpha)', x: 50, y: y += 50
|
||||||
text color: '#ff0000', str: '6-hex', x: 50, y: y+=50
|
text color: '#ff0000', str: '6-hex', x: 50, y: y += 50
|
||||||
text color: '#ff000099', str: '8-hex(alpha)', x: 50, y: y+=50
|
text color: '#ff000099', str: '8-hex(alpha)', x: 50, y: y += 50
|
||||||
text color: '#ffff00000000', str: '12-hex', x: 50, y: y+=50
|
text color: '#ffff00000000', str: '12-hex', x: 50, y: y += 50
|
||||||
text color: '#ffff000000009999', str: '12-hex (alpha)', x: 50, y: y+=50
|
text color: '#ffff000000009999', str: '12-hex (alpha)', x: 50, y: y += 50
|
||||||
text color: :burnt_orange, str: 'Symbols of constants too', x: 50, y: y+=50
|
text color: :burnt_orange, str: 'Symbols of constants too', x: 50, y: y += 50
|
||||||
text color: '(0,0)(400,0) blue@0.0 red@1.0', str: 'Linear gradients!', x: 50, y: y+=50
|
text color: '(0,0)(400,0) blue@0.0 red@1.0', str: 'Linear gradients!', x: 50, y: y += 50
|
||||||
text color: '(200,500,10)(200,500,100) blue@0.0 red@1.0', str: 'Radial gradients!', x: 50, y: y+=50
|
text color: '(200,500,10)(200,500,100) blue@0.0 red@1.0', str: 'Radial gradients!', x: 50, y: y += 50
|
||||||
# see gradients.rb sample for more on gradients
|
# see gradients.rb sample for more on gradients
|
||||||
|
|
||||||
save_png prefix: 'colors_'
|
save_png prefix: 'colors_'
|
||||||
|
|
@ -25,8 +25,8 @@ Squib::Deck.new(width: 3000, height: 1500) do
|
||||||
x, y, w, h = 0, 0, 300, 50
|
x, y, w, h = 0, 0, 300, 50
|
||||||
colors.each_with_index do |color, i|
|
colors.each_with_index do |color, i|
|
||||||
rect x: x, y: y, width: w, height: h, fill_color: color
|
rect x: x, y: y, width: w, height: h, fill_color: color
|
||||||
text str: color.to_s, x: x + 5, y: y+13, font: 'Sans Bold 16',
|
text str: color.to_s, x: x + 5, y: y + 13, font: 'Sans Bold 16',
|
||||||
color: (Cairo::Color.parse(color).to_hsv.v > 0.9) ? '#000': '#fff'
|
color: (Cairo::Color.parse(color).to_hsv.v > 0.9) ? '#000' : '#fff'
|
||||||
y += h
|
y += h
|
||||||
if y > @height
|
if y > @height
|
||||||
x += w
|
x += w
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ Squib::Deck.new(width: 825, height: 1125, cards: 3) do
|
||||||
range = hearts.each_index.select { |i| hearts[i] == n}
|
range = hearts.each_index.select { |i| hearts[i] == n}
|
||||||
n.times do |i|
|
n.times do |i|
|
||||||
svg file: 'glass-heart.svg', range: range,
|
svg file: 'glass-heart.svg', range: range,
|
||||||
x: 150, y: 55 + i*42, width: 40, height: 40
|
x: 150, y: 55 + i * 42, width: 40, height: 40
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ Squib::Deck.new(cards: 4) do
|
||||||
text str: %w(Grifter Thief Thug Kingpin),
|
text str: %w(Grifter Thief Thug Kingpin),
|
||||||
font: 'Helvetica,Sans weight=800 120',
|
font: 'Helvetica,Sans weight=800 120',
|
||||||
x: 78, y: 78, width: '2.25in', align: :center
|
x: 78, y: 78, width: '2.25in', align: :center
|
||||||
svg file: 'spanner.svg', x: (825-500)/2, y: 500, width: 500, height: 500
|
svg file: 'spanner.svg', x: (825 - 500) / 2, y: 500, width: 500, height: 500
|
||||||
|
|
||||||
# Defaults are pretty sensible.
|
# Defaults are pretty sensible.
|
||||||
showcase file: 'showcase.png'
|
showcase file: 'showcase.png'
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ Squib::Deck.new(width: 825, height: 1125, cards: 3) do
|
||||||
# Extents come back as an array of hashes, which can get split out like this
|
# Extents come back as an array of hashes, which can get split out like this
|
||||||
ws = extents.inject([]) { |arr, ext| arr << ext[:width] + 10; arr }
|
ws = extents.inject([]) { |arr, ext| arr << ext[:width] + 10; arr }
|
||||||
hs = extents.inject([]) { |arr, ext| arr << ext[:height] + 10; arr }
|
hs = extents.inject([]) { |arr, ext| arr << ext[:height] + 10; arr }
|
||||||
rect x: 65 - margin/2, y: 550 - margin/2,
|
rect x: 65 - margin / 2, y: 550 - margin / 2,
|
||||||
width: ws, height: hs,
|
width: ws, height: hs,
|
||||||
radius: 10, stroke_color: :black
|
radius: 10, stroke_color: :black
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ def mock_cairo(strio)
|
||||||
allow(pango).to receive(:height).and_return(25)
|
allow(pango).to receive(:height).and_return(25)
|
||||||
allow(pango).to receive(:width).and_return(25)
|
allow(pango).to receive(:width).and_return(25)
|
||||||
allow(pango).to receive(:index_to_pos).and_return(Pango::Rectangle.new(0, 0, 0, 0))
|
allow(pango).to receive(:index_to_pos).and_return(Pango::Rectangle.new(0, 0, 0, 0))
|
||||||
allow(pango).to receive(:extents).and_return([Pango::Rectangle.new(0, 0, 0, 0)]*2)
|
allow(pango).to receive(:extents).and_return([Pango::Rectangle.new(0, 0, 0, 0)] * 2)
|
||||||
allow(pango).to receive(:iter).and_return(iter)
|
allow(pango).to receive(:iter).and_return(iter)
|
||||||
allow(pango).to receive(:alignment).and_return(Pango::Layout::Alignment::LEFT)
|
allow(pango).to receive(:alignment).and_return(Pango::Layout::Alignment::LEFT)
|
||||||
allow(pango).to receive(:text).and_return("foo")
|
allow(pango).to receive(:text).and_return("foo")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue