Method: MotionPrime::DrawSectionMixin#prerender_elements_for_state

Defined in:
motion-prime/sections/_draw_section_mixin.rb

#prerender_elements_for_state(state = :normal) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'motion-prime/sections/_draw_section_mixin.rb', line 54

def prerender_elements_for_state(state = :normal)
  scale = UIScreen.mainScreen.scale
  space = CGColorSpaceCreateDeviceRGB()
  bits_per_component = 8
  context = CGBitmapContextCreate(nil, container_bounds.size.width*scale, container_bounds.size.height*scale,
    bits_per_component, container_bounds.size.width*scale*4, space, KCGImageAlphaPremultipliedLast)

  CGContextScaleCTM(context, scale, scale)

  draw_background_in_context(context, container_bounds)
  elements_to_draw.each do |key, element|
    element.draw_in_context(context)
  end

  cached_draw_image[state] = CGBitmapContextCreateImage(context)
end