|
48 | 48 | }
|
49 | 49 | </style>
|
50 | 50 |
|
51 |
| - <script>var require = {baseUrl: "../.."}</script> |
52 | 51 | <script type="text/javascript" src="../../requirejs/require.js"></script>
|
| 52 | + |
| 53 | + <script type="text/javascript"> |
| 54 | + require.config({ |
| 55 | + baseUrl: "../.." |
| 56 | + }); |
| 57 | + </script> |
| 58 | + |
53 | 59 | <script type="text/javascript">
|
54 |
| - requirejs([ |
| 60 | + require([ |
55 | 61 | "dpointer/events",
|
56 | 62 | "requirejs-domready/domReady!"
|
57 |
| - ], function(pointer){ |
| 63 | + ], function (pointer) { |
58 | 64 | var canvas = document.getElementById("drawingArea");
|
59 | 65 | var context = canvas.getContext("2d");
|
60 | 66 | canvas.height = window.innerHeight;
|
|
63 | 69 | var captured = {};
|
64 | 70 |
|
65 | 71 | // catch Pointer Down events and set capture on canvas
|
66 |
| - canvas.addEventListener("pointerdown", function(event){ |
| 72 | + canvas.addEventListener("pointerdown", function (event) { |
67 | 73 | pointer.setPointerCapture(canvas, event.pointerId);
|
68 | 74 | });
|
69 | 75 |
|
70 | 76 | // catch "got" pointer capture event and remember the pointerId as active
|
71 |
| - canvas.addEventListener("gotpointercapture", function(event){ |
| 77 | + canvas.addEventListener("gotpointercapture", function (event) { |
72 | 78 | captured[event.pointerId] = true;
|
73 | 79 | });
|
74 | 80 |
|
75 | 81 | // catch "lost" pointer capture event and set the pointerId as inactive
|
76 |
| - canvas.addEventListener("lostpointercapture", function(event){ |
| 82 | + canvas.addEventListener("lostpointercapture", function (event) { |
77 | 83 | captured[event.pointerId] = false;
|
78 | 84 | });
|
79 | 85 |
|
80 | 86 | // catch Pointer Move events and draw according to Pointer position
|
81 |
| - canvas.addEventListener("pointermove", function(event){ |
82 |
| - if(captured[event.pointerId]){ |
| 87 | + canvas.addEventListener("pointermove", function (event) { |
| 88 | + if (captured[event.pointerId]) { |
83 | 89 | // as pointer capture is enabled for this pointerId,
|
84 | 90 | // we do not have to check if the button is pressed:
|
85 | 91 | // Pointer capture is enabled until pointer is released.
|
|
88 | 94 | }
|
89 | 95 | });
|
90 | 96 | // reset canvas on double tap/click
|
91 |
| - canvas.addEventListener("dblclick", function(){ |
| 97 | + canvas.addEventListener("dblclick", function () { |
92 | 98 | canvas.height = window.innerHeight;
|
93 | 99 | canvas.width = window.innerWidth;
|
94 | 100 | });
|
95 | 101 |
|
96 | 102 | var PointerColor = {
|
97 | 103 | index: -1,
|
98 | 104 | colors: ["#FFFF00", "#0000FF", "#FF0000", "#00FF00", "#FFFFFF"], // yellow, blue, red, green, white
|
99 |
| - get: function(pointerId){ |
| 105 | + get: function (pointerId) { |
100 | 106 | return ( (this[pointerId]) || ((this[pointerId]) = this.next()));
|
101 | 107 | },
|
102 |
| - next: function(){ |
| 108 | + next: function () { |
103 | 109 | this.index = ((this.colors.length - this.index) == 1) ? 0 : (this.index + 1);
|
104 | 110 | return (this.colors[this.index]);
|
105 | 111 | }
|
|
0 commit comments