Sha256: 7b9276d57f966991a327c0419a666ab11efb33690c4d9767e5f619e02149f07e
Contents?: true
Size: 1.61 KB
Versions: 2
Compression:
Stored size: 1.61 KB
Contents
module MotionPrime class DrawElement < BaseElement # MotionPrime::DrawElement is container for drawRect method options. # Elements are located inside Sections def render! end def view @view ||= section.container_view end def computed_max_width view.bounds.size.width end def computed_max_height view.bounds.size.height end def computed_width width = computed_options[:width] width = 0.0 if width.nil? # calculate width if width is relative, e.g 0.7 if width > 0 && width <= 1 computed_max_width * width else computed_max_width < width ? width : computed_max_width end end def computed_height height = computed_options[:height] height = 0.0 if height.nil? # calculate height if height is relative, e.g 0.7 if height > 0 && height <= 1 computed_max_height * height else computed_max_height < height ? height : computed_max_height end end def computed_left left = computed_options[:left] right = computed_options[:right] return left if left return 0 if right.nil? computed_max_width - (computed_width + right) end def computed_top top = computed_options[:top] bottom = computed_options[:bottom] return top if top return 0 if bottom.nil? computed_max_height - (computed_height + bottom) end class << self def factory(type, options = {}) class_name = "#{type.classify}DrawElement" "MotionPrime::#{class_name}".constantize.new(options) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
motion-prime-0.1.3 | motion-prime/elements/draw.rb |
motion-prime-0.1.2 | motion-prime/elements/draw.rb |