/***** pure UI functions *****/
+var zoomstart;
+
+function mouseevent(etype, event) {
+ let canvas = document.getElementById("mbrotImage");
+ switch (etype) {
+ case 'down':
+ if (event.button == 0)
+ // left button - start dragzoom
+ zoomstart = {x: event.clientX - canvas.offsetLeft,
+ y: event.clientY - canvas.offsetTop};
+ break;
+ case 'up':
+ if (event.button == 0)
+ alert(zoomstart.x + ',' + zoomstart.y + '-' +
+ (event.clientX - canvas.offsetLeft) + ',' +
+ (event.clientY - canvas.offsetTop));
+ zoomstart = undefined;
+ break;
+ }
+}
+
function saveImage() {
const bundle = document.getElementById("mbrotBundle");
const nsIFilePicker = Components.interfaces.nsIFilePicker;
</toolbox>
<hbox flex="1" pack="center" align="center">
<stack>
- <html:canvas id="mbrotImage" width="300" height="300"></html:canvas>
+ <html:canvas id="mbrotImage" width="300" height="300"
+ onmousedown="mouseevent('down', event);"
+ onmouseup="mouseevent('up',event);">
+ </html:canvas>
<button id="drawButton" label="&fileDraw.label;" oncommand="drawImage();"/>
</stack>
</hbox>