Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <body>
  <canvas id="myCanvas" width="640" height="840">Canvas対応ブラウザを使って下さい。</canvas>
  
  <script src="https://code.createjs.com/easeljs-0.8.1.min.js"></script>
  <script src="https://code.createjs.com/preloadjs-0.6.1.min.js"></script>
</body>

              
            
!

CSS

              
                #myCanvas {
  border: 1px solid #333;
}

img {
  border: 1px dotted #333;
}
              
            
!

JS

              
                window.onload = function(){
  var stage;
  var file = 'https://dl.dropboxusercontent.com/u/49792001/html/svg/nico_shape_inkscape_plane_preserveAspectRatio_none.svg';
  
  initialize();
  
  function initialize(){
    var canvasObject = document.getElementById("myCanvas");
    var canvas_width = canvasObject.width;
    var canvas_height = canvasObject.height;
    
    stage = new createjs.Stage(canvasObject);
   
    var loader = new createjs.LoadQueue(true);
    loader.addEventListener("fileload", draw);
    loader.loadFile({src: file, type: createjs.AbstractLoader.SVG});
    
    function draw(eventObj){
      var myImage = eventObj.result;
      //svg要素
      document.body.insertBefore(myImage, document.body.firstChild);
     
      //eventObject.item.srcで取得できる
      var bitmap_origin = new createjs.Bitmap(eventObj.item.src);
      bitmap_origin.image.onload = function(){
        var svg_width = this.width;
        var svg_height = this.height;
        var img_halfWidth = svg_width / 2;
        var img_halfHeight = svg_height / 2;
        var leftX = img_halfWidth;
        var topY = img_halfHeight;
        var centerX = canvas_width/2;
        var centerY = canvas_height/2;
        bitmap_origin.regX = img_halfWidth;
        bitmap_origin.regY = img_halfHeight;
        bitmap_origin.x = centerX;
        bitmap_origin.y = topY;
        
        stage.addChild(bitmap_origin);
        stage.update();
        
        var bitmap_clone_x = bitmap_origin.clone();
        bitmap_clone_x.y += svg_height;
        bitmap_clone_x.scaleX = 2;
        bitmap_clone_x.scaleY = 0.5;
        stage.addChild(bitmap_clone_x);
        stage.update();
        
        var bitmap_clone_y = bitmap_origin.clone();
        bitmap_clone_y.y += bitmap_clone_x.y + 110;
        bitmap_clone_y.scaleX = 1;
        bitmap_clone_y.scaleY = 1.5;
        stage.addChild(bitmap_clone_y);
        stage.update();
      };
    }   
  }
};
              
            
!
999px

Console