Class: Kame::Remocon::Opal::CanvasView
- Inherits:
-
Object
- Object
- Kame::Remocon::Opal::CanvasView
- Includes:
- Hyalite::Component
- Defined in:
- lib/kame/remocon/opal/views/canvas_view.rb
Instance Method Summary collapse
Instance Method Details
#component_did_mount ⇒ Object
9 10 11 12 13 14 |
# File 'lib/kame/remocon/opal/views/canvas_view.rb', line 9 def component_did_mount el = @refs[:canvas] @canvas = Kame::Remocon::Opal::Canvas.new(el.native) @props[:onMounted].call(@canvas) end |
#create_image ⇒ Object
4 5 6 7 |
# File 'lib/kame/remocon/opal/views/canvas_view.rb', line 4 def create_image canvas = @refs[:canvas].native `canvas.toDataURL()` end |
#render ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/kame/remocon/opal/views/canvas_view.rb', line 16 def render image = nil if @props[:render_image] image = create_image end bg_color = @props[:bg_color] div({class: "wrap-canvas"}) do canvas(width: "400", height: "400", id: :canvas, ref: :canvas, style: {"background-color": bg_color}) end end |