Working on new files
parent
e9b42da5cf
commit
a50c70ae57
12
lib/squib.rb
12
lib/squib.rb
|
|
@ -1,11 +1,16 @@
|
||||||
require 'squib/commands/text_cmd'
|
require 'squib/commands/text_cmd'
|
||||||
|
|
||||||
|
class Squib
|
||||||
|
attr_accessor :the_deck
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
##################
|
##################
|
||||||
### PUBLIC API ###
|
### PUBLIC API ###
|
||||||
##################
|
##################
|
||||||
|
|
||||||
def deck(width:, height:, cards: 1)
|
def deck(width:, height:, cards: 1)
|
||||||
Deck.new(width, height, cards)
|
Squib.the_deck = Deck.new(width, height, cards)
|
||||||
end
|
end
|
||||||
|
|
||||||
def font(type: , size: 12, **options)
|
def font(type: , size: 12, **options)
|
||||||
|
|
@ -17,6 +22,11 @@ def set_font(type: 'Arial', size: 12, **options)
|
||||||
end
|
end
|
||||||
|
|
||||||
def text(range=:all, str: , font: :use_set, x: 0, y: 0, **options)
|
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
|
end
|
||||||
|
|
||||||
def image(range=:all, file: , x: 0, y: 0)
|
def image(range=:all, file: , x: 0, y: 0)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,15 @@
|
||||||
|
require 'cairo'
|
||||||
|
|
||||||
module Squib
|
module Squib
|
||||||
|
|
||||||
class Card
|
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
|
@width=width, @height=height
|
||||||
|
@cairo_surface = Cairo::ImageSurface.new(width,height)
|
||||||
|
@cairo_context = Cairo::Context.new(@cairo_surface)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
module Squib
|
|
||||||
|
|
||||||
class TextCmd
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
@ -3,16 +3,14 @@ module Squib
|
||||||
|
|
||||||
class Deck
|
class Deck
|
||||||
attr_reader :width, :height, :cards
|
attr_reader :width, :height, :cards
|
||||||
|
attr_accessor :deck
|
||||||
|
|
||||||
def initialize(width: 825, height: 1125, cards: 1)
|
def initialize(width: 825, height: 1125, cards: 1)
|
||||||
@width=width; @height=height; @cards=cards
|
@width=width; @height=height; @cards=cards
|
||||||
@deck = Array.new(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
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
Loading…
Reference in New Issue