Adding in a png method
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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 ###
|
||||
##################
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user