1 pixel|サイバーエージェント公式クリエイターズブログ サイバーエージェントのクリエイターの取り組みを紹介するオフィシャルブログです。最新技術への挑戦やサービス誕生の裏話、勉強会やイベントのレポートなどCAクリエイターの情報が満載です。
1 pixel|サイバーエージェント公式クリエイターズブログ サイバーエージェントのクリエイターの取り組みを紹介するオフィシャルブログです。最新技術への挑戦やサービス誕生の裏話、勉強会やイベントのレポートなどCAクリエイターの情報が満載です。
Fabric.js Javascript Canvas Library JSでのCanvas操作を簡単かつ高機能にできる「Fabric.js」 canvasのネイティブAPIは若干分かりづらいという方も多そうですが、このライブラリを使えばオブジェクト指向で楽々Canvasプログラミングが出来そうです 単に便利にコーディングできるようになるだけでなく、オブジェクトをマウスで拡大や回転できるなどといった色々な機能も盛り込まれていて便利そうです ネイティブAPIだと、四角形を描画するのに、次のようなコードを書きます。 これが、Fabric.jsを使うと次のように、とても分かりやすくなります。fillRectの引数の順ってどうだっけ?と毎回リファレンスを牽く必要もなくなりますね 他にもドキュメントを参照すれば、CanvasをネイティブAPIで書く面倒さを理解できるはず デモページも結構充実しており
enchant(); /* * グローバル変数 */ var slot_left,slot_center,slot_right; var TXT_START = "スタート"; var TXT_STOP = "ストップ"; var IMG_WIDTH = 80; var IMG_HEIGHT = 80; var IMG_MOVE_SPEED = 20; // 20pxごとに動かす /* * スロットクラス */ var Slot = enchant.Class.create(enchant.Sprite,{ initialize:function(x,y){ var surface = new Surface(IMG_WIDTH,IMG_HEIGHT); // 回転させる画像 var slot = core.assets['http://jsrun.it/assets/v/F/V/3/vF
fork元のに解説コメントを追加していきます。 まずは決まった位置でビリビリするように。 多分、ベースの処理はsin波にPerlinNoiseを乗せて繰り返しアニメーションをしてる風。 PerlinNoiseは雲模様作るところで使ってるのでそちらを参照。 // forked from akm2's "Lightning" http://jsdo.it/akm2/pQbM /** * Using PerlinNoise class * Using Point class * @see http://jsdo.it/akm2/fhMC */ PerlinNoise.useClassic = true; var BACKGROUND_COLOR = '#0b5693'; var canvas; var canvasWidth; var canvasHeight; var context; var
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く