converted the rest!
parent
fc3908533f
commit
9ef4afc2e6
|
|
@ -34,3 +34,8 @@ cap
|
|||
default: ``:butt``
|
||||
|
||||
Define how the end of the stroke is drawn. Options are ``:square``, ``:butt``, and ``:round`` (or string equivalents of those).
|
||||
|
||||
join
|
||||
default: ``:mitre``
|
||||
|
||||
Specifies how to render the junction of two lines when stroking. Options are ``:mitre``, ``:round``, and ``:bevel``.
|
||||
|
|
|
|||
|
|
@ -50,6 +50,11 @@ stroke_strategy
|
|||
|
||||
Must be either ``:fill_first`` or ``:stroke_first`` (or their string equivalents).
|
||||
|
||||
join
|
||||
default: ``:mitre``
|
||||
|
||||
Specifies how to render the junction of two lines when stroking. Options are ``:mitre``, ``:round``, and ``:bevel``.
|
||||
|
||||
dash
|
||||
default: ``'3 3'`` (no dash pattern set)
|
||||
|
||||
|
|
@ -78,6 +83,21 @@ angle
|
|||
|
||||
the angle at which to rotate the rectangle about it's upper-left corner
|
||||
|
||||
x_radius
|
||||
default: ``0.125in``
|
||||
|
||||
The x radius of the rounded corners. Supports :doc:`/units`.
|
||||
|
||||
y_radius
|
||||
default: ``0.125in``
|
||||
|
||||
The y radius of the rounded corners. Supports :doc:`/units`.
|
||||
|
||||
radius
|
||||
default: ``nil``
|
||||
|
||||
The x and y radius of the rounded corners. If specified, overrides x_radius and y_radius. Supports :doc:`/units`.
|
||||
|
||||
Examples
|
||||
^^^^^^^^
|
||||
|
||||
|
|
|
|||
|
|
@ -30,20 +30,6 @@ y2
|
|||
|
||||
the y-coordinate to place. Supports :doc:`/units/`
|
||||
|
||||
|
||||
x3
|
||||
default: ``0``
|
||||
|
||||
the x-coordinate to place. Supports :doc:`/units/`
|
||||
|
||||
|
||||
y3
|
||||
default: ``50``
|
||||
|
||||
the y-coordinate to place. Supports :doc:`/units/`
|
||||
|
||||
|
||||
|
||||
.. include:: /args/draw.rst
|
||||
.. include:: /args/range.rst
|
||||
.. include:: /args/layout.rst
|
||||
|
|
|
|||
|
|
@ -9,12 +9,28 @@ Options
|
|||
|
||||
.. include:: /args/xy.rst
|
||||
.. include:: /args/wh.rst
|
||||
|
||||
x_radius
|
||||
default: ``0``
|
||||
|
||||
The x radius of the rounded corners. Supports :doc:`/units`.
|
||||
|
||||
y_radius
|
||||
default: ``0``
|
||||
|
||||
The y radius of the rounded corners. Supports :doc:`/units`.
|
||||
|
||||
radius
|
||||
default: ``nil``
|
||||
|
||||
The x and y radius of the rounded corners. If specified, overrides x_radius and y_radius. Supports :doc:`/units`.
|
||||
|
||||
.. include:: /args/draw.rst
|
||||
.. include:: /args/range.rst
|
||||
.. include:: /args/layout.rst
|
||||
|
||||
angle
|
||||
default: 0
|
||||
default: ``0``
|
||||
|
||||
the angle at which to rotate the rectangle about it's upper-left corner
|
||||
|
||||
|
|
|
|||
|
|
@ -42,6 +42,20 @@ stroke_width
|
|||
|
||||
the width of the outside stroke. Supports :doc:`/units`.
|
||||
|
||||
x_radius
|
||||
default: ``0.125in``
|
||||
|
||||
The x radius of the rounded corners. Supports :doc:`/units`.
|
||||
|
||||
y_radius
|
||||
default: ``0.125in``
|
||||
|
||||
The y radius of the rounded corners. Supports :doc:`/units`.
|
||||
|
||||
radius
|
||||
default: ``nil``
|
||||
|
||||
The x and y radius of the rounded corners. If specified, overrides x_radius and y_radius. Supports :doc:`/units`.
|
||||
|
||||
stroke_strategy
|
||||
default: ``:fill_first``
|
||||
|
|
@ -50,6 +64,11 @@ stroke_strategy
|
|||
|
||||
Must be either ``:fill_first`` or ``:stroke_first`` (or their string equivalents).
|
||||
|
||||
join
|
||||
default: ``:mitre``
|
||||
|
||||
Specifies how to render the junction of two lines when stroking. Options are ``:mitre``, ``:round``, and ``:bevel``.
|
||||
|
||||
dash
|
||||
default: ``'3 3'`` (no dash pattern set)
|
||||
|
||||
|
|
|
|||
|
|
@ -7,117 +7,9 @@ require_relative '../args/coords'
|
|||
module Squib
|
||||
class Deck
|
||||
|
||||
# DSL method. See http://squib.readthedocs.io
|
||||
def rect(opts = {})
|
||||
range = Args::CardRange.new(opts[:range], deck_size: size)
|
||||
box = Args::Box.new(self).load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
||||
draw = Args::Draw.new(custom_colors).load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
||||
trans = Args::Transform.new.load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
||||
range.each { |i| @cards[i].rect(box[i], draw[i], trans[i]) }
|
||||
end
|
||||
|
||||
# DSL method. See http://squib.readthedocs.io
|
||||
def circle(opts = {})
|
||||
range = Args::CardRange.new(opts[:range], deck_size: size)
|
||||
coords = Args::Coords.new.load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
||||
draw = Args::Draw.new(custom_colors).load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
||||
range.each { |i| @cards[i].circle(coords[i], draw[i]) }
|
||||
end
|
||||
|
||||
# DSL method. See http://squib.readthedocs.io
|
||||
def ellipse(opts = {})
|
||||
range = Args::CardRange.new(opts[:range], deck_size: size)
|
||||
draw = Args::Draw.new(custom_colors).load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
||||
box = Args::Box.new(self, { width: '0.25in', height: '0.25in' }).load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
||||
trans = Args::Transform.new.load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
||||
range.each { |i| @cards[i].ellipse(box[i], draw[i], trans[i]) }
|
||||
end
|
||||
|
||||
# DSL method. See http://squib.readthedocs.io
|
||||
# def grid(opts = {})
|
||||
# range = Args::CardRange.new(opts[:range], deck_size: size)
|
||||
# draw = Args::Draw.new(custom_colors).load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
||||
# box = Args::Box.new(self).load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
||||
# range.each { |i| @cards[i].grid(box[i], draw[i]) }
|
||||
# end
|
||||
|
||||
# DSL method. See http://squib.readthedocs.io
|
||||
def triangle(opts = {})
|
||||
range = Args::CardRange.new(opts[:range], deck_size: size)
|
||||
draw = Args::Draw.new(custom_colors).load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
||||
coords = Args::Coords.new.load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
||||
range.each { |i| @cards[i].triangle(coords[i], draw[i]) }
|
||||
end
|
||||
|
||||
# DSL method. See http://squib.readthedocs.io
|
||||
def line(opts = {})
|
||||
range = Args::CardRange.new(opts[:range], deck_size: size)
|
||||
draw = Args::Draw.new(custom_colors).load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
||||
coords = Args::Coords.new.load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
||||
range.each { |i| @cards[i].line(coords[i], draw[i]) }
|
||||
end
|
||||
|
||||
# DSL method. See http://squib.readthedocs.io
|
||||
def curve(opts = {})
|
||||
range = Args::CardRange.new(opts[:range], deck_size: size)
|
||||
draw = Args::Draw.new(custom_colors).load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
||||
coords = Args::Coords.new.load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
||||
range.each { |i| @cards[i].curve(coords[i], draw[i]) }
|
||||
end
|
||||
|
||||
# DSL method. See http://squib.readthedocs.io
|
||||
def star(opts = {})
|
||||
range = Args::CardRange.new(opts[:range], deck_size: size)
|
||||
draw = Args::Draw.new(custom_colors).load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
||||
coords = Args::Coords.new.load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
||||
trans = Args::Transform.new.load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
||||
range.each { |i| @cards[i].star(coords[i], trans[i], draw[i]) }
|
||||
end
|
||||
|
||||
# DSL method. See http://squib.readthedocs.io
|
||||
def polygon(opts = {})
|
||||
range = Args::CardRange.new(opts[:range], deck_size: size)
|
||||
draw = Args::Draw.new(custom_colors).load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
||||
coords = Args::Coords.new.load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
||||
trans = Args::Transform.new.load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
||||
range.each { |i| @cards[i].polygon(coords[i], trans[i], draw[i]) }
|
||||
end
|
||||
|
||||
# DSL method. See http://squib.readthedocs.io
|
||||
def safe_zone(opts = {})
|
||||
safe_defaults = {
|
||||
margin: '0.25in',
|
||||
radius: '0.125in',
|
||||
stroke_color: :blue,
|
||||
fill_color: '#0000',
|
||||
stroke_width: 1.0,
|
||||
dash: '3 3',
|
||||
}
|
||||
new_opts = safe_defaults.merge(opts)
|
||||
margin = Args::UnitConversion.parse new_opts[:margin]
|
||||
new_opts[:x] = margin
|
||||
new_opts[:y] = margin
|
||||
new_opts[:width] = width - (2 * margin)
|
||||
new_opts[:height] = height - (2 * margin)
|
||||
rect new_opts
|
||||
end
|
||||
|
||||
# DSL method. See http://squib.readthedocs.io
|
||||
def cut_zone(opts = {})
|
||||
safe_defaults = {
|
||||
margin: '0.125in',
|
||||
radius: '0.125in',
|
||||
stroke_color: :red,
|
||||
fill_color: '#0000',
|
||||
stroke_width: 2.0,
|
||||
}
|
||||
new_opts = safe_defaults.merge(opts)
|
||||
margin = Args::UnitConversion.parse new_opts[:margin]
|
||||
new_opts[:x] = margin
|
||||
new_opts[:y] = margin
|
||||
new_opts[:width] = width - (2 * margin)
|
||||
new_opts[:height] = height - (2 * margin)
|
||||
rect new_opts
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
require_relative 'arg_loader'
|
||||
|
||||
module Squib::Args
|
||||
module_function def extract_coord(opts, deck)
|
||||
module_function def extract_coords(opts, deck)
|
||||
Coords.new.extract!(opts, deck)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -102,11 +102,9 @@ module Squib
|
|||
##################
|
||||
### PUBLIC API ###
|
||||
##################
|
||||
require_relative 'dsl/background'
|
||||
require_relative 'api/data'
|
||||
require_relative 'api/groups'
|
||||
require_relative 'api/settings'
|
||||
require_relative 'api/shapes'
|
||||
require_relative 'api/text'
|
||||
require_relative 'api/units'
|
||||
|
||||
|
|
@ -114,15 +112,25 @@ module Squib
|
|||
### DSL METHODS ###
|
||||
###################
|
||||
require_relative 'dsl/background'
|
||||
require_relative 'dsl/circle'
|
||||
require_relative 'dsl/curve'
|
||||
require_relative 'dsl/cut_zone'
|
||||
require_relative 'dsl/ellipse'
|
||||
require_relative 'dsl/grid'
|
||||
require_relative 'dsl/hand'
|
||||
require_relative 'dsl/line'
|
||||
require_relative 'dsl/png'
|
||||
require_relative 'dsl/polygon'
|
||||
require_relative 'dsl/rect'
|
||||
require_relative 'dsl/safe_zone'
|
||||
require_relative 'dsl/save_pdf'
|
||||
require_relative 'dsl/save_png'
|
||||
require_relative 'dsl/save_sheet'
|
||||
require_relative 'dsl/save'
|
||||
require_relative 'dsl/showcase'
|
||||
require_relative 'dsl/star'
|
||||
require_relative 'dsl/svg'
|
||||
require_relative 'dsl/triangle'
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -0,0 +1,39 @@
|
|||
require_relative '../errors_warnings/warn_unexpected_params'
|
||||
require_relative '../args/card_range'
|
||||
require_relative '../args/coords'
|
||||
require_relative '../args/draw'
|
||||
|
||||
module Squib
|
||||
class Deck
|
||||
def circle(opts = {})
|
||||
DSL::Circle.new(self, __callee__).run(opts)
|
||||
end
|
||||
end
|
||||
|
||||
module DSL
|
||||
class Circle
|
||||
include WarnUnexpectedParams
|
||||
attr_reader :dsl_method, :deck
|
||||
|
||||
def initialize(deck, dsl_method)
|
||||
@deck = deck
|
||||
@dsl_method = dsl_method
|
||||
end
|
||||
|
||||
def self.accepted_params
|
||||
%i(x y
|
||||
radius arc_start arc_end arc_direction arc_close
|
||||
fill_color stroke_color stroke_width stroke_strategy join dash cap
|
||||
range layout)
|
||||
end
|
||||
|
||||
def run(opts)
|
||||
warn_if_unexpected opts
|
||||
range = Args.extract_range opts, deck
|
||||
coords = Args.extract_coords opts, deck
|
||||
draw = Args.extract_draw opts, deck
|
||||
range.each { |i| deck.cards[i].circle(coords[i], draw[i]) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
require_relative '../errors_warnings/warn_unexpected_params'
|
||||
|
||||
module Squib
|
||||
class Deck
|
||||
def curve(opts = {})
|
||||
DSL::Curve.new(self, __callee__).run(opts)
|
||||
end
|
||||
end
|
||||
|
||||
module DSL
|
||||
class Curve
|
||||
include WarnUnexpectedParams
|
||||
attr_reader :dsl_method, :deck
|
||||
|
||||
def initialize(deck, dsl_method)
|
||||
@deck = deck
|
||||
@dsl_method = dsl_method
|
||||
end
|
||||
|
||||
def self.accepted_params
|
||||
%i(x1 y1 x2 y2 cx1 cy1 cx2 cy2
|
||||
fill_color stroke_color stroke_width stroke_strategy join dash cap
|
||||
range layout)
|
||||
end
|
||||
|
||||
def run(opts)
|
||||
warn_if_unexpected opts
|
||||
range = Args.extract_range opts, deck
|
||||
draw = Args.extract_draw opts, deck
|
||||
coords = Args.extract_coords opts, deck
|
||||
range.each { |i| deck.cards[i].curve(coords[i], draw[i]) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
require_relative '../errors_warnings/warn_unexpected_params'
|
||||
|
||||
module Squib
|
||||
class Deck
|
||||
def cut_zone(opts = {})
|
||||
DSL::CutZone.new(self, __callee__).run(opts)
|
||||
end
|
||||
end
|
||||
|
||||
module DSL
|
||||
class CutZone
|
||||
include WarnUnexpectedParams
|
||||
attr_reader :dsl_method, :deck
|
||||
|
||||
def initialize(deck, dsl_method)
|
||||
@deck = deck
|
||||
@dsl_method = dsl_method
|
||||
end
|
||||
|
||||
def self.accepted_params
|
||||
%i(x y width height margin angle
|
||||
x_radius y_radius radius
|
||||
fill_color stroke_color stroke_width stroke_strategy join dash cap
|
||||
range layout)
|
||||
end
|
||||
|
||||
def run(opts)
|
||||
warn_if_unexpected opts
|
||||
cut_defaults = {
|
||||
margin: '0.125in',
|
||||
radius: '0.125in',
|
||||
stroke_color: :red,
|
||||
fill_color: '#0000',
|
||||
stroke_width: 2.0,
|
||||
}
|
||||
new_opts = cut_defaults.merge(opts)
|
||||
margin = Args::UnitConversion.parse new_opts[:margin]
|
||||
new_opts[:x] = margin
|
||||
new_opts[:y] = margin
|
||||
new_opts[:width] = deck.width - (2 * margin)
|
||||
new_opts[:height] = deck.height - (2 * margin)
|
||||
new_opts.delete :margin
|
||||
deck.rect new_opts
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
require_relative '../errors_warnings/warn_unexpected_params'
|
||||
|
||||
module Squib
|
||||
class Deck
|
||||
def ellipse(opts = {})
|
||||
DSL::Ellipse.new(self, __callee__).run(opts)
|
||||
end
|
||||
end
|
||||
|
||||
module DSL
|
||||
class Ellipse
|
||||
include WarnUnexpectedParams
|
||||
attr_reader :dsl_method, :deck
|
||||
|
||||
def initialize(deck, dsl_method)
|
||||
@deck = deck
|
||||
@dsl_method = dsl_method
|
||||
end
|
||||
|
||||
def self.accepted_params
|
||||
%i(x y width height
|
||||
fill_color stroke_color stroke_width stroke_strategy join dash cap
|
||||
angle
|
||||
range layout)
|
||||
end
|
||||
|
||||
def run(opts)
|
||||
warn_if_unexpected opts
|
||||
range = Args.extract_range opts, deck
|
||||
draw = Args.extract_draw opts, deck
|
||||
box = Args.extract_box opts, deck
|
||||
trans = Args.extract_transform opts, deck
|
||||
range.each { |i| deck.cards[i].ellipse(box[i], draw[i], trans[i]) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -19,7 +19,7 @@ module Squib
|
|||
|
||||
def self.accepted_params
|
||||
%i(x y width height
|
||||
fill_color stroke_color stroke_width stroke_strategy dash cap
|
||||
fill_color stroke_color stroke_width stroke_strategy join dash cap
|
||||
range layout)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,35 @@
|
|||
require_relative '../errors_warnings/warn_unexpected_params'
|
||||
|
||||
module Squib
|
||||
class Deck
|
||||
def line(opts = {})
|
||||
DSL::Line.new(self, __callee__).run(opts)
|
||||
end
|
||||
end
|
||||
|
||||
module DSL
|
||||
class Line
|
||||
include WarnUnexpectedParams
|
||||
attr_reader :dsl_method, :deck
|
||||
|
||||
def initialize(deck, dsl_method)
|
||||
@deck = deck
|
||||
@dsl_method = dsl_method
|
||||
end
|
||||
|
||||
def self.accepted_params
|
||||
%i(x1 y1 x2 y2
|
||||
fill_color stroke_color stroke_width stroke_strategy join dash cap
|
||||
range layout)
|
||||
end
|
||||
|
||||
def run(opts)
|
||||
warn_if_unexpected opts
|
||||
range = Args.extract_range opts, deck
|
||||
draw = Args.extract_draw opts, deck
|
||||
coords = Args.extract_coords opts, deck
|
||||
range.each { |i| deck.cards[i].line(coords[i], draw[i]) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
require_relative '../errors_warnings/warn_unexpected_params'
|
||||
|
||||
module Squib
|
||||
class Deck
|
||||
def polygon(opts = {})
|
||||
DSL::Polygon.new(self, __callee__).run(opts)
|
||||
end
|
||||
end
|
||||
|
||||
module DSL
|
||||
class Polygon
|
||||
include WarnUnexpectedParams
|
||||
attr_reader :dsl_method, :deck
|
||||
|
||||
def initialize(deck, dsl_method)
|
||||
@deck = deck
|
||||
@dsl_method = dsl_method
|
||||
end
|
||||
|
||||
def self.accepted_params
|
||||
%i(n x y radius angle
|
||||
fill_color stroke_color stroke_width stroke_strategy join dash cap
|
||||
range layout)
|
||||
end
|
||||
|
||||
def run(opts)
|
||||
warn_if_unexpected opts
|
||||
range = Args.extract_range opts, deck
|
||||
draw = Args.extract_draw opts, deck
|
||||
coords = Args.extract_coords opts, deck
|
||||
trans = Args.extract_transform opts, deck
|
||||
range.each { |i| deck.cards[i].polygon(coords[i], trans[i], draw[i]) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
require_relative '../errors_warnings/warn_unexpected_params'
|
||||
|
||||
module Squib
|
||||
class Deck
|
||||
def rect(opts = {})
|
||||
DSL::Rect.new(self, __callee__).run(opts)
|
||||
end
|
||||
end
|
||||
|
||||
module DSL
|
||||
class Rect
|
||||
include WarnUnexpectedParams
|
||||
attr_reader :dsl_method, :deck
|
||||
|
||||
def initialize(deck, dsl_method)
|
||||
@deck = deck
|
||||
@dsl_method = dsl_method
|
||||
end
|
||||
|
||||
def self.accepted_params
|
||||
%i(x y width height angle
|
||||
x_radius y_radius radius
|
||||
fill_color stroke_color stroke_width stroke_strategy join dash cap
|
||||
range layout)
|
||||
end
|
||||
|
||||
def run(opts)
|
||||
warn_if_unexpected opts
|
||||
range = Args.extract_range opts, deck
|
||||
draw = Args.extract_draw opts, deck
|
||||
box = Args.extract_box opts, deck
|
||||
trans = Args.extract_transform opts, deck
|
||||
range.each { |i| deck.cards[i].rect(box[i], draw[i], trans[i]) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
require_relative '../errors_warnings/warn_unexpected_params'
|
||||
|
||||
module Squib
|
||||
class Deck
|
||||
def safe_zone(opts = {})
|
||||
DSL::SafeZone.new(self, __callee__).run(opts)
|
||||
end
|
||||
end
|
||||
|
||||
module DSL
|
||||
class SafeZone
|
||||
include WarnUnexpectedParams
|
||||
attr_reader :dsl_method, :deck
|
||||
|
||||
def initialize(deck, dsl_method)
|
||||
@deck = deck
|
||||
@dsl_method = dsl_method
|
||||
end
|
||||
|
||||
def self.accepted_params
|
||||
%i(x y width height margin angle
|
||||
x_radius y_radius radius
|
||||
fill_color stroke_color stroke_width stroke_strategy join dash cap
|
||||
range layout)
|
||||
end
|
||||
|
||||
def run(opts)
|
||||
warn_if_unexpected opts
|
||||
safe_defaults = {
|
||||
margin: '0.25in',
|
||||
radius: '0.125in',
|
||||
stroke_color: :blue,
|
||||
fill_color: '#0000',
|
||||
stroke_width: 1.0,
|
||||
dash: '3 3',
|
||||
}
|
||||
new_opts = safe_defaults.merge(opts)
|
||||
margin = Args::UnitConversion.parse new_opts[:margin]
|
||||
new_opts[:x] = margin
|
||||
new_opts[:y] = margin
|
||||
new_opts[:width] = deck.width - (2 * margin)
|
||||
new_opts[:height] = deck.height - (2 * margin)
|
||||
new_opts.delete :margin
|
||||
deck.rect(new_opts)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
require_relative '../errors_warnings/warn_unexpected_params'
|
||||
|
||||
module Squib
|
||||
class Deck
|
||||
def star(opts = {})
|
||||
DSL::Star.new(self, __callee__).run(opts)
|
||||
end
|
||||
end
|
||||
|
||||
module DSL
|
||||
class Star
|
||||
include WarnUnexpectedParams
|
||||
attr_reader :dsl_method, :deck
|
||||
|
||||
def initialize(deck, dsl_method)
|
||||
@deck = deck
|
||||
@dsl_method = dsl_method
|
||||
end
|
||||
|
||||
def self.accepted_params
|
||||
%i(n x y
|
||||
inner_radius outer_radius angle
|
||||
fill_color stroke_color stroke_width stroke_strategy join dash cap
|
||||
range layout)
|
||||
end
|
||||
|
||||
def run(opts)
|
||||
warn_if_unexpected opts
|
||||
range = Args.extract_range opts, deck
|
||||
draw = Args.extract_draw opts, deck
|
||||
coords = Args.extract_coords opts, deck
|
||||
trans = Args.extract_transform opts, deck
|
||||
range.each { |i| deck.cards[i].star(coords[i], trans[i], draw[i]) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
require_relative '../errors_warnings/warn_unexpected_params'
|
||||
|
||||
module Squib
|
||||
class Deck
|
||||
def triangle(opts = {})
|
||||
DSL::Triangle.new(self, __callee__).run(opts)
|
||||
end
|
||||
end
|
||||
|
||||
module DSL
|
||||
class Triangle
|
||||
include WarnUnexpectedParams
|
||||
attr_reader :dsl_method, :deck
|
||||
|
||||
def initialize(deck, dsl_method)
|
||||
@deck = deck
|
||||
@dsl_method = dsl_method
|
||||
end
|
||||
|
||||
def self.accepted_params
|
||||
%i(x1 y1 x2 y2 x3 y3
|
||||
fill_color stroke_color stroke_width stroke_strategy join dash cap
|
||||
range layout)
|
||||
end
|
||||
|
||||
def run(opts)
|
||||
warn_if_unexpected opts
|
||||
range = Args.extract_range opts, deck
|
||||
draw = Args.extract_draw opts, deck
|
||||
coords = Args.extract_coords opts, deck
|
||||
range.each { |i| deck.cards[i].triangle(coords[i], draw[i]) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -59,6 +59,6 @@ Squib::Deck.new(width: 825, height: 1125, cards: 3) do
|
|||
end
|
||||
end
|
||||
|
||||
rect color: 'black' # just a border
|
||||
rect stroke_color: 'black' # just a border
|
||||
save_sheet prefix: 'ranges_', columns: 3
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ require 'squib'
|
|||
Squib::Deck.new(cards: 8) do
|
||||
background color: :gray
|
||||
rect x: 37.5, y: 37.5, width: 750, height: 1050,
|
||||
x_radius: 37.5, y_radius: 37.5, stroke: 3.0, dash: '4 4'
|
||||
x_radius: 37.5, y_radius: 37.5, stroke_width: 2.0, dash: '4 4'
|
||||
|
||||
# Tests for crop marks
|
||||
save_pdf file: 'crops-default.pdf', crop_marks: true
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ require 'squib'
|
|||
Squib::Deck.new(width: 825, height: 1125, cards: 16) do
|
||||
background color: :gray
|
||||
rect x: 38, y: 38, width: 750, height: 1050,
|
||||
x_radius: 38, y_radius: 38, stroke: 3.0, dash: '4 4'
|
||||
x_radius: 38, y_radius: 38, stroke_width: 2.0, dash: '4 4'
|
||||
|
||||
text str: (1..16).to_a, x: 220, y: 78, font: 'Arial 18'
|
||||
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ describe 'docs spec helper' do
|
|||
expect(options.sort).to eq(%i(color range))
|
||||
end
|
||||
|
||||
it 'gets all documented options for grid' do
|
||||
it 'gets all documented options for grid.rst' do
|
||||
expected = %i(x y width height fill_color stroke_color stroke_width
|
||||
stroke_strategy dash cap range layout)
|
||||
stroke_strategy join dash cap range layout)
|
||||
options = documented_options(:Grid)
|
||||
expect(options.sort).to eq(expected.sort)
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue