LoginSignup
1
0

More than 5 years have passed since last update.

よし、まずはEaselJSで四角を描いてみる

Last updated at Posted at 2015-12-01
sample
<!DOCTYPE html>
<html lang="jp">
<head>
    <meta charset="UTF-8">
    <title>EaselJSで四角を描く</title>
</head>
<body>

    <canvas id="canvas" width="1920" height="1140"></canvas>
    <script src="https://code.createjs.com/createjs-2015.05.21.min.js"></script>

    <script type="text/javascript">
        document.addEventListener('DOMContentLoaded', function(){
            create();
        }, false);


        function create(){
            // stage生成
            var stageElm = document.querySelector('#canvas');
            var stage = new createjs.Stage(stageElm);
            // フレームレート設定
            createjs.Ticker.setFPS(30);
            // 1フレームごとに実行される
            createjs.Ticker.addEventListener('tick', function(){
                stage.update();
            });

            // 四角を描画
            var graphic = new createjs.Graphics();
            graphic.beginStroke('#000') // 線の色
            .beginFill('red') // 色
            .drawRect(0, 0, 100, 100); // 四角のサイズ (x1,y1, x2, y2)
            var shape = new createjs.Shape(graphic);
            stage.addChild(shape);
        }
    </script>
</body>
</html>
1
0
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
1
0