// Generated by CoffeeScript 1.6.3 (function() { var DrawTarget, MonkeyResult; MonkeyResult = function() { var options, that; that = {}; options = null; that.configure = function(opts) { options = opts; options.image_size_rate = opts.image_size_rate || 1; return that; }; that.draw = function() { var i, ir, log, _i, _len, _ref, _results; ir = options.image_size_rate; _ref = options.log_list; _results = []; for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) { log = _ref[i]; _results.push((function(log, i) { var img, text_div; text_div = $('#' + options.text_prefix + '-' + i); text_div.html(log.message + "
" + log.timestamp); img = new Image(); img.addEventListener("load", function() { var canvas, context, element, target; element = $('#' + options.view_prefix + '-' + i); canvas = element[0]; canvas.width = img.width * ir; canvas.height = img.height * ir; context = canvas.getContext('2d'); context.scale(1, 1); context.clearRect(0, 0, canvas.width, canvas.height); context.drawImage(img, 0, 0, canvas.width, canvas.height); target = DrawTarget({ canvas: canvas, context: context, image_size_rate: ir, index: i }); return eval(log.message); }); return img.src = log.screen_image + '.png'; })(log, i)); } return _results; }; return that; }; DrawTarget = function(opts) { var arc_radius, canvas, context, draw_arc, draw_arrow, draw_text, ir, options, orientation_name, pos_to_number, that; that = {}; options = opts; canvas = options.canvas; context = options.context; ir = options.image_size_rate; context.strokeStyle = "#f00"; context.lineWidth = 2; arc_radius = 20; that.tapWithOptions = function(p1, info) { var num, o, tc, _i, _j, _ref, _ref1, _results; console.log(opts.index, p1, info); pos_to_number(p1); tc = 1 * info.touchCount; for (num = _i = 0, _ref = tc - 1; 0 <= _ref ? _i <= _ref : _i >= _ref; num = 0 <= _ref ? ++_i : --_i) { o = { x: (context.lineWidth + 2) * (num - (tc - 1) / 2), y: 0 }; draw_arc({ x: (p1.x * ir + o.x) / ir, y: (p1.y * ir + o.y) / ir }, { r: 0.1 }); } _results = []; for (num = _j = 0, _ref1 = 1 * info.tapCount - 1; 0 <= _ref1 ? _j <= _ref1 : _j >= _ref1; num = 0 <= _ref1 ? ++_j : --_j) { _results.push(draw_arc(p1, { r: (arc_radius * ir + (1 + context.lineWidth) * num) / ir })); } return _results; }; that.pinchCloseFromToForDuration = function(p1, p2, info) { var center, p, _i, _len, _ref; _ref = [p1, p2]; for (_i = 0, _len = _ref.length; _i < _len; _i++) { p = _ref[_i]; pos_to_number(p); } draw_arc(p1); draw_arc(p2); center = { x: (p1.x + p2.x) / 2, y: (p1.y + p2.y) / 2 }; draw_arrow(p1, center); return draw_arrow(p2, center); }; that.pinchOpenFromToForDuration = function(p1, p2, info) { var center, p, _i, _len, _ref; _ref = [p1, p2]; for (_i = 0, _len = _ref.length; _i < _len; _i++) { p = _ref[_i]; pos_to_number(p); } draw_arc(p1); draw_arc(p2); center = { x: (p1.x + p2.x) / 2, y: (p1.y + p2.y) / 2 }; draw_arrow(center, p1); return draw_arrow(center, p2); }; that.dragFromToForDuration = function(p1, p2, info) { var p, _i, _len, _ref; _ref = [p1, p2]; for (_i = 0, _len = _ref.length; _i < _len; _i++) { p = _ref[_i]; pos_to_number(p); } console.log(opts.index, p1, p2, info); draw_arc(p1); draw_arc(p2); return draw_arrow(p1, p2); }; that.flickFromTo = function(p1, p2, info) { var p, _i, _len, _ref; _ref = [p1, p2]; for (_i = 0, _len = _ref.length; _i < _len; _i++) { p = _ref[_i]; pos_to_number(p); } console.log(opts.index, p1, p2, info); draw_arc(p1); return draw_arrow(p1, p2); }; that.lockForDuration = function(duration) { return draw_text("Lock Screen " + (Math.floor(duration * 100) / 100) + " Secs."); }; that.deactivateAppForDuration = function(duration) { return draw_text("Deactivate " + (Math.floor(duration * 100) / 100) + " Secs."); }; that.setDeviceOrientation = function(orientation) { return draw_text("Orientation to " + (orientation_name(orientation))); }; that.shake = function() { return draw_text("Shake!"); }; that.clickVolumeUp = function() { return draw_text("clickVolumeUp!"); }; that.clickVolumeDown = function() { return draw_text("clickVolumeDown!"); }; draw_text = function(text, opts) { if (opts == null) { opts = {}; } context.font = "10px 'MS Pゴシック'"; context.lineWidth = 1; context.strokeStyle = "green"; context.beginPath(); context.fillRect(canvas.width * 0.1, 20, canvas.width * 0.8, 40); context.stroke(); return context.strokeText(text, canvas.width * 0.13, 42); }; orientation_name = function(orientation) { switch (1 * orientation) { case 0: return "UNKNOWN"; case 1: return "PORTRAIT"; case 2: return "PORTRAIT_UPSIDEDOWN"; case 3: return "LANDSCAPELEFT"; case 4: return "LANDSCAPERIGHT"; case 5: return "FACEUP"; case 6: return "FACEDOWN"; default: return "UNDEF"; } }; pos_to_number = function(p) { p.x = 1 * p.x; p.y = 1 * p.y; return p; }; draw_arc = function(p, opts) { var radius; if (opts == null) { opts = {}; } radius = opts.r || arc_radius; context.beginPath(); context.arc(p.x * ir, p.y * ir, radius * ir, 0, Math.PI * 2); return context.stroke(); }; draw_arrow = function(p1, p2, opts) { var lp, mp, rp, ux, uy, v, vx, vy; if (opts == null) { opts = {}; } vx = p2.x - p1.x; vy = p2.y - p1.y; v = Math.sqrt(vx * vx + vy * vy); ux = vx / v; uy = vy / v; opts.w || (opts.w = 8); opts.h || (opts.h = 12); opts.h2 || (opts.h2 = 5); lp = { x: p2.x - uy * opts.w - ux * opts.h, y: p2.y + ux * opts.w - uy * opts.h }; rp = { x: p2.x + uy * opts.w - ux * opts.h, y: p2.y - ux * opts.w - uy * opts.h }; mp = { x: p2.x - ux * opts.h2, y: p2.y - uy * opts.h2 }; context.beginPath(); context.moveTo(p1.x * ir, p1.y * ir); context.lineTo(mp.x * ir, mp.y * ir); context.lineTo(lp.x * ir, lp.y * ir); context.lineTo(p2.x * ir, p2.y * ir); context.lineTo(rp.x * ir, rp.y * ir); context.lineTo(mp.x * ir, mp.y * ir); return context.stroke(); }; return that; }; window.MonkeyResult = MonkeyResult; }).call(this);