-
Notifications
You must be signed in to change notification settings - Fork 2k
/
Copy pathHelloWorld.html
54 lines (42 loc) · 1.75 KB
/
HelloWorld.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>EaselJS Example: Bitmap</title>
<link href="../../_assets/css/shared.css" rel="stylesheet" type="text/css"/>
<link href="../../_assets/css/examples.css" rel="stylesheet" type="text/css"/>
<script src="../../_assets/js/examples.js"></script>
<script src="../../lib/easeljs-NEXT.js"></script>
<!-- We also provide hosted minified versions of all CreateJS libraries.
http://code.createjs.com -->
<script id="editable">
function init() {
// create a stage object to work with the canvas. This is the top level node in the display list:
var stage = new createjs.StageGL("testCanvas");
// Create a new Text object:
var bitmap = new createjs.Bitmap("../../_assets/art/robot.png");
// add the text as a child of the stage. This means it will be drawn any time the stage is updated
// and that its transformations will be relative to the stage coordinates:
stage.addChild(bitmap);
// make it so the image will center around where it's told to move to:
bitmap.regX = 142;
bitmap.regY = 168;
// position the image on screen, relative to the stage coordinates:
bitmap.x = stage.canvas.width / 2;
bitmap.y = stage.canvas.height / 2;
// set up a ticker to update the stage, calling stage.update now would display a black screen as the image hasn't loaded
// we can avoid this and only call stage.update once, if we pre-load the image before running this code.
createjs.Ticker.on("tick", stage);
}
</script>
</head>
<body onload="init();">
<header class="EaselJS">
<h1>Hello World!</h1>
<p>A simple example using <code>Bitmap</code> and <code>StageGL</code>.</p>
</header>
<div>
<canvas id="testCanvas" width="960" height="400"></canvas>
</div>
</body>
</html>