LoginSignup
9
9

More than 5 years have passed since last update.

WebRubyでキャンバスに描画する

Last updated at Posted at 2014-06-04

はじめに

昨日シダを生やした際に覚えた事を忘れないようにメモ。

Canvasに図形を描画する準備

<div id="container"></div>
window = MrubyJs.get_root_object
container = window.call('$', '#container')
container.call("append", "<canvas id=\"cs\"></canvas>")
cs = window.call("$","#cs")
ctx = cs[0].call("getContext","2d")

図形の描画

あとは通常のHTML5と同様にCanvasに図形を描画できる

ctx.fillStyle='rgb(0, 255, 0)'
ctx.fillRect(0, 0, 256, 512)

Link

9
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
9