lib/wingtips/slide.rb in wingtips-0.1.0 vs lib/wingtips/slide.rb in wingtips-0.2.0
- old
+ new
@@ -14,22 +14,24 @@
IMAGES_DIRECTORY = 'images/'
CODE_DIRECTORY = 'code/'
attr_reader :app
- def initialize(app)
+ def initialize(app, wingtips_options = {})
@app = app
@effects = []
+ @background_color = wingtips_options[:background_color]
after_initialize
end
def content
# implemented by subclasses
end
def show
@main_slot = stack height: app.height do
+ background @background_color if @background_color
content
end
end
def append(&blk)
@@ -44,14 +46,15 @@
else
super
end
end
- def code(string, demo_as_effect = false, &block)
+ def code(string, demo_as_effect = false, options = {}, &block)
source = source_from string
source = source.split("\n").map{|line| ' ' + line}.join("\n")
- highlighted_code = para *highlight(source), size: CODE_SIZE
+ opts = {size: CODE_SIZE}.merge options
+ highlighted_code = para *highlight(source, nil, @app.code_highlighting), opts
add_demo_as_effect(source, &block) if demo_as_effect
highlighted_code
end
def demo(string, &block)
@@ -124,9 +127,10 @@
end
def scale_image_by(img, ratio)
img.width = (img.width * ratio).to_i
img.height = (img.height * ratio).to_i
+ img
end
def centered_title(string, opts={})
para string, defaulted_options(opts,
align: 'center',