From bda920ebe66867ae4d11284184dd582b49b466be Mon Sep 17 00:00:00 2001 From: Andy Meneely Date: Tue, 22 Jul 2014 14:30:24 -0400 Subject: [PATCH] Adding stroke and fill to rect --- lib/squib/api/shapes.rb | 5 +++-- lib/squib/graphics/shapes.rb | 8 ++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/squib/api/shapes.rb b/lib/squib/api/shapes.rb index 412f2c8..b60b50d 100644 --- a/lib/squib/api/shapes.rb +++ b/lib/squib/api/shapes.rb @@ -2,12 +2,13 @@ module Squib class Deck def rect(range: :all, x: 0, y: 0, width: 825, height: 1125, \ - radius: 0, x_radius: 0, y_radius: 0, color: :black) + radius: nil, x_radius: 0, y_radius: 0, \ + fill_color: '#0000', stroke_color: :black, stroke_width: 2.0) range = rangeify(range) color = colorify(color) x_radius,y_radius = radiusify(radius, x_radius, y_radius) range.each do |i| - @cards[i].draw_rectangle(x, y, width, height, x_radius, y_radius, color) + @cards[i].draw_rectangle(x, y, width, height, x_radius, y_radius, fill_color, stroke_color, stroke_width) end end diff --git a/lib/squib/graphics/shapes.rb b/lib/squib/graphics/shapes.rb index 2631ef8..d3105bc 100644 --- a/lib/squib/graphics/shapes.rb +++ b/lib/squib/graphics/shapes.rb @@ -1,11 +1,15 @@ module Squib class Card - def draw_rectangle(x, y, width, height, x_radius, y_radius, color) + def draw_rectangle(x, y, width, height, x_radius, y_radius, fill_color, stroke_color, stroke_width) cc = cairo_context - cc.set_source_color(color) cc.rounded_rectangle(x, y, width, height, x_radius, y_radius) + cc.set_source_color(stroke_color) + cc.set_line_width(stroke_width); cc.stroke + cc.rounded_rectangle(x, y, width, height, x_radius, y_radius) + cc.set_source_color(fill_color) + cc.fill end end