UNPKG

ensilico

Version:

Synthetic data generation, simulated vehicles

72 lines (63 loc) 2.58 kB
<html> <head> <meta name="viewport" content="width=device-width, user-scalable=no"> <style> .unselectable { -moz-user-select: none; -webkit-user-select: none; -ms-user-select: none; user-select: none; } </style> <script src="ensilico.js"></script> <script> function Clock() { this.time = 0; this.radii = { hour: 0.6, minute: 0.75, second: 0.9, bezel: 0.95, outer: 1 }; } Clock.prototype.preferences = { visualScale: 200 }; Clock.prototype.update = function(controls) { this.time += controls.stepsize; }; Clock.prototype.visualize = function(context, elapsedTime) { var halfDays = this.time / (60 * 60 * 12); var angle = (halfDays - Math.floor(halfDays)) * 2 * Math.PI; this.constructor.drawRadial(context, 0, this.radii.hour, angle); angle *= 12; this.constructor.drawRadial(context, 0, this.radii.minute, angle); angle *= 60; this.constructor.drawRadial(context, 0, this.radii.second, angle); var numTicks = 12; for (var i = 0; i < numTicks; i++) { angle = 2 * Math.PI * i / numTicks; this.constructor.drawRadial( context, this.radii.bezel, this.radii.outer, angle); } }; Clock.drawRadial = function(context, r1, r2, angle) { context.moveTo(r1 * Math.sin(angle), r1 * Math.cos(angle)); context.lineTo(r2 * Math.sin(angle), r2 * Math.cos(angle)); }; var theSim; // for debug var tmpDst; // for debug </script> </head> <body onload="Executive.start('clock', new Clock(), 'clock.json')" class="unselectable"> <canvas id="clock" width="400" height="400"> Opps. </canvas> <button onclick="Executive.breakFrame('clock', function(sim){theSim=sim;})">Break</button> <button onclick="Platform.load(new Clock(), 'clock.json', function(msg){console.log(msg);}, function(dst){tmpDst=dst;debugger;})">Check</button> </body> </html>