Calculator and canvas

Calculator and canvas
0

#1

Hi,
I want to use CreateJs to use Canvas for the calculator


I don’t understand why the Canvas doesn’t work

<html>
  <head>
    <script src="https://code.createjs.com/createjs-2015.11.26.min.js"></script>
    <script type="javascript" src="script.js"></script>
  </head>
  <body>
    <canvas id="demoCanvas" width="500" height="200">
      fallback er
    </canvas>
    <!--<script type="javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>-->
  </body>
</html>

in script.js

function init() {
  var stage = new createjs.Stage("demoCanvas");
  var circle = new createjs.Shape();
  circle.graphics.beginFill("DeepSkyBlue").drawCircle(0, 0, 50);
  circle.x = 100;
  circle.y = 100;
  stage.addChild(circle);
  stage.update();
}
init()

#3

Thanks for that, I was using application/javascript by default then I changed and didn’t realize my mistake.


#4

My error come from my mixin with Jade I forgot the type…

//- utils.jade
mixin script(src)
  script(type='text/javascript', src=src)
mixin style(href)
  link(rel='stylesheet', type='text/css', href=href)
doctype html
//- End mixins

html(lang='en')
  head
    meta(charset='UTF-8')
    meta(name='viewport', content='width=device-width, initial-scale=1')
    +style('style.css')
    title Calculator 

  body
    canvas#demoCanvas(height=200, width=500)
      | fallback init
    div
      | Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

    //-+script('https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js')
    +script('https://code.createjs.com/easeljs-0.8.2.min.js')
    +script('script.js')