From a50c70ae578838f5f1e7167de2364de7b4a83abe Mon Sep 17 00:00:00 2001 From: Andy Meneely Date: Fri, 11 Jul 2014 23:58:03 -0400 Subject: [PATCH] Working on new files --- lib/squib.rb | 12 +++++++++++- lib/squib/card.rb | 9 ++++++++- lib/squib/commands/text_cmd.rb | 7 ------- lib/squib/deck.rb | 6 ++---- 4 files changed, 21 insertions(+), 13 deletions(-) delete mode 100644 lib/squib/commands/text_cmd.rb diff --git a/lib/squib.rb b/lib/squib.rb index 91e2d9b..3473af2 100644 --- a/lib/squib.rb +++ b/lib/squib.rb @@ -1,11 +1,16 @@ require 'squib/commands/text_cmd' +class Squib + attr_accessor :the_deck + +end + ################## ### PUBLIC API ### ################## def deck(width:, height:, cards: 1) - Deck.new(width, height, cards) + Squib.the_deck = Deck.new(width, height, cards) end def font(type: , size: 12, **options) @@ -17,6 +22,11 @@ def set_font(type: 'Arial', size: 12, **options) end def text(range=:all, str: , font: :use_set, x: 0, y: 0, **options) + range = 0..cards-1 if range == :all + str = [str] * cards unless str.respond_to? :each + #TODO define a singleton or something for the deck we're working on. + str.each{ |s| Squib::Graphics::Text.new(card, s, font, x, y, options) } + end end def image(range=:all, file: , x: 0, y: 0) diff --git a/lib/squib/card.rb b/lib/squib/card.rb index 2a7605c..30c9f63 100644 --- a/lib/squib/card.rb +++ b/lib/squib/card.rb @@ -1,8 +1,15 @@ +require 'cairo' + module Squib class Card - def initialize(width: 825, height: 1125) + attr_reader :width:, :height + attr_accessor :cairo_surface, :cairo_context + + def initialize(width, height) @width=width, @height=height + @cairo_surface = Cairo::ImageSurface.new(width,height) + @cairo_context = Cairo::Context.new(@cairo_surface) end end diff --git a/lib/squib/commands/text_cmd.rb b/lib/squib/commands/text_cmd.rb deleted file mode 100644 index 92abb5a..0000000 --- a/lib/squib/commands/text_cmd.rb +++ /dev/null @@ -1,7 +0,0 @@ -module Squib - - class TextCmd - - end - -end \ No newline at end of file diff --git a/lib/squib/deck.rb b/lib/squib/deck.rb index 972db46..765712d 100644 --- a/lib/squib/deck.rb +++ b/lib/squib/deck.rb @@ -3,16 +3,14 @@ module Squib class Deck attr_reader :width, :height, :cards + attr_accessor :deck 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: width, height: height) } + (1..cards).each{ @deck << Squib::Card.new(width, height) } end - - - end end \ No newline at end of file