Adding stroke and fill to rect

dev
Andy Meneely 2014-07-22 14:30:24 -04:00
parent d34e4729ce
commit bda920ebe6
2 changed files with 9 additions and 4 deletions

View File

@ -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

View File

@ -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