SVG canvas with bouncing balls in it. console.log('Bouncing balls demo started.'); this.nrOfFields = 0; console.log('Constructor fired.'); this.fieldWindow = userInterface.newWindow(500, 500); this.canvas = userInterface.appendCanvas(this.fieldWindow,400,400,{'background':'#bbb'}); userInterface.bindEvent(this.fieldWindow, userInterface.EVENTS.WINDOW_CLOSE, this.controller, 'windowClose', this.inports['fieldUi']); userInterface.bindEvent(this.fieldWindow, userInterface.EVENTS.KEY_PRESS, this.controller, 'keyPress', this.inports['fieldUi']); userInterface.bindEvent(this.canvas.element, userInterface.EVENTS.MOUSE_RIGHT_CLICK, this.controller, 'rightClick', this.inports['fieldUi']); userInterface.bindEvent(this.canvas.element, userInterface.EVENTS.MOUSE_MOVE, this.controller, 'mouseMove'); userInterface.bindEvent(this.canvas.element, userInterface.EVENTS.MOUSE_RELEASE, this.controller, 'mouseRelease'); console.log('Canvas field created.'); userInterface.closeWindow(this.fieldWindow); console.log('Canvas field destroyed.'); this.eventName = eventName; var button = userInterface.appendButton(parent.fieldWindow, buttonText); userInterface.bindEvent(button.element, userInterface.EVENTS.MOUSE_CLICK, this.controller, 'mouseClick', this.inports["buttonUi"]); console.log('Button created.'); this.canvas = canvas; this.r = 20.0; this.vel = {'x': utils.random() * 3.0, 'y': utils.random() * 3.0}; this.mousePos = {}; this.smooth = 0.4; var circle = this.canvas.addCircle(x, y, this.r, {'fill':'#000'}); userInterface.bindEvent(circle, userInterface.EVENTS.MOUSE_PRESS, this.controller, 'mousePress', this.inports["ballUi"]); this.element = circle; console.log('Ball created.'); this.canvas.removeElement(this.element); console.log('Ball destroyed.');