Browse Source
* Playing with PDF support * Added background * Added rectangle * Split save to save_pdf and save_images since PDFs are way different * Working on text rendering (non-pango for now, but that'll change)dev
7 changed files with 96 additions and 10 deletions
@ -0,0 +1,17 @@
|
||||
module Squib |
||||
module Graphics |
||||
|
||||
class Background |
||||
def initialize(card, color) |
||||
@card=card; @color=color |
||||
end |
||||
|
||||
def execute |
||||
cc = @card.cairo_context |
||||
cc.set_source_rgb(*@color) |
||||
cc.paint |
||||
end |
||||
end |
||||
|
||||
end |
||||
end |
||||
@ -0,0 +1,21 @@
|
||||
module Squib |
||||
module Graphics |
||||
|
||||
class Rectangle |
||||
|
||||
def initialize(card, x, y, width, height, x_radius, y_radius) |
||||
@card=card; @x=x; @y=y; @width=width; @height=height |
||||
@x_radius=x_radius; @y_radius=y_radius |
||||
end |
||||
|
||||
def execute |
||||
cc = @card.cairo_context |
||||
cc.set_source_rgb(0.0,0.0,0.0) |
||||
cc.rounded_rectangle(@x, @y, @width, @height, @x_radius, @y_radius) |
||||
cc.stroke |
||||
end |
||||
|
||||
end |
||||
|
||||
end |
||||
end |
||||
@ -0,0 +1,27 @@
|
||||
module Squib |
||||
module Graphics |
||||
|
||||
class SaveDoc |
||||
def initialize(format) |
||||
@format = format |
||||
end |
||||
|
||||
def execute |
||||
#paper is 8.5x11 |
||||
# PDF points are 1/72 of an inch |
||||
width = 8.5 * 72 |
||||
height = 11 * 72 |
||||
cc = Cairo::Context.new(Cairo::PDFSurface.new('_img/deck.pdf', width, height)) |
||||
x = 10 |
||||
y = 10 |
||||
Squib.the_deck.each_with_index do |card, i| |
||||
cc.move_to(x,y) |
||||
x += 825*i |
||||
cc.set_source(card.cairo_surface, 0, 300) |
||||
cc.paint |
||||
end |
||||
end |
||||
end |
||||
|
||||
end |
||||
end |
||||
@ -1,13 +1,12 @@
|
||||
module Squib |
||||
module Graphics |
||||
|
||||
class Save |
||||
class SaveImages |
||||
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 |
||||
Loading…
Reference in new issue