Adding in a png method

This commit is contained in:
Andy Meneely
2014-07-16 23:14:56 -04:00
parent 7e86630ad7
commit 6c1d32a8cd
6 changed files with 25 additions and 3 deletions
+3 -1
View File
@@ -2,7 +2,9 @@ module Squib
class Deck
def png(range=:all, file: nil, x: 0, y: 0)
raise 'Not implemented!'
range = rangeify(range)
file = fileify(file)
range.each{ |i| @cards[i].png(file, x, y) }
end
end
+1
View File
@@ -16,6 +16,7 @@ module Squib
### BACKEND GRAPHICS ###
########################
require 'squib/graphics/background'
require 'squib/graphics/image'
require 'squib/graphics/save_doc'
require 'squib/graphics/save_images'
require 'squib/graphics/shapes'
+5
View File
@@ -30,6 +30,11 @@ module Squib
return range
end
def fileify(file)
raise 'File #{file} does not exist!' unless File.exists? file
file
end
##################
### PUBLIC API ###
##################
+12
View File
@@ -0,0 +1,12 @@
module Squib
class Card
def png(file, x, y)
cc = cairo_context
png = Cairo::ImageSurface.from_png(file)
cc.set_source(png, x, y)
cc.paint
end
end
end