shapes: rect and ellipse get the angle option

Closes #162
This commit is contained in:
Andy Meneely
2016-09-09 00:10:43 -04:00
parent 01cd0f1ef2
commit d2eae64da2
22 changed files with 293 additions and 6 deletions
+4 -2
View File
@@ -12,7 +12,8 @@ module Squib
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)
range.each { |i| @cards[i].rect(box[i], draw[i]) }
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
@@ -28,7 +29,8 @@ module Squib
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)
range.each { |i| @cards[i].ellipse(box[i], draw[i]) }
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
+6 -3
View File
@@ -4,9 +4,11 @@ module Squib
# :nodoc:
# @api private
def rect(box, draw)
def rect(box, draw, trans)
use_cairo do |cc|
cc.rounded_rectangle(box.x, box.y, box.width, box.height, box.x_radius, box.y_radius)
cc.rotate_about(box.x, box.y, trans.angle)
cc.rounded_rectangle(box.x, box.y, box.width, box.height,
box.x_radius, box.y_radius)
cc.fill_n_stroke(draw)
end
end
@@ -27,9 +29,10 @@ module Squib
# of the rectangle. Control points are at 1/4 and 3/4 of the side.
# :nodoc:
# @api private
def ellipse(box, draw)
def ellipse(box, draw, trans)
x, y, w, h = box.x, box.y, box.width, box.height
use_cairo do |cc|
cc.rotate_about(box.x, box.y, trans.angle)
cc.move_to(x, y + 0.5 * h) # start west
cc.curve_to(x, y + 0.25 * h, # west to north
x + 0.25 * w, y,