Browse Source

Adding stroke and fill to rect

dev
Andy Meneely 12 years ago
parent
commit
bda920ebe6
  1. 5
      lib/squib/api/shapes.rb
  2. 8
      lib/squib/graphics/shapes.rb

5
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

8
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

Loading…
Cancel
Save