* Flipping works, now just need new argument * Finishing up * New test data
This commit is contained in:
@@ -20,11 +20,11 @@ module Squib
|
||||
|
||||
def_delegators :cairo_cxt, :save, :set_source_color, :paint, :restore,
|
||||
:translate, :rotate, :move_to, :update_pango_layout, :width, :height,
|
||||
:show_pango_layout, :rounded_rectangle, :set_line_width, :stroke, :fill,
|
||||
:show_pango_layout, :rectangle, :rounded_rectangle, :set_line_width, :stroke, :fill,
|
||||
:set_source, :scale, :render_rsvg_handle, :circle, :triangle, :line_to,
|
||||
:operator=, :show_page, :clip, :transform, :mask, :create_pango_layout,
|
||||
:antialias=, :curve_to, :matrix, :matrix=, :identity_matrix, :pango_layout_path,
|
||||
:stroke_preserve, :target, :new_path, :fill_preserve, :close_path,
|
||||
:stroke_preserve, :target, :new_path, :new_sub_path, :reset_clip, :fill_preserve, :close_path,
|
||||
:set_line_join, :set_line_cap, :set_dash, :arc, :arc_negative
|
||||
|
||||
# :nodoc:
|
||||
|
||||
@@ -32,6 +32,7 @@ module Squib
|
||||
draw_card cc, card,
|
||||
slot['x'], slot['y'],
|
||||
slot['rotate'],
|
||||
slot['flip_vertical'], slot['flip_horizontal'],
|
||||
@sheet_args.trim, @sheet_args.trim_radius
|
||||
|
||||
bar.increment
|
||||
@@ -128,7 +129,7 @@ module Squib
|
||||
(@deck.height - 2.0 * @sheet_args.trim) > @tmpl.card_height
|
||||
end
|
||||
|
||||
def draw_card(cc, card, x, y, angle, trim, trim_radius)
|
||||
def draw_card(cc, card, x, y, angle, flip_v, flip_h, trim, trim_radius)
|
||||
# Compute the true size of the card after trimming
|
||||
w = @deck.width - 2.0 * trim
|
||||
h = @deck.height - 2.0 * trim
|
||||
@@ -142,6 +143,7 @@ module Squib
|
||||
mat = cc.matrix # Save the transformation matrix to revert later
|
||||
cc.translate x, y
|
||||
cc.translate @deck.width / 2.0, @deck.height / 2.0
|
||||
cc.flip(flip_v, flip_h, 0, 0)
|
||||
cc.rotate angle
|
||||
cc.translate -@deck.width / 2.0, -@deck.height / 2.0
|
||||
cc.rounded_rectangle(trim, trim, w, h, trim_radius, trim_radius) # clip
|
||||
@@ -164,7 +166,8 @@ module Squib
|
||||
@tmpl.sheet_height * ratio
|
||||
)
|
||||
|
||||
cc = Cairo::Context.new(surface)
|
||||
cc = CairoContextWrapper.new(Cairo::Context.new(surface))
|
||||
# cc = Cairo::Context.new(surface)
|
||||
cc.scale(72.0 / @deck.dpi, 72.0 / @deck.dpi) # make it like pixels
|
||||
cc
|
||||
end
|
||||
@@ -185,7 +188,8 @@ module Squib
|
||||
class SaveSpruePNG < SaveSprue
|
||||
def init_cc
|
||||
surface = Cairo::ImageSurface.new @tmpl.sheet_width, @tmpl.sheet_height
|
||||
Cairo::Context.new(surface)
|
||||
CairoContextWrapper.new(Cairo::Context.new(surface))
|
||||
# Cairo::Context.new(surface)
|
||||
end
|
||||
|
||||
def draw_page(cc)
|
||||
|
||||
@@ -175,6 +175,8 @@ module Squib
|
||||
new_card['y'] = y
|
||||
new_card['rotate'] = parse_rotate_param(
|
||||
card['rotate'] ? card['rotate'] : @template_hash['rotate'])
|
||||
new_card['flip_vertical'] = card['flip_vertical'] == true
|
||||
new_card['flip_horizontal'] = card['flip_horizontal'] == true
|
||||
new_card
|
||||
end
|
||||
|
||||
@@ -199,5 +201,6 @@ module Squib
|
||||
val.to_f
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -41,8 +41,10 @@ module Squib
|
||||
:optional, Numeric,
|
||||
ClassyHash::G.enum(:clockwise, :counterclockwise, :turnaround),
|
||||
ROTATE_REGEX
|
||||
]
|
||||
}]]
|
||||
],
|
||||
'flip_vertical' => [ :optional, FalseClass ],
|
||||
'flip_horizontal' => [ :optional, FalseClass ],
|
||||
}]]
|
||||
}.freeze
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user