23 changed files with 465 additions and 133 deletions
@ -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 |
||||
@ -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 |
||||
Loading…
Reference in new issue