Got the example workingrake install && squib-eg
This commit is contained in:
+1
-1
@@ -3,7 +3,7 @@ require 'cairo'
|
||||
module Squib
|
||||
|
||||
class Card
|
||||
attr_reader :width:, :height
|
||||
attr_reader :width, :height
|
||||
attr_accessor :cairo_surface, :cairo_context
|
||||
|
||||
def initialize(width, height)
|
||||
|
||||
+15
-7
@@ -2,15 +2,23 @@ require 'squib/card'
|
||||
module Squib
|
||||
|
||||
class Deck
|
||||
attr_reader :width, :height, :cards
|
||||
attr_accessor :deck
|
||||
include Enumerable
|
||||
attr_reader :width, :height, :num_cards
|
||||
|
||||
def initialize(width: 825, height: 1125, cards: 1)
|
||||
@width=width; @height=height; @cards=cards
|
||||
@deck = Array.new(cards)
|
||||
(1..cards).each{ @deck << Squib::Card.new(width, height) }
|
||||
def initialize(width, height, cards)
|
||||
@width=width; @height=height; @num_cards=cards
|
||||
@cards = []
|
||||
num_cards.times{ @cards << Squib::Card.new(width, height) }
|
||||
end
|
||||
|
||||
def [](key)
|
||||
@cards[key]
|
||||
end
|
||||
|
||||
#For enumerables
|
||||
def each(&block)
|
||||
@cards.each { |card| block.call(card) }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,18 @@
|
||||
module Squib
|
||||
module Graphics
|
||||
|
||||
class Save
|
||||
def initialize(format)
|
||||
@format = format
|
||||
end
|
||||
|
||||
def execute
|
||||
puts "Here!"
|
||||
Squib.the_deck.each_with_index do |card, i|
|
||||
card.cairo_context.target.write_to_png("_img/img_#{i}.png")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,23 @@
|
||||
module Squib
|
||||
module Graphics
|
||||
|
||||
class Text
|
||||
def initialize(card, str, font, x, y, options)
|
||||
@card=card
|
||||
@str=str
|
||||
@font=font
|
||||
@x=x; @y=y
|
||||
end
|
||||
|
||||
def execute
|
||||
cc = @card.cairo_context
|
||||
cc.set_source_rgb(0.0,0.0,0.0)
|
||||
cc.select_font_face ("Helvetica");
|
||||
cc.set_font_size(36)
|
||||
cc.move_to(@x,@y)
|
||||
cc.show_text(@str.to_s)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
@@ -1,7 +0,0 @@
|
||||
module Squib
|
||||
|
||||
class TextCmd
|
||||
def initialize(range, str, )
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user