Color handling handed off to rcairo

This commit is contained in:
Andy Meneely
2014-07-17 13:11:26 -04:00
parent f47ab6f4dd
commit c477432239
8 changed files with 22 additions and 16 deletions
+1 -1
View File
@@ -3,7 +3,7 @@ module Squib
def background(color)
cc = cairo_context
cc.set_source_rgb(*color)
cc.set_source_color(color)
cc.paint
end
+3 -3
View File
@@ -3,14 +3,14 @@ require 'pango'
module Squib
class Card
def text(str, font, x, y, options)
def text(str, font, x, y, color, options)
cc = cairo_context
cc.set_source_color(:black) #black
cc.set_source_color(color)
cc.move_to(x,y)
layout = cc.create_pango_layout
layout.text = str.to_s
w = options[:width] ; h = options[:height]
w ||= (@width - 2*x) ; h ||= (@height - 2*y) # default centers to x,y
w ||= (@width - 2*x); h ||= (@height - 2*y) # default centers to x,y
w *= Pango::SCALE ; h *= Pango::SCALE
layout.width=w ; layout.height=h
layout.wrap = Pango::WRAP_WORD