1 | (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
2 | module.exports = {
|
3 | Renderer:require('./src/renderer/Renderer'),
|
4 | ShotRenderer:require('./src/renderer/ShotRenderer'),
|
5 | TargetRenderer:require('./src/renderer/TargetRenderer'),
|
6 | TriangleRenderer:require('./src/renderer/TriangleRenderer'),
|
7 | CardRenderer:require('./src/renderer/CardRenderer'),
|
8 | MegalinkCardRenderer:require('./src/renderer/megalink/MegalinkCardRenderer'),
|
9 | RangeRenderer:require('./src/renderer/RangeRenderer'),
|
10 | MegalinkRangeRenderer:require('./src/renderer/megalink/MegalinkRangeRenderer'),
|
11 | Scaler:require('./src/scaler/Scaler'),
|
12 | RingTargetBuilder:require('./src/target/RingTargetBuilder'),
|
13 | RingTargetRenderer:require('./src/renderer/RingTargetRenderer'),
|
14 | RingTargetScaler:require('./src/scaler/RingTargetScaler'),
|
15 | targets:require('./src/target/targets'),
|
16 | Builder:require('./src/protocol/Builder'),
|
17 | CardBuilder:require('./src/protocol/CardBuilder'),
|
18 | ConfigBuilder:require('./src/protocol/ConfigBuilder'),
|
19 | RangeBuilder:require('./src/protocol/RangeBuilder'),
|
20 | ResultBuilder:require('./src/protocol/ResultBuilder'),
|
21 | ShooterBuilder:require('./src/protocol/ShooterBuilder'),
|
22 | ShotBuilder:require('./src/protocol/ShotBuilder')
|
23 | };
|
24 |
|
25 | },{"./src/protocol/Builder":3,"./src/protocol/CardBuilder":4,"./src/protocol/ConfigBuilder":5,"./src/protocol/RangeBuilder":6,"./src/protocol/ResultBuilder":7,"./src/protocol/ShooterBuilder":8,"./src/protocol/ShotBuilder":9,"./src/renderer/CardRenderer":10,"./src/renderer/RangeRenderer":13,"./src/renderer/Renderer":14,"./src/renderer/RingTargetRenderer":15,"./src/renderer/ShotRenderer":16,"./src/renderer/TargetRenderer":17,"./src/renderer/TriangleRenderer":18,"./src/renderer/megalink/MegalinkCardRenderer":19,"./src/renderer/megalink/MegalinkRangeRenderer":20,"./src/scaler/RingTargetScaler":23,"./src/scaler/Scaler":24,"./src/target/RingTargetBuilder":25,"./src/target/targets":37}],2:[function(require,module,exports){
|
26 | if (typeof Object.create === 'function') {
|
27 |
|
28 | module.exports = function inherits(ctor, superCtor) {
|
29 | ctor.super_ = superCtor
|
30 | ctor.prototype = Object.create(superCtor.prototype, {
|
31 | constructor: {
|
32 | value: ctor,
|
33 | enumerable: false,
|
34 | writable: true,
|
35 | configurable: true
|
36 | }
|
37 | });
|
38 | };
|
39 | } else {
|
40 |
|
41 | module.exports = function inherits(ctor, superCtor) {
|
42 | ctor.super_ = superCtor
|
43 | var TempCtor = function () {}
|
44 | TempCtor.prototype = superCtor.prototype
|
45 | ctor.prototype = new TempCtor()
|
46 | ctor.prototype.constructor = ctor
|
47 | }
|
48 | }
|
49 |
|
50 | },{}],3:[function(require,module,exports){
|
51 | function Builder() {
|
52 | this.reset();
|
53 | }
|
54 |
|
55 | module.exports = Builder;
|
56 |
|
57 |
|
58 | Builder.blankCopy = function (defaultObject) {
|
59 | return cloneDeep(defaultObject);
|
60 | };
|
61 |
|
62 | Builder.sanitize = function (rawObject, defaultObject) {
|
63 | return set(rawObject, this.blankCopy(defaultObject));
|
64 | };
|
65 |
|
66 | // --- Non-static methods ---
|
67 | Builder._default = {};
|
68 |
|
69 | Builder.prototype.reset = function () {
|
70 | this._object = Builder.blankCopy(this.constructor._default);
|
71 |
|
72 | return this;
|
73 | };
|
74 |
|
75 | Builder.prototype.getObject = function () {
|
76 | return cloneDeep(this._object);
|
77 | };
|
78 |
|
79 | Builder.prototype.setObject = function (rawObject) {
|
80 | this._object = Builder.sanitize(rawObject, this.constructor._default);
|
81 |
|
82 | return this;
|
83 | };
|
84 |
|
85 |
|
86 |
|
87 | function set(from, to) {
|
88 | for (var key in to) {
|
89 | if (!from.hasOwnProperty(key)) {
|
90 | continue;
|
91 | }
|
92 |
|
93 | var value = from[key];
|
94 |
|
95 | if (value instanceof Array) {
|
96 | to[key] = [].concat(value);
|
97 | } else {
|
98 | to[key] = value;
|
99 | }
|
100 | }
|
101 |
|
102 | return to;
|
103 | }
|
104 |
|
105 | function clone(object) {
|
106 | var copy = {};
|
107 |
|
108 | for (var key in object) {
|
109 | var value = object[key];
|
110 |
|
111 | if (value instanceof Array) {
|
112 | copy[key] = [].concat(value);
|
113 | } else {
|
114 | copy[key] = value;
|
115 | }
|
116 | }
|
117 |
|
118 | return copy;
|
119 | }
|
120 |
|
121 | function cloneDeep(object) {
|
122 | if (!(object instanceof Object)) {
|
123 | return object;
|
124 | }
|
125 |
|
126 | var copy = {};
|
127 |
|
128 | for (var key in object) {
|
129 | var value = object[key];
|
130 |
|
131 | if (value instanceof Array) {
|
132 | copy[key] = [];
|
133 |
|
134 | for (var idx in value) {
|
135 | copy[key].push(cloneDeep(value[idx]));
|
136 | }
|
137 | } else {
|
138 | copy[key] = cloneDeep(value);
|
139 | }
|
140 | }
|
141 |
|
142 | return copy;
|
143 | }
|
144 |
|
145 | },{}],4:[function(require,module,exports){
|
146 | var Builder = require('./Builder');
|
147 | var inherits = require('inherits');
|
148 | var ConfigBuilder = require('./ConfigBuilder');
|
149 | var ResultBuilder = require('./ResultBuilder');
|
150 | var ShooterBuilder = require('./ShooterBuilder');
|
151 |
|
152 | function CardBuilder() {
|
153 | this.initialize();
|
154 | this.reset();
|
155 | }
|
156 |
|
157 | module.exports = CardBuilder;
|
158 | inherits(CardBuilder, Builder);
|
159 |
|
160 | CardBuilder._default = {
|
161 | lane:'',
|
162 | shooter:ShooterBuilder.createBlankShooter(),
|
163 | result:ResultBuilder.createBlankResult(),
|
164 | config:ConfigBuilder.createBlankConfig()
|
165 | };
|
166 |
|
167 |
|
168 | CardBuilder.createBlankCard = function () {
|
169 | return Builder.blankCopy(this._default);
|
170 | };
|
171 |
|
172 | CardBuilder.sanitizeCard = function (rawCard) {
|
173 | var card = Builder.sanitize(rawCard, this._default);
|
174 |
|
175 | card.shooter = ShooterBuilder.sanitizeShooter(card.shooter);
|
176 | card.result = ResultBuilder.sanitizeResult(card.result);
|
177 | card.config = ConfigBuilder.sanitizeConfig(card.config);
|
178 |
|
179 | return card;
|
180 | };
|
181 |
|
182 | CardBuilder.prototype.reset = function () {
|
183 | Builder.prototype.reset.apply(this);
|
184 |
|
185 | this._object.shooter = this._shooterBuilder.reset().getShooter();
|
186 | this._object.result = this._resultBuilder.reset().getResult();
|
187 | this._object.config = this._configBuilder.reset().getConfig();
|
188 |
|
189 | return this;
|
190 | };
|
191 |
|
192 | CardBuilder.prototype.getCard = function () {
|
193 | return this.getObject();
|
194 | };
|
195 |
|
196 |
|
197 | CardBuilder.prototype.setCard = function (card) {
|
198 | this.setObject(card);
|
199 |
|
200 | this.setConfig(card.config || {});
|
201 | this.setResult(card.result || {});
|
202 | this.setShooter(card.shooter || {});
|
203 |
|
204 | return this;
|
205 | };
|
206 |
|
207 | CardBuilder.prototype.setConfig = function (config) {
|
208 | this._object.config = this._configBuilder.setConfig(config).getConfig();
|
209 |
|
210 | return this;
|
211 | };
|
212 |
|
213 | CardBuilder.prototype.setResult = function (result) {
|
214 | this._object.result = this._resultBuilder.setResult(result).getResult();
|
215 |
|
216 | return this;
|
217 | };
|
218 |
|
219 | CardBuilder.prototype.setShooter = function (shooter) {
|
220 | this._object.shooter = this._shooterBuilder.setShooter(shooter).getShooter();
|
221 |
|
222 | return this;
|
223 | };
|
224 |
|
225 |
|
226 | CardBuilder.prototype.setLane = function (lane) {
|
227 | this._object.lane = lane;
|
228 |
|
229 | return this;
|
230 | };
|
231 |
|
232 | CardBuilder.prototype.setName = function (name) {
|
233 | this._object.shooter = this._shooterBuilder.setName(name).getShooter();
|
234 |
|
235 | return this;
|
236 | };
|
237 |
|
238 | CardBuilder.prototype.setClub = function (club) {
|
239 | this._object.shooter = this._shooterBuilder.setClub(club).getShooter();
|
240 |
|
241 | return this;
|
242 | };
|
243 |
|
244 | CardBuilder.prototype.setClassName = function (className) {
|
245 | this._object.shooter = this._shooterBuilder.setClassName(className).getShooter();
|
246 |
|
247 | return this;
|
248 | };
|
249 |
|
250 | CardBuilder.prototype.setCategory = function (category) {
|
251 | this._object.shooter = this._shooterBuilder.setCategory(category).getShooter();
|
252 |
|
253 | return this;
|
254 | };
|
255 |
|
256 | CardBuilder.prototype.setSeriesName = function (seriesName) {
|
257 | this._object.result = this._resultBuilder.setSeriesName(seriesName).getResult();
|
258 |
|
259 | return this;
|
260 | };
|
261 |
|
262 | CardBuilder.prototype.setSeriesSum = function (seriesSum) {
|
263 | this._object.result = this._resultBuilder.setSeriesSum(seriesSum).getResult();
|
264 |
|
265 | return this;
|
266 | };
|
267 |
|
268 | CardBuilder.prototype.setTotalSum = function (totalSum) {
|
269 | this._object.result = this._resultBuilder.setTotalSum(totalSum).getResult();
|
270 |
|
271 | return this;
|
272 | };
|
273 |
|
274 | CardBuilder.prototype.setMarking = function (marking) {
|
275 | this._object.result = this._resultBuilder.setMarking(marking).getResult();
|
276 |
|
277 | return this;
|
278 | };
|
279 |
|
280 | CardBuilder.prototype.setGaugeSize = function (gaugeSize) {
|
281 | this._object.config = this._configBuilder.setGaugeSize(gaugeSize).getConfig();
|
282 |
|
283 | return this;
|
284 | };
|
285 |
|
286 | CardBuilder.prototype.setTargetID = function (targetID) {
|
287 | this._object.config = this._configBuilder.setTargetID(targetID).getConfig();
|
288 |
|
289 | return this;
|
290 | };
|
291 |
|
292 | CardBuilder.prototype.setShots = function (shots) {
|
293 | this._object.result = this._resultBuilder.setShots(shots).getResult();
|
294 |
|
295 | return this;
|
296 | };
|
297 |
|
298 | CardBuilder.prototype.resetShots = function () {
|
299 | this._object.result = this._resultBuilder.resetShots().getResult();
|
300 |
|
301 | return this;
|
302 | };
|
303 |
|
304 | CardBuilder.prototype.addShot = function (shot) {
|
305 | this._object.result = this._resultBuilder.addShot(shot).getResult();
|
306 |
|
307 | return this;
|
308 | };
|
309 |
|
310 | CardBuilder.prototype.addShotData = function (x, y, value) {
|
311 | this._object.result = this._resultBuilder.addShotData(x, y, value).getResult();
|
312 |
|
313 | return this;
|
314 | };
|
315 |
|
316 |
|
317 | CardBuilder.prototype.initialize = function () {
|
318 | this._shooterBuilder = new ShooterBuilder();
|
319 | this._resultBuilder = new ResultBuilder();
|
320 | this._configBuilder = new ConfigBuilder();
|
321 | };
|
322 |
|
323 | },{"./Builder":3,"./ConfigBuilder":5,"./ResultBuilder":7,"./ShooterBuilder":8,"inherits":2}],5:[function(require,module,exports){
|
324 | var Builder = require('./Builder');
|
325 | var inherits = require('inherits');
|
326 |
|
327 | function ConfigBuilder() {
|
328 | this.reset();
|
329 | }
|
330 |
|
331 | module.exports = ConfigBuilder;
|
332 | inherits(ConfigBuilder, Builder);
|
333 |
|
334 | ConfigBuilder._default = {
|
335 | gaugeSize:.02,
|
336 | targetID:'NO_DFS_200M'
|
337 | };
|
338 |
|
339 | ConfigBuilder.createBlankConfig = function () {
|
340 | return Builder.blankCopy(this._default);
|
341 | };
|
342 |
|
343 | ConfigBuilder.sanitizeConfig = function (config) {
|
344 | return Builder.sanitize(config, this._default);
|
345 | };
|
346 |
|
347 | ConfigBuilder.prototype.getConfig = function () {
|
348 | return this.getObject();
|
349 | };
|
350 |
|
351 | ConfigBuilder.prototype.setConfig = function (config) {
|
352 | return this.setObject(config);
|
353 | };
|
354 |
|
355 | ConfigBuilder.prototype.setGaugeSize = function (gaugeSize) {
|
356 | this._object.gaugeSize = gaugeSize;
|
357 |
|
358 | return this;
|
359 | };
|
360 |
|
361 | ConfigBuilder.prototype.setTargetID = function (targetID) {
|
362 | this._object.targetID = targetID;
|
363 |
|
364 | return this;
|
365 | };
|
366 |
|
367 | },{"./Builder":3,"inherits":2}],6:[function(require,module,exports){
|
368 | var Builder = require('./Builder');
|
369 | var inherits = require('inherits');
|
370 |
|
371 | function RangeBuilder() {
|
372 | this.reset();
|
373 | };
|
374 |
|
375 | module.exports = RangeBuilder;
|
376 | inherits(RangeBuilder, Builder);
|
377 |
|
378 | RangeBuilder._default = {
|
379 | host:'',
|
380 | name:'',
|
381 | relay:''
|
382 | };
|
383 |
|
384 |
|
385 | RangeBuilder.createBlankRange = function () {
|
386 | return Builder.blankCopy(this._default);
|
387 | };
|
388 |
|
389 | RangeBuilder.sanitizeRange = function (rawRange) {
|
390 | return Builder.sanitize(rawRange, this._default);
|
391 | };
|
392 |
|
393 | RangeBuilder.prototype.getRange = function () {
|
394 | return this.getObject();
|
395 | };
|
396 |
|
397 | RangeBuilder.prototype.setRange = function (range) {
|
398 | this.setObject(range);
|
399 |
|
400 | return this;
|
401 | };
|
402 |
|
403 |
|
404 | RangeBuilder.prototype.setHost = function (host) {
|
405 | this._object.host = host;
|
406 |
|
407 | return this;
|
408 | };
|
409 |
|
410 | RangeBuilder.prototype.setName = function (name) {
|
411 | this._object.name = name;
|
412 |
|
413 | return this;
|
414 | };
|
415 |
|
416 | RangeBuilder.prototype.setRelay = function (relay) {
|
417 | this._object.relay = relay;
|
418 |
|
419 | return this;
|
420 | };
|
421 |
|
422 | },{"./Builder":3,"inherits":2}],7:[function(require,module,exports){
|
423 | var Builder = require('./Builder');
|
424 | var ShotBuilder = require('./ShotBuilder');
|
425 | var inherits = require('inherits');
|
426 |
|
427 | function ResultBuilder() {
|
428 | this.initialize();
|
429 | this.reset();
|
430 | }
|
431 |
|
432 | module.exports = ResultBuilder;
|
433 | inherits(ResultBuilder, Builder);
|
434 |
|
435 | ResultBuilder._default = {
|
436 | seriesName:'',
|
437 | seriesSum:'',
|
438 | totalSum:'',
|
439 | marking:false,
|
440 | shots:[]
|
441 | };
|
442 |
|
443 |
|
444 | ResultBuilder.createBlankResult = function () {
|
445 | return Builder.blankCopy(this._default);
|
446 | };
|
447 |
|
448 | ResultBuilder.sanitizeResult = function (rawResult) {
|
449 | var result = Builder.sanitize(rawResult, this._default);
|
450 |
|
451 | for (var key in result.shots) {
|
452 | result.shots[key] = ShotBuilder.sanitizeShot(result.shots[key]);
|
453 | }
|
454 |
|
455 | return result;
|
456 | };
|
457 |
|
458 | ResultBuilder.prototype.resetShots = function () {
|
459 | this._object.shots = [];
|
460 |
|
461 | return this;
|
462 | };
|
463 |
|
464 | ResultBuilder.prototype.getResult = function () {
|
465 | return this.getObject();
|
466 | };
|
467 |
|
468 | ResultBuilder.prototype.setResult = function (result) {
|
469 | this.setObject(result);
|
470 | this.setShots(result.shots || []);
|
471 |
|
472 | return this;
|
473 | };
|
474 |
|
475 | ResultBuilder.prototype.setSeriesName = function (seriesName) {
|
476 | this._object.seriesName = seriesName;
|
477 |
|
478 | return this;
|
479 | };
|
480 |
|
481 | ResultBuilder.prototype.setSeriesSum = function (seriesSum) {
|
482 | this._object.seriesSum = seriesSum;
|
483 |
|
484 | return this;
|
485 | };
|
486 |
|
487 | ResultBuilder.prototype.setTotalSum = function (totalSum) {
|
488 | this._object.totalSum = totalSum;
|
489 |
|
490 | return this;
|
491 | };
|
492 |
|
493 | ResultBuilder.prototype.setMarking = function (marking) {
|
494 | this._object.marking = marking;
|
495 |
|
496 | return this;
|
497 | };
|
498 |
|
499 | ResultBuilder.prototype.setShots = function (shots) {
|
500 | this.resetShots();
|
501 |
|
502 | for (var idx in shots) {
|
503 | this.addShot(ShotBuilder.sanitizeShot(shots[idx]));
|
504 | }
|
505 |
|
506 | return this;
|
507 | };
|
508 |
|
509 | ResultBuilder.prototype.addShot = function (shot) {
|
510 | this._object.shots.push(shot);
|
511 |
|
512 | return this;
|
513 | };
|
514 |
|
515 | ResultBuilder.prototype.addShotData = function (x, y, value) {
|
516 | var shot = this._shotBuilder.reset()
|
517 | .setPosition(x, y)
|
518 | .setValue(value)
|
519 | .getShot();
|
520 |
|
521 | return this.addShot(shot);
|
522 | };
|
523 |
|
524 |
|
525 | ResultBuilder.prototype.initialize = function () {
|
526 | this._shotBuilder = new ShotBuilder();
|
527 | };
|
528 |
|
529 | },{"./Builder":3,"./ShotBuilder":9,"inherits":2}],8:[function(require,module,exports){
|
530 | var Builder = require('./Builder');
|
531 | var inherits = require('inherits');
|
532 |
|
533 | function ShooterBuilder() {
|
534 | this.reset();
|
535 | }
|
536 |
|
537 | module.exports = ShooterBuilder;
|
538 | inherits(ShooterBuilder, Builder);
|
539 |
|
540 | ShooterBuilder._default = {
|
541 | name:'',
|
542 | club:'',
|
543 | className:'',
|
544 | category:''
|
545 | };
|
546 |
|
547 | ShooterBuilder.createBlankShooter = function () {
|
548 | return Builder.blankCopy(this._default);
|
549 | };
|
550 |
|
551 | ShooterBuilder.sanitizeShooter = function (shooter) {
|
552 | return Builder.sanitize(shooter, this._default);
|
553 | };
|
554 |
|
555 | ShooterBuilder.prototype.getShooter = function () {
|
556 | return this.getObject();
|
557 | };
|
558 |
|
559 | ShooterBuilder.prototype.setShooter = function (shooter) {
|
560 | return this.setObject(shooter);
|
561 | };
|
562 |
|
563 | ShooterBuilder.prototype.setName = function (name) {
|
564 | this._object.name = name;
|
565 |
|
566 | return this;
|
567 | };
|
568 |
|
569 | ShooterBuilder.prototype.setClub = function (club) {
|
570 | this._object.club = club;
|
571 |
|
572 | return this;
|
573 | };
|
574 |
|
575 | ShooterBuilder.prototype.setClassName = function (className) {
|
576 | this._object.className = className;
|
577 |
|
578 | return this;
|
579 | };
|
580 |
|
581 | ShooterBuilder.prototype.setCategory = function (category) {
|
582 | this._object.category = category;
|
583 |
|
584 | return this;
|
585 | };
|
586 |
|
587 | },{"./Builder":3,"inherits":2}],9:[function(require,module,exports){
|
588 | var Builder = require('./Builder');
|
589 | var inherits = require('inherits');
|
590 |
|
591 | function ShotBuilder() {
|
592 | this.reset();
|
593 | }
|
594 |
|
595 | module.exports = ShotBuilder;
|
596 | inherits(ShotBuilder, Builder);
|
597 |
|
598 | ShotBuilder._default = {
|
599 | x:0,
|
600 | y:0,
|
601 | value:''
|
602 | };
|
603 |
|
604 | ShotBuilder.createBlankShot = function () {
|
605 | return Builder.blankCopy(this._default);
|
606 | };
|
607 |
|
608 | ShotBuilder.sanitizeShot = function (shot) {
|
609 | return Builder.sanitize(shot, this._default);
|
610 | };
|
611 |
|
612 | ShotBuilder.prototype.getShot = function () {
|
613 | return this.getObject();
|
614 | };
|
615 |
|
616 | ShotBuilder.prototype.setShot = function (shot) {
|
617 | return this.setObject(shot);
|
618 | };
|
619 |
|
620 | ShotBuilder.prototype.setPosition = function (x, y) {
|
621 | this.setX(x);
|
622 | this.setY(y);
|
623 |
|
624 | return this;
|
625 | };
|
626 |
|
627 | ShotBuilder.prototype.setX = function (x) {
|
628 | this._object.x = x;
|
629 |
|
630 | return this;
|
631 | };
|
632 |
|
633 | ShotBuilder.prototype.setY = function (y) {
|
634 | this._object.y = y;
|
635 |
|
636 | return this;
|
637 | };
|
638 |
|
639 | ShotBuilder.prototype.setValue = function (value) {
|
640 | this._object.value = value;
|
641 |
|
642 | return this;
|
643 | };
|
644 |
|
645 | },{"./Builder":3,"inherits":2}],10:[function(require,module,exports){
|
646 | var inherits = require('inherits');
|
647 | var targets = require('../target/targets');
|
648 |
|
649 | var Renderer = require('./Renderer');
|
650 | var TriangleRenderer = require('./TriangleRenderer');
|
651 | var CardBuilder = require('../protocol/CardBuilder');
|
652 |
|
653 | function CardRenderer() {
|
654 | Renderer.prototype.constructor.apply(this);
|
655 |
|
656 | this.initialize();
|
657 | }
|
658 |
|
659 | module.exports = CardRenderer;
|
660 | inherits(CardRenderer, Renderer);
|
661 |
|
662 |
|
663 | CardRenderer.prototype.setStyle = function (style) {
|
664 | for (var key in this.style) {
|
665 | if (style.hasOwnProperty(key))
|
666 | this.style[key] = style[key];
|
667 | }
|
668 |
|
669 | this.targetRenderer.setStyle(style);
|
670 | this.shotRenderer.setStyle(style);
|
671 | this.triangleRenderer.setStyle(style);
|
672 |
|
673 | return this;
|
674 | };
|
675 |
|
676 | CardRenderer.prototype.setCard = function (card, valid) {
|
677 | if (!valid) {
|
678 | card = CardBuilder.sanitizeCard(card);
|
679 | }
|
680 |
|
681 | this.card = card;
|
682 |
|
683 | this.setTarget(this.card.config.targetID);
|
684 | this.setGaugeSize(this.card.config.gaugeSize);
|
685 | this.setShots(this.card.result.shots);
|
686 |
|
687 | return this;
|
688 | };
|
689 |
|
690 |
|
691 | CardRenderer.prototype.initialize = function () {
|
692 | this.style = {
|
693 | backColor:'rgb(255, 255, 255)',
|
694 | frontColor:'rgb(0, 0, 0)'
|
695 | };
|
696 |
|
697 | this.triangleRenderer = new TriangleRenderer();
|
698 |
|
699 | this.setCard(CardBuilder.createBlankCard());
|
700 | };
|
701 |
|
702 | CardRenderer.prototype.draw = function () {
|
703 | this.updateScale();
|
704 |
|
705 | this.drawTarget();
|
706 | this.drawShots();
|
707 | this.drawTriangle();
|
708 | };
|
709 |
|
710 | CardRenderer.prototype.updateScale = function () {
|
711 | var prevScale = this.scale;
|
712 | this.scale = this.scaler.getScale();
|
713 |
|
714 | this.targetRenderer.setScale(this.scale);
|
715 | this.shotRenderer.setScale(this.scale);
|
716 |
|
717 | if (prevScale && prevScale > this.scale) {
|
718 | this.clearTarget();
|
719 | }
|
720 | };
|
721 |
|
722 | CardRenderer.prototype.clearTarget = function () {
|
723 | var targetRect = this.getTargetRect();
|
724 |
|
725 | this.context.clearRect(targetRect.x, targetRect.y, targetRect.width, targetRect.height);
|
726 | };
|
727 |
|
728 | CardRenderer.prototype.drawTarget = function () {
|
729 | this.targetRenderer.render();
|
730 | };
|
731 |
|
732 | CardRenderer.prototype.drawShots = function () {
|
733 | this.shotRenderer.render();
|
734 | };
|
735 |
|
736 | CardRenderer.prototype.drawTriangle = function () {
|
737 | if (!this.card.result.marking) {
|
738 | this.triangleRenderer.render();
|
739 | }
|
740 | };
|
741 |
|
742 | CardRenderer.prototype.setPosition = function (x, y) {
|
743 | var res = Renderer.prototype.setPosition.apply(this, [x, y]);
|
744 |
|
745 | this.updateTargetRect();
|
746 |
|
747 | return res;
|
748 | };
|
749 |
|
750 | CardRenderer.prototype.setSize = function (width, height) {
|
751 | var res = Renderer.prototype.setSize.apply(this, [width, height]);
|
752 |
|
753 | this.updateTargetRect();
|
754 |
|
755 | return res;
|
756 | };
|
757 |
|
758 | CardRenderer.prototype.setRect = function (rect) {
|
759 | var res = Renderer.prototype.setRect.apply(this, [rect]);
|
760 |
|
761 | this.updateTargetRect();
|
762 |
|
763 | return res;
|
764 | };
|
765 |
|
766 | CardRenderer.prototype.updateTargetRect = function () {
|
767 | var targetRect = this.getTargetRect();
|
768 |
|
769 | this.targetRenderer.setRect(targetRect);
|
770 | this.shotRenderer.setRect(targetRect);
|
771 | this.triangleRenderer.setRect(targetRect);
|
772 | };
|
773 |
|
774 | CardRenderer.prototype.setContext = function (context) {
|
775 | var res = Renderer.prototype.setContext.apply(this, [context]);
|
776 |
|
777 | this.targetRenderer.setContext(this.context);
|
778 | this.shotRenderer.setContext(this.context);
|
779 | this.triangleRenderer.setContext(this.context);
|
780 |
|
781 | return this;
|
782 | };
|
783 |
|
784 | CardRenderer.prototype.setTarget = function (targetID) {
|
785 | if (this.targetID == targetID) {
|
786 | return;
|
787 | }
|
788 |
|
789 | this.targetID = targetID;
|
790 |
|
791 | this.scaler = targets.getScaler(this.targetID);
|
792 |
|
793 | var targetStyle = this.targetRenderer ? this.targetRenderer.style : {};
|
794 | this.targetRenderer = targets.getTargetRenderer(this.targetID);
|
795 | this.targetRenderer.setStyle(targetStyle);
|
796 |
|
797 | var shotStyle = this.shotRenderer ? this.shotRenderer.style : {};
|
798 | this.shotRenderer = targets.getShotRenderer(this.targetID);
|
799 | this.shotRenderer.setStyle(targetStyle);
|
800 |
|
801 | this.setRect(this.rect);
|
802 | this.setContext(this.context);
|
803 | };
|
804 |
|
805 | CardRenderer.prototype.setShots = function (shots) {
|
806 | if (this.shots == shots) {
|
807 | return;
|
808 | }
|
809 |
|
810 | this.shots = shots;
|
811 |
|
812 | this.scaler.setShots(shots);
|
813 | this.shotRenderer.setShots(shots);
|
814 | };
|
815 |
|
816 | CardRenderer.prototype.setGaugeSize = function (gaugeSize) {
|
817 | if (this.gaugeSize == gaugeSize) {
|
818 | return;
|
819 | }
|
820 |
|
821 | this.gaugeSize = gaugeSize;
|
822 | this.shotRenderer.setStyle({gaugeSize:gaugeSize});
|
823 | };
|
824 |
|
825 |
|
826 | CardRenderer.prototype.getTargetRect = function () {
|
827 | return CardRenderer.getTargetRect(this.rect);
|
828 | };
|
829 |
|
830 | CardRenderer.getTargetRect = function (rect) {
|
831 | return rect;
|
832 | };
|
833 |
|
834 | },{"../protocol/CardBuilder":4,"../target/targets":37,"./Renderer":14,"./TriangleRenderer":18,"inherits":2}],11:[function(require,module,exports){
|
835 | var ShotRenderer = require('./ShotRenderer');
|
836 | var ISSFSilhouetteFinalPistolTargetRenderer = require('./ISSFSilhouetteFinalPistolTargetRenderer');
|
837 |
|
838 | function ISSFSilhouetteFinalPistolShotRenderer() {
|
839 | ShotRenderer.prototype.constructor.apply(this);
|
840 | }
|
841 |
|
842 | ISSFSilhouetteFinalPistolShotRenderer.prototype = new ShotRenderer();
|
843 | ISSFSilhouetteFinalPistolShotRenderer.prototype.constructor = ISSFSilhouetteFinalPistolShotRenderer;
|
844 | module.exports = ISSFSilhouetteFinalPistolShotRenderer;
|
845 |
|
846 | ISSFSilhouetteFinalPistolShotRenderer.prototype.initialize = function () {
|
847 | ShotRenderer.prototype.initialize.apply(this);
|
848 |
|
849 | this.style.markerSize = 0.025;
|
850 | this.style.missedMarkerColor = this.style.lastMarkerColor;
|
851 | this.style.hitMarkerColor = this.style.markerColor;
|
852 | };
|
853 |
|
854 | ISSFSilhouetteFinalPistolShotRenderer.prototype.drawShots = function () {
|
855 |
|
856 | var i = 0;
|
857 | var targetSpacing = ISSFSilhouetteFinalPistolTargetRenderer.TARGET_SPACING;
|
858 | var targetWidth = (1 - 6*targetSpacing)/5;
|
859 |
|
860 | for (var idx in this.shots) {
|
861 | var shot = this.shots[idx];
|
862 | var j = 4 - i;
|
863 |
|
864 | if (shot.value !== '-1 ') {
|
865 | this.drawShot({
|
866 | x: shot.x*targetWidth/2 + ((j + 1)*targetSpacing + (j + 0.5)*targetWidth) - 0.5,
|
867 | y: shot.y*targetWidth/2,
|
868 | value: shot.value
|
869 | }, shot.value === '1 ' ? this.style.hitMarkerColor : this.style.missedMarkerColor);
|
870 | }
|
871 |
|
872 | ++i;
|
873 | }
|
874 | };
|
875 |
|
876 | ISSFSilhouetteFinalPistolShotRenderer.prototype.getShotScale = function () {
|
877 | return this.scale*this.rect.width;
|
878 | };
|
879 |
|
880 | },{"./ISSFSilhouetteFinalPistolTargetRenderer":12,"./ShotRenderer":16}],12:[function(require,module,exports){
|
881 | var TargetRenderer = require('./TargetRenderer');
|
882 | var RingTargetRenderer = require('./RingTargetRenderer');
|
883 |
|
884 | function ISSFSilhouetteFinalPistolTargetRenderer() {
|
885 | TargetRenderer.prototype.constructor.apply(this);
|
886 | }
|
887 |
|
888 | ISSFSilhouetteFinalPistolTargetRenderer.prototype = new TargetRenderer();
|
889 | ISSFSilhouetteFinalPistolTargetRenderer.prototype.constructor = ISSFSilhouetteFinalPistolTargetRenderer;
|
890 | ISSFSilhouetteFinalPistolTargetRenderer.TARGET_SPACING = 0.02;
|
891 | module.exports = ISSFSilhouetteFinalPistolTargetRenderer;
|
892 |
|
893 |
|
894 | ISSFSilhouetteFinalPistolTargetRenderer.prototype.setTarget = function (target) {
|
895 | this.renderer.setTarget(target);
|
896 |
|
897 | return this;
|
898 | };
|
899 |
|
900 | ISSFSilhouetteFinalPistolTargetRenderer.prototype.setStyle = function (style) {
|
901 | var ret = TargetRenderer.prototype.setStyle.apply(this, [style]);
|
902 | this.renderer.setStyle(style);
|
903 |
|
904 | return ret;
|
905 | };
|
906 |
|
907 | ISSFSilhouetteFinalPistolTargetRenderer.prototype.setContext = function (context) {
|
908 | var ret = TargetRenderer.prototype.setContext.apply(this, [context]);
|
909 | this.renderer.setContext(context);
|
910 |
|
911 | return ret;
|
912 | };
|
913 |
|
914 |
|
915 | ISSFSilhouetteFinalPistolTargetRenderer.prototype.initialize = function () {
|
916 | TargetRenderer.prototype.initialize.apply(this);
|
917 |
|
918 | this.renderer = new RingTargetRenderer()
|
919 | .setScale(1);
|
920 | };
|
921 |
|
922 | ISSFSilhouetteFinalPistolTargetRenderer.prototype.render = function () {
|
923 | this.context.fillStyle = this.style.backColor;
|
924 | this.context.fillRect(this.rect.x, this.rect.y, this.rect.width, this.rect.height);
|
925 |
|
926 | var width = this.rect.width;
|
927 | var targetSpacing = ISSFSilhouetteFinalPistolTargetRenderer.TARGET_SPACING;
|
928 | var targetWidth = width*(1 - 6*targetSpacing)/5;
|
929 |
|
930 |
|
931 | for (var i = 0; i < 5; ++i) {
|
932 | var rect = {
|
933 | x: this.rect.x + targetWidth*i + width*targetSpacing*(i + 1),
|
934 | y: this.rect.y,
|
935 | width: targetWidth,
|
936 | height: this.rect.height
|
937 | };
|
938 |
|
939 | this.renderer.setRect(rect);
|
940 | this.renderer.render();
|
941 | }
|
942 | };
|
943 |
|
944 | },{"./RingTargetRenderer":15,"./TargetRenderer":17}],13:[function(require,module,exports){
|
945 | var inherits = require('inherits');
|
946 |
|
947 | var Renderer = require('./Renderer');
|
948 | var CardRenderer = require('./CardRenderer');
|
949 | var RangeBuilder = require('../protocol/RangeBuilder');
|
950 |
|
951 | function RangeRenderer() {
|
952 | Renderer.prototype.constructor.apply(this);
|
953 |
|
954 | this.initialize();
|
955 | }
|
956 |
|
957 | module.exports = RangeRenderer;
|
958 | inherits(RangeRenderer, Renderer);
|
959 |
|
960 |
|
961 | RangeRenderer.prototype.setStyle = function (style) {
|
962 | for (var key in style) {
|
963 | this.rawStyle[key] = style[key];
|
964 | }
|
965 |
|
966 | for (var key in this.style) {
|
967 | if (style.hasOwnProperty(key))
|
968 | this.style[key] = style[key];
|
969 | }
|
970 |
|
971 | for (var idx in this.cardRenderers) {
|
972 | this.cardRenderers[idx].setStyle(style);
|
973 | }
|
974 |
|
975 | return this;
|
976 | };
|
977 |
|
978 | RangeRenderer.prototype.setRange = function (range, valid) {
|
979 | if (!valid) {
|
980 | range = RangeBuilder.sanitizeRange(range);
|
981 | }
|
982 |
|
983 | this.range = range;
|
984 |
|
985 | return this;
|
986 | };
|
987 |
|
988 | RangeRenderer.prototype.setCards = function (cards, valid) {
|
989 |
|
990 | for (var idx in cards) {
|
991 | this.setCard(idx, cards[idx], valid, true);
|
992 | }
|
993 |
|
994 |
|
995 | for (var idx in this.cardRenderers) {
|
996 | if (!cards.hasOwnProperty(idx)) {
|
997 | this.removeCard(idx, true);
|
998 | }
|
999 | }
|
1000 |
|
1001 | this.pushCardRects();
|
1002 |
|
1003 | return this;
|
1004 | };
|
1005 |
|
1006 | RangeRenderer.prototype.setCard = function (idx, card, valid, maintainRects) {
|
1007 | if (!this.cardRenderers.hasOwnProperty(idx)) {
|
1008 | this.addCardRenderer(idx);
|
1009 |
|
1010 | if (!maintainRects) {
|
1011 | this.pushCardRects();
|
1012 | }
|
1013 | }
|
1014 |
|
1015 | this.cardRenderers[idx].setCard(card, valid);
|
1016 |
|
1017 | return this;
|
1018 | };
|
1019 |
|
1020 | RangeRenderer.prototype.removeCard = function (idx, maintainRects) {
|
1021 | this.removeCardRenderer(idx);
|
1022 |
|
1023 | if (!maintainRects) {
|
1024 | this.pushCardRects();
|
1025 | }
|
1026 |
|
1027 | return this;
|
1028 | };
|
1029 |
|
1030 |
|
1031 | RangeRenderer.prototype.initialize = function () {
|
1032 | this.cardRenderers = {};
|
1033 | this.rawStyle = {};
|
1034 | this.style = {};
|
1035 | this.numCardRenderers = 0;
|
1036 |
|
1037 | this.setRange(RangeBuilder.createBlankRange());
|
1038 | };
|
1039 |
|
1040 | RangeRenderer.prototype.setContext = function (context) {
|
1041 | var res = Renderer.prototype.setContext.apply(this, [context]);
|
1042 |
|
1043 | for (var idx in this.cardRenderers) {
|
1044 | this.cardRenderers[idx].setContext(this.context);
|
1045 | }
|
1046 |
|
1047 | return res;
|
1048 | };
|
1049 |
|
1050 | RangeRenderer.prototype.setRect = function (rect) {
|
1051 | var res = Renderer.prototype.setRect.apply(this, [rect]);
|
1052 |
|
1053 | this.pushCardRects();
|
1054 |
|
1055 | return res;
|
1056 | };
|
1057 |
|
1058 | RangeRenderer.prototype.addCardRenderer = function (idx) {
|
1059 | var renderer = new this.CardRenderer();
|
1060 | renderer.setContext(this.context);
|
1061 | renderer.setStyle(this.rawStyle);
|
1062 |
|
1063 | this.cardRenderers[idx] = renderer;
|
1064 |
|
1065 | ++this.numCardRenderers;
|
1066 | };
|
1067 |
|
1068 | RangeRenderer.prototype.removeCardRenderer = function (idx) {
|
1069 | delete this.cardRenderers[idx];
|
1070 | --this.numCardRenderers;
|
1071 | };
|
1072 |
|
1073 | RangeRenderer.prototype.draw = function () {
|
1074 | for (var idx in this.cardRenderers) {
|
1075 | this.cardRenderers[idx].render();
|
1076 | }
|
1077 | };
|
1078 |
|
1079 | RangeRenderer.prototype.pushCardRects = function () {
|
1080 | var rect = this.getCardsRect();
|
1081 | var layout = this.getCardsLayout();
|
1082 |
|
1083 | var cardNum = 0;
|
1084 | var cardIndices = this.getCardIndices();
|
1085 | var cardWidth = rect.width/layout.numCols;
|
1086 | var cardHeight = rect.height/layout.numRows;
|
1087 |
|
1088 | for (var i = 0; i < layout.numRows; ++i) {
|
1089 | for (var j = 0; j < layout.numCols; ++j) {
|
1090 | if (cardNum >= cardIndices.length) {
|
1091 | return;
|
1092 | }
|
1093 |
|
1094 | var cardIdx = cardIndices[cardNum++];
|
1095 |
|
1096 | var leftEdge = Math.floor(j*cardWidth) + rect.x;
|
1097 | var rightEdge = Math.floor((j + 1)*cardWidth) + rect.x;
|
1098 | var topEdge = Math.floor(i*cardHeight) + rect.y;
|
1099 | var bottomEdge = Math.floor((i + 1)*cardHeight) + rect.y;
|
1100 |
|
1101 | this.cardRenderers[cardIdx].setRect({
|
1102 | x: leftEdge,
|
1103 | y: topEdge,
|
1104 | width: rightEdge - leftEdge,
|
1105 | height: bottomEdge - topEdge
|
1106 | });
|
1107 | }
|
1108 | }
|
1109 | };
|
1110 |
|
1111 | RangeRenderer.prototype.getCardIndices = function () {
|
1112 | var indices = [];
|
1113 |
|
1114 | for (var idx in this.cardRenderers) {
|
1115 | indices.push(idx);
|
1116 | }
|
1117 |
|
1118 | return indices;
|
1119 | };
|
1120 |
|
1121 | RangeRenderer.prototype.CardRenderer = CardRenderer;
|
1122 |
|
1123 |
|
1124 | RangeRenderer.prototype.getCardsRect = function () {
|
1125 | return this.rect;
|
1126 | };
|
1127 |
|
1128 | RangeRenderer.prototype.getCardsLayout = function () {
|
1129 | var rect = this.getCardsRect();
|
1130 | var N = this.numCardRenderers;
|
1131 | var minBadness = Number.MAX_VALUE;
|
1132 | var bestM = 0;
|
1133 | var bestN = 0;
|
1134 |
|
1135 | if (N == 5 || N == 7) {
|
1136 | ++N;
|
1137 | }
|
1138 |
|
1139 | for (var m = 1; m <= N; ++m) {
|
1140 | var n = Math.ceil(N / m);
|
1141 | var cardWidth = rect.width/n;
|
1142 | var cardHeight = rect.height/m;
|
1143 | var targetRect = this.CardRenderer.getTargetRect({x: 0, y: 0, width: cardWidth, height: cardHeight});
|
1144 |
|
1145 | var aspectRatio = targetRect.width / targetRect.height;
|
1146 | var optimalRatio = 1;
|
1147 | var ratioBadness = Math.abs(aspectRatio - optimalRatio) + Math.abs(1/aspectRatio - 1/optimalRatio);
|
1148 | var cellCountBadness = Math.abs(n*m - N);
|
1149 | var badness = ratioBadness + cellCountBadness;
|
1150 |
|
1151 | if (badness < minBadness) {
|
1152 | minBadness = badness;
|
1153 | bestM = m;
|
1154 | bestN = n;
|
1155 | }
|
1156 | }
|
1157 |
|
1158 | return {
|
1159 | numCols: bestN,
|
1160 | numRows: bestM
|
1161 | };
|
1162 | };
|
1163 |
|
1164 | },{"../protocol/RangeBuilder":6,"./CardRenderer":10,"./Renderer":14,"inherits":2}],14:[function(require,module,exports){
|
1165 | function Renderer() {
|
1166 | this.rect = {
|
1167 | x:0,
|
1168 | y:0,
|
1169 | width:0,
|
1170 | height:0
|
1171 | };
|
1172 | }
|
1173 |
|
1174 | module.exports = Renderer;
|
1175 |
|
1176 |
|
1177 | Renderer.prototype.render = function () {
|
1178 | var ctx = this.context;
|
1179 |
|
1180 | ctx.save();
|
1181 |
|
1182 | this.clipContext();
|
1183 | this.draw();
|
1184 |
|
1185 | ctx.restore();
|
1186 |
|
1187 | return this;
|
1188 | };
|
1189 |
|
1190 | Renderer.prototype.setPosition = function (x, y) {
|
1191 | this.rect.x = x;
|
1192 | this.rect.y = y;
|
1193 |
|
1194 | return this;
|
1195 | };
|
1196 |
|
1197 | Renderer.prototype.setSize = function (width, height) {
|
1198 | this.rect.width = width;
|
1199 | this.rect.height = height;
|
1200 |
|
1201 | return this;
|
1202 | };
|
1203 |
|
1204 | Renderer.prototype.setRect = function (rect) {
|
1205 | this.rect = rect;
|
1206 |
|
1207 | return this;
|
1208 | };
|
1209 |
|
1210 | Renderer.prototype.setContext = function (context) {
|
1211 | this.context = context;
|
1212 |
|
1213 | return this;
|
1214 | };
|
1215 |
|
1216 |
|
1217 | Renderer.prototype.centerContext = function () {
|
1218 | var ctx = this.context;
|
1219 |
|
1220 | ctx.translate(this.rect.x, this.rect.y);
|
1221 | ctx.translate(this.rect.width/2, this.rect.height/2);
|
1222 | };
|
1223 |
|
1224 | Renderer.prototype.draw = function () {
|
1225 |
|
1226 | };
|
1227 |
|
1228 | Renderer.prototype.clipContext = function () {
|
1229 | var ctx = this.context;
|
1230 |
|
1231 | ctx.save();
|
1232 | this.centerContext();
|
1233 |
|
1234 | ctx.beginPath();
|
1235 | ctx.rect(-this.rect.width/2, -this.rect.height/2, this.rect.width, this.rect.height);
|
1236 | ctx.closePath();
|
1237 | ctx.restore();
|
1238 |
|
1239 | ctx.clip();
|
1240 | };
|
1241 |
|
1242 | },{}],15:[function(require,module,exports){
|
1243 | var TargetRenderer = require('./TargetRenderer');
|
1244 |
|
1245 | function RingTargetRenderer() {
|
1246 | TargetRenderer.prototype.constructor.apply(this);
|
1247 |
|
1248 | this.style.drawFullTarget = false;
|
1249 | this.style.ringLineWidth = .75;
|
1250 | }
|
1251 |
|
1252 | RingTargetRenderer.prototype = new TargetRenderer();
|
1253 | RingTargetRenderer.prototype.constructor = RingTargetRenderer;
|
1254 | module.exports = RingTargetRenderer;
|
1255 |
|
1256 |
|
1257 | RingTargetRenderer.prototype.setTarget = function (target) {
|
1258 | this.target = target;
|
1259 |
|
1260 | return this;
|
1261 | };
|
1262 |
|
1263 |
|
1264 | RingTargetRenderer.prototype.drawTarget = function () {
|
1265 | this.drawBackground();
|
1266 | this.drawRings();
|
1267 | this.drawNumbers();
|
1268 | };
|
1269 |
|
1270 | RingTargetRenderer.prototype.drawBackground = function () {
|
1271 | var ctx = this.context;
|
1272 | var size = this.getSize();
|
1273 |
|
1274 |
|
1275 | var backSize = this.getMaxSize();
|
1276 | ctx.fillStyle = this.style.backColor;
|
1277 |
|
1278 | ctx.beginPath();
|
1279 | ctx.arc(0, 0, backSize * size, 0, Math.PI*2, true);
|
1280 | ctx.closePath();
|
1281 | ctx.fill();
|
1282 |
|
1283 |
|
1284 | var frontSize = Math.min(this.target.frontSize, this.getMaxSize());
|
1285 | ctx.fillStyle = this.style.frontColor;
|
1286 |
|
1287 | ctx.beginPath();
|
1288 | ctx.arc(0, 0, frontSize * size, 0, Math.PI*2, true);
|
1289 | ctx.closePath();
|
1290 | ctx.fill();
|
1291 |
|
1292 |
|
1293 | if (this.target.drawSightLines) {
|
1294 | ctx.beginPath();
|
1295 | ctx.fillStyle = this.style.backColor;
|
1296 | ctx.fillRect(-frontSize*size, -0.01*frontSize*size, frontSize*size/2, 0.02*frontSize*size);
|
1297 | ctx.fillStyle = this.style.backColor;
|
1298 | ctx.fillRect(frontSize*size/2, -0.01*frontSize*size, frontSize*size/2, 0.02*frontSize*size);
|
1299 | ctx.closePath();
|
1300 | ctx.fill();
|
1301 | }
|
1302 | };
|
1303 |
|
1304 | RingTargetRenderer.prototype.drawRings = function () {
|
1305 | var ctx = this.context;
|
1306 | var frontSize = this.target.frontSize;
|
1307 | var ringSizes = this.target.ringSizes;
|
1308 | var size = this.getSize();
|
1309 | var pixelRatio = window.devicePixelRatio || 1;
|
1310 |
|
1311 | for (var idx in ringSizes) {
|
1312 | var ringSize = ringSizes[idx];
|
1313 |
|
1314 | if (ringSize == frontSize || ringSize > this.getMaxSize()) {
|
1315 | continue;
|
1316 | }
|
1317 |
|
1318 | var radius = ringSize*size;
|
1319 | var isFrontRing = ringSize <= frontSize;
|
1320 | ctx.strokeStyle = isFrontRing
|
1321 | ? this.style.backColor
|
1322 | : this.style.frontColor;
|
1323 | ctx.lineWidth = this.style.ringLineWidth*pixelRatio;
|
1324 |
|
1325 | ctx.beginPath();
|
1326 | ctx.arc(0, 0, radius, 0, Math.PI*2, true);
|
1327 | ctx.closePath();
|
1328 |
|
1329 | ctx.stroke();
|
1330 |
|
1331 | if (isFrontRing && this.target.drawSightLines && ringSize > 0.5*frontSize) {
|
1332 | var dh = 0.01*frontSize*size;
|
1333 | var alpha = Math.asin(dh/radius);
|
1334 |
|
1335 | ctx.strokeStyle = this.style.frontColor;
|
1336 | ctx.beginPath();
|
1337 | ctx.arc(0, 0, radius, -alpha, alpha, false);
|
1338 | ctx.closePath();
|
1339 |
|
1340 | ctx.stroke();
|
1341 |
|
1342 | ctx.beginPath();
|
1343 | ctx.arc(0, 0, radius, Math.PI - alpha, Math.PI + alpha, false);
|
1344 | ctx.closePath();
|
1345 |
|
1346 | ctx.stroke();
|
1347 | }
|
1348 | }
|
1349 | };
|
1350 |
|
1351 | RingTargetRenderer.prototype.drawNumbers = function () {
|
1352 | var ctx = this.context;
|
1353 | var size = this.getSize();
|
1354 |
|
1355 | for (var i = 0; i + 1 < this.target.ringSizes.length
|
1356 | && i + this.target.numbersFrom <= this.target.numbersTo; ++i) {
|
1357 | var number = i + this.target.numbersFrom;
|
1358 | var lowerRingSize = this.target.ringSizes[i];
|
1359 | var upperRingSize = this.target.ringSizes[i + 1];
|
1360 |
|
1361 | if (lowerRingSize > this.getMaxSize()) {
|
1362 | continue;
|
1363 | }
|
1364 |
|
1365 | var d = (lowerRingSize + upperRingSize) / 2 * size;
|
1366 |
|
1367 | if (lowerRingSize > this.target.frontSize) {
|
1368 | ctx.fillStyle = this.style.frontColor;
|
1369 | } else {
|
1370 | ctx.fillStyle = this.style.backColor;
|
1371 | }
|
1372 |
|
1373 | if (this.target.drawHorisontalNumbers) {
|
1374 | this.drawNumber(number, -d, 0);
|
1375 | this.drawNumber(number, d, 0);
|
1376 | }
|
1377 |
|
1378 | if (this.target.drawVerticalNumbers) {
|
1379 | this.drawNumber(number, 0, -d);
|
1380 | this.drawNumber(number, 0, d);
|
1381 | }
|
1382 | }
|
1383 | };
|
1384 |
|
1385 | RingTargetRenderer.prototype.drawNumber = function (number, dx, dy) {
|
1386 | var ctx = this.context;
|
1387 | var size = this.getSize();
|
1388 |
|
1389 | ctx.font = "36px arial";
|
1390 | ctx.textBaseline = "middle";
|
1391 | ctx.textAlign = "center";
|
1392 |
|
1393 | ctx.save();
|
1394 | ctx.translate(dx, dy);
|
1395 | ctx.scale(1/500 * size, 1/500 * size);
|
1396 |
|
1397 | ctx.fillText(number, 0, 0);
|
1398 |
|
1399 | ctx.restore();
|
1400 | };
|
1401 |
|
1402 | RingTargetRenderer.prototype.getSize = function () {
|
1403 | return this.scale * Math.min(this.rect.width, this.rect.height)/2;
|
1404 | };
|
1405 |
|
1406 | RingTargetRenderer.prototype.getMaxSize = function () {
|
1407 | var maxSize = 1;
|
1408 |
|
1409 | if (!this.style.drawFullTarget)
|
1410 | maxSize = Math.min(maxSize, 1 / this.scale);
|
1411 |
|
1412 | return maxSize;
|
1413 | };
|
1414 |
|
1415 | },{"./TargetRenderer":17}],16:[function(require,module,exports){
|
1416 | var Renderer = require('./Renderer');
|
1417 |
|
1418 | function ShotRenderer() {
|
1419 | Renderer.prototype.constructor.apply(this);
|
1420 |
|
1421 | this.initialize();
|
1422 | }
|
1423 |
|
1424 | ShotRenderer.prototype = new Renderer();
|
1425 | ShotRenderer.prototype.constructor = ShotRenderer;
|
1426 | module.exports = ShotRenderer;
|
1427 |
|
1428 |
|
1429 | ShotRenderer.prototype.setStyle = function (style) {
|
1430 | for (var key in this.style) {
|
1431 | if (style.hasOwnProperty(key))
|
1432 | this.style[key] = style[key];
|
1433 | }
|
1434 |
|
1435 | return this;
|
1436 | };
|
1437 |
|
1438 | ShotRenderer.prototype.setShots = function (shots) {
|
1439 | this.shots = shots;
|
1440 |
|
1441 | return this;
|
1442 | };
|
1443 |
|
1444 | ShotRenderer.prototype.setScale = function (scale) {
|
1445 | this.scale = scale;
|
1446 |
|
1447 | return this;
|
1448 | };
|
1449 |
|
1450 |
|
1451 | ShotRenderer.prototype.initialize = function () {
|
1452 | this.scale = 1;
|
1453 | this.shots = {};
|
1454 | this.style = {
|
1455 | gaugeSize:.015,
|
1456 | gaugeColor:'rgb(0, 0, 0)',
|
1457 | markerSize:.05,
|
1458 | markerColor:'rgb(0, 255, 0)',
|
1459 | lastMarkerColor:'rgb(255, 0, 0)'
|
1460 | };
|
1461 | };
|
1462 |
|
1463 | ShotRenderer.prototype.draw = function () {
|
1464 | var ctx = this.context;
|
1465 | ctx.save();
|
1466 |
|
1467 | this.centerContext();
|
1468 | this.drawShots();
|
1469 |
|
1470 | ctx.restore();
|
1471 | };
|
1472 |
|
1473 | ShotRenderer.prototype.drawShots = function () {
|
1474 |
|
1475 | var shot = null;
|
1476 | for (var idx in this.shots) {
|
1477 | if (shot) {
|
1478 | this.drawShot(shot, this.style.markerColor);
|
1479 | }
|
1480 |
|
1481 | shot = this.shots[idx];
|
1482 | }
|
1483 |
|
1484 |
|
1485 | if (shot)
|
1486 | this.drawShot(shot, this.style.lastMarkerColor);
|
1487 | };
|
1488 |
|
1489 | ShotRenderer.prototype.drawShot = function (shot, markerColor) {
|
1490 | var ctx = this.context;
|
1491 | var scale = this.getShotScale();
|
1492 |
|
1493 | ctx.save();
|
1494 | ctx.scale(scale, scale);
|
1495 | ctx.translate(shot.x, shot.y);
|
1496 |
|
1497 | if (this.style.gaugeSize > .7*this.style.markerSize) {
|
1498 | this.renderShotWithoutGauge(shot, markerColor, scale);
|
1499 | } else {
|
1500 | this.renderShotWithGauge(shot, markerColor);
|
1501 | }
|
1502 |
|
1503 | ctx.restore();
|
1504 | };
|
1505 |
|
1506 | ShotRenderer.prototype.renderShotWithGauge = function (shot, markerColor) {
|
1507 | var ctx = this.context;
|
1508 |
|
1509 |
|
1510 | ctx.beginPath();
|
1511 | ctx.arc(0, 0, this.style.markerSize, 0, Math.PI*2, true);
|
1512 | ctx.closePath();
|
1513 |
|
1514 | ctx.fillStyle = markerColor;
|
1515 | ctx.fill();
|
1516 |
|
1517 |
|
1518 | ctx.beginPath();
|
1519 | ctx.arc(0, 0, this.style.gaugeSize, 0, Math.PI*2, true);
|
1520 | ctx.closePath();
|
1521 |
|
1522 | ctx.fillStyle = this.style.gaugeColor;
|
1523 | ctx.fill();
|
1524 | };
|
1525 |
|
1526 | ShotRenderer.prototype.renderShotWithoutGauge = function (shot, markerColor, scale) {
|
1527 | var ctx = this.context;
|
1528 | var pixelRatio = window.devicePixelRatio || 1;
|
1529 | ctx.save();
|
1530 |
|
1531 | ctx.beginPath();
|
1532 | ctx.arc(0, 0, this.style.gaugeSize, 0, Math.PI*2, true);
|
1533 | ctx.closePath();
|
1534 |
|
1535 | ctx.fillStyle = markerColor;
|
1536 | ctx.fill();
|
1537 |
|
1538 | ctx.scale(1/scale, 1/scale);
|
1539 | ctx.strokeStyle = this.style.gaugeColor;
|
1540 | ctx.lineWidth = .5*pixelRatio;
|
1541 | ctx.stroke();
|
1542 |
|
1543 | ctx.restore();
|
1544 | };
|
1545 |
|
1546 | ShotRenderer.prototype.getShotScale = function () {
|
1547 | return this.scale * Math.min(this.rect.width, this.rect.height)/2;
|
1548 | };
|
1549 |
|
1550 | },{"./Renderer":14}],17:[function(require,module,exports){
|
1551 | var Renderer = require('./Renderer');
|
1552 |
|
1553 | function TargetRenderer() {
|
1554 | Renderer.prototype.constructor.apply(this);
|
1555 |
|
1556 | this.initialize();
|
1557 | }
|
1558 |
|
1559 | TargetRenderer.prototype = new Renderer();
|
1560 | TargetRenderer.prototype.constructor = TargetRenderer;
|
1561 | module.exports = TargetRenderer;
|
1562 |
|
1563 |
|
1564 | TargetRenderer.prototype.setStyle = function (style) {
|
1565 | for (var key in this.style) {
|
1566 | if (style.hasOwnProperty(key))
|
1567 | this.style[key] = style[key];
|
1568 | }
|
1569 |
|
1570 | return this;
|
1571 | };
|
1572 |
|
1573 | TargetRenderer.prototype.setScale = function (scale) {
|
1574 | this.scale = scale;
|
1575 |
|
1576 | return this;
|
1577 | };
|
1578 |
|
1579 |
|
1580 | TargetRenderer.prototype.initialize = function () {
|
1581 | this.scale = 1;
|
1582 | this.style = {
|
1583 | backColor:'rgb(255, 255, 255)',
|
1584 | frontColor:'rgb(0, 0, 0)'
|
1585 | };
|
1586 | };
|
1587 |
|
1588 | TargetRenderer.prototype.draw = function () {
|
1589 | var ctx = this.context;
|
1590 | ctx.save();
|
1591 |
|
1592 | this.centerContext();
|
1593 | this.drawTarget();
|
1594 |
|
1595 | ctx.restore();
|
1596 | };
|
1597 |
|
1598 | TargetRenderer.prototype.drawTarget = function () {
|
1599 |
|
1600 | };
|
1601 |
|
1602 | },{"./Renderer":14}],18:[function(require,module,exports){
|
1603 | var Renderer = require('./Renderer');
|
1604 |
|
1605 | function TriangleRenderer() {
|
1606 | Renderer.prototype.constructor.apply(this);
|
1607 |
|
1608 | this.initialize();
|
1609 | }
|
1610 |
|
1611 | TriangleRenderer.prototype = new Renderer();
|
1612 | TriangleRenderer.prototype.constructor = TriangleRenderer;
|
1613 | module.exports = TriangleRenderer;
|
1614 |
|
1615 |
|
1616 | TriangleRenderer.prototype.setStyle = function (style) {
|
1617 | for (var key in this.style) {
|
1618 | if (style.hasOwnProperty(key))
|
1619 | this.style[key] = style[key];
|
1620 | }
|
1621 |
|
1622 | return this;
|
1623 | };
|
1624 |
|
1625 |
|
1626 | TriangleRenderer.prototype.initialize = function () {
|
1627 | this.style = {
|
1628 | color:'rgb(150, 150, 150)',
|
1629 | borderColor:'rgb(50, 50, 50)',
|
1630 | size:.2
|
1631 | };
|
1632 | };
|
1633 |
|
1634 | TriangleRenderer.prototype.draw = function () {
|
1635 | var ctx = this.context;
|
1636 | var size = this.style.size;
|
1637 | var pixelRatio = window.devicePixelRatio || 1;
|
1638 |
|
1639 | ctx.save();
|
1640 |
|
1641 | ctx.translate(this.rect.x, this.rect.y);
|
1642 | ctx.scale(this.rect.width, this.rect.width);
|
1643 |
|
1644 | ctx.beginPath();
|
1645 | ctx.moveTo(1, 0);
|
1646 | ctx.lineTo(1 - size, 0);
|
1647 | ctx.lineTo(1, size);
|
1648 | ctx.closePath();
|
1649 |
|
1650 | ctx.fillStyle = this.style.color;
|
1651 | ctx.fill();
|
1652 |
|
1653 | ctx.beginPath();
|
1654 | ctx.moveTo(1 - size, 0);
|
1655 | ctx.lineTo(1, size);
|
1656 | ctx.closePath();
|
1657 |
|
1658 | ctx.scale(1/this.rect.width, 1/this.rect.width);
|
1659 |
|
1660 | ctx.strokeStyle = this.style.borderColor;
|
1661 | ctx.lineWidth = .5*pixelRatio;
|
1662 | ctx.stroke();
|
1663 |
|
1664 | ctx.restore();
|
1665 | };
|
1666 |
|
1667 | },{"./Renderer":14}],19:[function(require,module,exports){
|
1668 | var inherits = require('inherits');
|
1669 | var CardRenderer = require('../CardRenderer');
|
1670 | var utils = require('./utils');
|
1671 |
|
1672 |
|
1673 | var MARGINH = 5;
|
1674 | var MARGINV = 3;
|
1675 |
|
1676 | var MAX_SHOTS = 10;
|
1677 |
|
1678 | var BACKGROUND_COLOR = 'rgb(255, 255, 255)';
|
1679 | var FRONT_COLOR = 'rgb(0, 0, 0)';
|
1680 |
|
1681 | var GAUGE_COLOR = 'rgb(0, 0, 0)';
|
1682 | var MARKER_COLOR = 'rgb(0, 255, 0)';
|
1683 | var LAST_MARKER_COLOR = 'rgb(255, 0, 0)';
|
1684 |
|
1685 | var TRIANGLE_COLOR = 'rgb(200, 200, 200)';
|
1686 | var TRIANGLE_BORDER_COLOR = 'rgb(150, 150, 150)';
|
1687 |
|
1688 | var LANE_NUMBER_BACK_COLOR = 'rgba(64, 64, 64, 0.7)';
|
1689 | var LANE_NUMBER_FRONT_COLOR = 'rgb(245, 245, 245)';
|
1690 |
|
1691 | function MegalinkCardRenderer() {
|
1692 | CardRenderer.prototype.constructor.apply(this);
|
1693 | }
|
1694 |
|
1695 | module.exports = MegalinkCardRenderer;
|
1696 | inherits(MegalinkCardRenderer, CardRenderer);
|
1697 |
|
1698 |
|
1699 | MegalinkCardRenderer.prototype.initialize = function () {
|
1700 | CardRenderer.prototype.initialize.apply(this);
|
1701 |
|
1702 | this.style.backColor = BACKGROUND_COLOR;
|
1703 | this.style.frontColor = FRONT_COLOR;
|
1704 |
|
1705 | this.shotRenderer.setStyle({
|
1706 | gaugeColor: GAUGE_COLOR,
|
1707 | markerColor: MARKER_COLOR,
|
1708 | lastMarkerColor: LAST_MARKER_COLOR
|
1709 | });
|
1710 |
|
1711 | this.triangleRenderer.setStyle({
|
1712 | color: TRIANGLE_COLOR,
|
1713 | borderColor: TRIANGLE_BORDER_COLOR
|
1714 | });
|
1715 | };
|
1716 |
|
1717 | MegalinkCardRenderer.prototype.setTarget = function (targetId) {
|
1718 | CardRenderer.prototype.setTarget.apply(this, [targetId]);
|
1719 |
|
1720 | this.targetRenderer.setStyle({
|
1721 | drawFullTarget:true
|
1722 | });
|
1723 | };
|
1724 |
|
1725 | MegalinkCardRenderer.prototype.draw = function () {
|
1726 | CardRenderer.prototype.draw.apply(this);
|
1727 |
|
1728 | this.drawLaneNumber();
|
1729 | this.drawHeader();
|
1730 | this.drawShotList();
|
1731 | this.drawSums();
|
1732 | };
|
1733 |
|
1734 | MegalinkCardRenderer.prototype.drawTarget = function () {
|
1735 | CardRenderer.prototype.drawTarget.apply(this);
|
1736 |
|
1737 | utils.strokeFrame(this.context, MegalinkCardRenderer.getTargetRect(this.rect), this.style.frontColor);
|
1738 | };
|
1739 |
|
1740 | MegalinkCardRenderer.prototype.drawLaneNumber = function () {
|
1741 | var rect = MegalinkCardRenderer.getLaneNumberRect(this.rect);
|
1742 | var laneNumber = this.card.lane;
|
1743 |
|
1744 | this.context.fillStyle = LANE_NUMBER_BACK_COLOR;
|
1745 | this.context.fillRect(rect.x, rect.y, rect.width, rect.height);
|
1746 |
|
1747 | utils.setFont(this.context, laneNumber, .8*rect.width, .8*rect.height);
|
1748 | this.context.textBaseline = "middle";
|
1749 | this.context.textAlign = "center";
|
1750 |
|
1751 | this.context.fillStyle = LANE_NUMBER_FRONT_COLOR;
|
1752 | this.context.fillText(laneNumber, rect.x + rect.width/2, rect.y + rect.height/2);
|
1753 | };
|
1754 |
|
1755 | MegalinkCardRenderer.prototype.drawHeader = function () {
|
1756 | utils.drawFrame(this.context, MegalinkCardRenderer.getHeaderRect(this.rect), this.style.frontColor, this.style.backColor);
|
1757 |
|
1758 | this.drawName();
|
1759 | this.drawClub();
|
1760 | this.drawSeriesName();
|
1761 | this.drawClass();
|
1762 | this.drawCategory();
|
1763 | };
|
1764 |
|
1765 | MegalinkCardRenderer.prototype.drawName = function () {
|
1766 | var name = this.card.shooter.name;
|
1767 | var rect = MegalinkCardRenderer.getNameRect(this.rect);
|
1768 |
|
1769 | utils.setFont(this.context, name, rect.width, rect.height);
|
1770 | this.context.textBaseline = "top";
|
1771 | this.context.textAlign = "left";
|
1772 |
|
1773 | this.context.fillStyle = this.style.frontColor;
|
1774 | this.context.fillText(name, rect.x, rect.y);
|
1775 | };
|
1776 |
|
1777 | MegalinkCardRenderer.prototype.drawClub = function () {
|
1778 | var club = this.card.shooter.club;
|
1779 | var rect = MegalinkCardRenderer.getClubRect(this.rect);
|
1780 |
|
1781 | utils.setFont(this.context, club, rect.width, rect.height);
|
1782 | this.context.textBaseline = "bottom";
|
1783 | this.context.textAlign = "left";
|
1784 |
|
1785 | this.context.fillStyle = this.style.frontColor;
|
1786 | this.context.fillText(club, rect.x, rect.y + rect.height);
|
1787 | };
|
1788 |
|
1789 | MegalinkCardRenderer.prototype.drawSeriesName = function () {
|
1790 | var seriesName = this.card.result.seriesName;
|
1791 | var rect = MegalinkCardRenderer.getSeriesNameRect(this.rect);
|
1792 |
|
1793 | utils.setFont(this.context, seriesName, rect.width, rect.height);
|
1794 | this.context.textBaseline = "bottom";
|
1795 | this.context.textAlign = "left";
|
1796 |
|
1797 | this.context.fillStyle = this.style.frontColor;
|
1798 | this.context.fillText(seriesName, rect.x, rect.y + rect.height);
|
1799 | };
|
1800 |
|
1801 | MegalinkCardRenderer.prototype.drawClass = function () {
|
1802 | var className = this.card.shooter.className;
|
1803 | var rect = MegalinkCardRenderer.getClassRect(this.rect);
|
1804 |
|
1805 | utils.setFont(this.context, className, rect.width, rect.height);
|
1806 | this.context.textBaseline = "bottom";
|
1807 | this.context.textAlign = "right";
|
1808 |
|
1809 | this.context.fillStyle = this.style.frontColor;
|
1810 | this.context.fillText(className, rect.x + rect.width, rect.y + rect.height);
|
1811 | };
|
1812 |
|
1813 | MegalinkCardRenderer.prototype.drawCategory = function () {
|
1814 | var category = this.card.shooter.category;
|
1815 | var rect = MegalinkCardRenderer.getCategoryRect(this.rect);
|
1816 |
|
1817 | utils.setFont(this.context, category, rect.width, rect.height);
|
1818 | this.context.textBaseline = "bottom";
|
1819 | this.context.textAlign = "right";
|
1820 |
|
1821 | this.context.fillStyle = this.style.frontColor;
|
1822 | this.context.fillText(category, rect.x + rect.width, rect.y + rect.height);
|
1823 | };
|
1824 |
|
1825 | MegalinkCardRenderer.prototype.drawShotList = function () {
|
1826 | utils.drawFrame(this.context, MegalinkCardRenderer.getShotListRect(this.rect), this.style.frontColor, this.style.backColor);
|
1827 |
|
1828 | this.drawShotListFrame();
|
1829 | this.drawShotListContent();
|
1830 | };
|
1831 |
|
1832 | MegalinkCardRenderer.prototype.drawShotListFrame = function () {
|
1833 | var rect = MegalinkCardRenderer.getShotListRect(this.rect);
|
1834 |
|
1835 | var numRows = this.getNumRows();
|
1836 | var numColumns = this.getNumColumns();
|
1837 | var rowHeight = rect.height / numRows;
|
1838 | var columnWidth = rect.width / numColumns;
|
1839 |
|
1840 | var pixelRatio = window.devicePixelRatio || 1;
|
1841 |
|
1842 | this.context.strokeStyle = this.style.frontColor;
|
1843 | this.context.lineWidth = 1*pixelRatio;
|
1844 | this.context.beginPath();
|
1845 |
|
1846 | for (var i = 1; i < numRows; ++i) {
|
1847 | var y = rect.y + i*rowHeight;
|
1848 |
|
1849 | this.context.moveTo(rect.x, y);
|
1850 | this.context.lineTo(rect.x + rect.width, y);
|
1851 | }
|
1852 |
|
1853 | for (var i = 1; i < numColumns; ++i) {
|
1854 | var x = rect.x + i*columnWidth;
|
1855 |
|
1856 | this.context.moveTo(x, rect.y);
|
1857 | this.context.lineTo(x, rect.y + rect.height);
|
1858 | }
|
1859 |
|
1860 | this.context.stroke();
|
1861 | this.context.closePath();
|
1862 | };
|
1863 |
|
1864 | MegalinkCardRenderer.prototype.drawShotListContent = function () {
|
1865 | var offset = Math.max(0, this.card.result.shots.length - MAX_SHOTS);
|
1866 | var shots = this.card.result.shots.slice(-MAX_SHOTS);
|
1867 | var shotNum = 1;
|
1868 |
|
1869 | for (var idx in shots) {
|
1870 | var shot = shots[idx];
|
1871 | this.drawShotContent(shotNum + offset, shot, this.getShotRect(shotNum));
|
1872 |
|
1873 | ++shotNum;
|
1874 | }
|
1875 | };
|
1876 |
|
1877 | MegalinkCardRenderer.prototype.drawShotContent = function (shotNum, shot, rect) {
|
1878 | utils.setFont(this.context, '10:', .4*rect.width, .9*rect.height);
|
1879 | this.context.textBaseline = 'middle';
|
1880 | this.context.fillStyle = this.style.frontColor;
|
1881 |
|
1882 |
|
1883 | this.context.textAlign = 'left';
|
1884 | this.context.fillText(shotNum + ':', rect.x + 5, rect.y - rect.height/2);
|
1885 |
|
1886 |
|
1887 | this.context.textAlign = 'right';
|
1888 | this.context.fillText(shot.value, rect.x + rect.width - 5, rect.y - rect.height/2);
|
1889 | };
|
1890 |
|
1891 | MegalinkCardRenderer.prototype.getNumRows = function () {
|
1892 | return 5;
|
1893 | };
|
1894 |
|
1895 | MegalinkCardRenderer.prototype.getNumColumns = function () {
|
1896 | var numShots = 0;
|
1897 | for (var idx in this.card.result.shots) ++numShots;
|
1898 |
|
1899 | return Math.min(2, Math.ceil(numShots / this.getNumRows()));
|
1900 | };
|
1901 |
|
1902 | MegalinkCardRenderer.prototype.drawSums = function () {
|
1903 | var rect = MegalinkCardRenderer.getSumsRect(this.rect);
|
1904 |
|
1905 | utils.drawFrame(this.context, rect, this.style.frontColor, this.style.backColor);
|
1906 |
|
1907 | this.context.fillStyle = this.style.frontColor;
|
1908 | this.context.fillRect(rect.x + .5*rect.width, rect.y, .5*rect.width, rect.height);
|
1909 |
|
1910 |
|
1911 | var seriesSum = this.card.result.seriesSum;
|
1912 | var totalSum = this.card.result.totalSum;
|
1913 |
|
1914 | utils.setFont(this.context, totalSum, .6*rect.width, .6*rect.height);
|
1915 | this.context.textBaseline = "middle";
|
1916 | this.context.textAlign = "center";
|
1917 |
|
1918 | this.context.fillStyle = this.style.frontColor;
|
1919 | this.context.fillText(seriesSum, rect.x + .25*rect.width, rect.y + .5*rect.height);
|
1920 |
|
1921 | this.context.fillStyle = this.style.backColor;
|
1922 | this.context.fillText(totalSum, rect.x + .75*rect.width, rect.y + .5*rect.height);
|
1923 | };
|
1924 |
|
1925 |
|
1926 | MegalinkCardRenderer.isPortrait = function (rect) {
|
1927 | return rect.width / rect.height < 1;
|
1928 | };
|
1929 |
|
1930 | MegalinkCardRenderer.prototype.getTargetRect = function () {
|
1931 | return MegalinkCardRenderer.getTargetRect(this.rect);
|
1932 | };
|
1933 |
|
1934 | MegalinkCardRenderer.getTargetRect = function (rect) {
|
1935 | if (MegalinkCardRenderer.isPortrait(rect)) {
|
1936 | return {
|
1937 | x:rect.x,
|
1938 | y:rect.y + .125*rect.height,
|
1939 | width:rect.width,
|
1940 | height:.5*rect.height
|
1941 | }
|
1942 | } else {
|
1943 | return {
|
1944 | x:rect.x,
|
1945 | y:rect.y + .25*rect.height,
|
1946 | width:.6*rect.width,
|
1947 | height:.75*rect.height
|
1948 | };
|
1949 | }
|
1950 | };
|
1951 |
|
1952 | MegalinkCardRenderer.getHeaderRect = function (rect) {
|
1953 | if (MegalinkCardRenderer.isPortrait(rect)) {
|
1954 | return {
|
1955 | x:rect.x,
|
1956 | y:rect.y,
|
1957 | width:rect.width,
|
1958 | height:.125*rect.height
|
1959 | };
|
1960 | } else {
|
1961 | return {
|
1962 | x:rect.x,
|
1963 | y:rect.y,
|
1964 | width:rect.width,
|
1965 | height:.25*rect.height
|
1966 | };
|
1967 | }
|
1968 | };
|
1969 |
|
1970 | MegalinkCardRenderer.getNameRect = function (rect) {
|
1971 | var rect = MegalinkCardRenderer.getHeaderRect(rect);
|
1972 |
|
1973 | var width = rect.width;
|
1974 | var height = .55*rect.height;
|
1975 |
|
1976 | return {
|
1977 | x:rect.x + MARGINH,
|
1978 | y:rect.y + MARGINV,
|
1979 | width:width - 2*MARGINH,
|
1980 | height:height - 2*MARGINV
|
1981 | };
|
1982 | };
|
1983 |
|
1984 | MegalinkCardRenderer.getClubRect = function (rect) {
|
1985 | var rect = MegalinkCardRenderer.getHeaderRect(rect);
|
1986 |
|
1987 | var width = .55*rect.width;
|
1988 | var height = .45*rect.height;
|
1989 |
|
1990 | return {
|
1991 | x:rect.x + MARGINH,
|
1992 | y:rect.y + rect.height - height + MARGINV,
|
1993 | width:width - 3/2*MARGINH,
|
1994 | height:height - 2*MARGINV
|
1995 | };
|
1996 | };
|
1997 |
|
1998 | MegalinkCardRenderer.getSeriesNameRect = function (rect) {
|
1999 | var rect = MegalinkCardRenderer.getHeaderRect(rect);
|
2000 |
|
2001 | var width = .25*rect.width;
|
2002 | var height = .45*rect.height;
|
2003 |
|
2004 | return {
|
2005 | x:rect.x + .55*rect.width + MARGINH/2,
|
2006 | y:rect.y + rect.height - height + MARGINV,
|
2007 | width:width - MARGINH,
|
2008 | height:height - 2*MARGINV
|
2009 | };
|
2010 | };
|
2011 |
|
2012 | MegalinkCardRenderer.getClassRect = function (rect) {
|
2013 | var rect = MegalinkCardRenderer.getHeaderRect(rect);
|
2014 |
|
2015 | var width = .13*rect.width;
|
2016 | var height = .45*rect.height;
|
2017 |
|
2018 | return {
|
2019 | x:rect.x + .8*rect.width + MARGINH/2,
|
2020 | y:rect.y + rect.height - height + MARGINV,
|
2021 | width:width - MARGINH,
|
2022 | height:height - 2*MARGINV
|
2023 | };
|
2024 | };
|
2025 |
|
2026 | MegalinkCardRenderer.getCategoryRect = function (rect) {
|
2027 | var rect = MegalinkCardRenderer.getHeaderRect(rect);
|
2028 |
|
2029 | var width = .07*rect.width;
|
2030 | var height = .45*rect.height;
|
2031 |
|
2032 | return {
|
2033 | x:rect.x + .93*rect.width + MARGINH/2,
|
2034 | y:rect.y + rect.height - height + MARGINV,
|
2035 | width:width - 3/2*MARGINH,
|
2036 | height:height - 2*MARGINV
|
2037 | };
|
2038 | };
|
2039 |
|
2040 | MegalinkCardRenderer.getShotListRect = function (rect) {
|
2041 | if (MegalinkCardRenderer.isPortrait(rect)) {
|
2042 | return {
|
2043 | x:rect.x,
|
2044 | y:rect.y + .625*rect.height,
|
2045 | width:rect.width,
|
2046 | height:.25*rect.height
|
2047 | };
|
2048 | } else {
|
2049 | return {
|
2050 | x:rect.x + .6*rect.width,
|
2051 | y:rect.y + .25*rect.height,
|
2052 | width:.4*rect.width,
|
2053 | height:.55*rect.height
|
2054 | };
|
2055 | }
|
2056 | };
|
2057 |
|
2058 | MegalinkCardRenderer.getLaneNumberRect = function (rect) {
|
2059 | var targetRect = MegalinkCardRenderer.getTargetRect(rect);
|
2060 | var size = Math.min(targetRect.width, targetRect.height) / 5;
|
2061 |
|
2062 | targetRect.width = size;
|
2063 | targetRect.height = size;
|
2064 |
|
2065 | return targetRect;
|
2066 | };
|
2067 |
|
2068 | MegalinkCardRenderer.getSumsRect = function (rect) {
|
2069 | if (MegalinkCardRenderer.isPortrait(rect)) {
|
2070 | return {
|
2071 | x:rect.x,
|
2072 | y:rect.y + .875*rect.height,
|
2073 | width:rect.width,
|
2074 | height:.125*rect.height
|
2075 | };
|
2076 | } else {
|
2077 | return {
|
2078 | x:rect.x + .6*rect.width,
|
2079 | y:rect.y + .80*rect.height,
|
2080 | width:.4*rect.width,
|
2081 | height:.20*rect.height
|
2082 | };
|
2083 | }
|
2084 | };
|
2085 |
|
2086 | MegalinkCardRenderer.prototype.getShotRect = function (shotNum) {
|
2087 | var numRows = this.getNumRows();
|
2088 | var numColumns = this.getNumColumns();
|
2089 | var rect = MegalinkCardRenderer.getShotListRect(this.rect);
|
2090 |
|
2091 | var cellWidth = rect.width / numColumns;
|
2092 | var cellHeight = rect.height / numRows;
|
2093 |
|
2094 | var j = Math.floor((shotNum - 1) / numRows);
|
2095 | var i = shotNum - j*numRows;
|
2096 |
|
2097 | return {
|
2098 | x:rect.x + j*cellWidth,
|
2099 | y:rect.y + i*cellHeight,
|
2100 | width:cellWidth,
|
2101 | height:cellHeight
|
2102 | };
|
2103 | };
|
2104 |
|
2105 | },{"../CardRenderer":10,"./utils":21,"inherits":2}],20:[function(require,module,exports){
|
2106 | var inherits = require('inherits');
|
2107 |
|
2108 | var MegalinkCardRenderer = require('./MegalinkCardRenderer');
|
2109 | var RangeRenderer = require('../RangeRenderer');
|
2110 | var utils = require('./utils');
|
2111 |
|
2112 |
|
2113 | var HEADER_HEIGHT = 90;
|
2114 | var HEADER_MARGIN = 8;
|
2115 |
|
2116 | function MegalinkRangeRenderer() {
|
2117 | RangeRenderer.prototype.constructor.apply(this);
|
2118 | }
|
2119 |
|
2120 | module.exports = MegalinkRangeRenderer;
|
2121 | inherits(MegalinkRangeRenderer, RangeRenderer);
|
2122 |
|
2123 |
|
2124 | MegalinkRangeRenderer.prototype.initialize = function () {
|
2125 | RangeRenderer.prototype.initialize.apply(this);
|
2126 |
|
2127 | this.style.frontColor = 'rgb(0, 0, 0)';
|
2128 | };
|
2129 |
|
2130 | MegalinkRangeRenderer.prototype.CardRenderer = MegalinkCardRenderer;
|
2131 |
|
2132 | MegalinkRangeRenderer.prototype.draw = function () {
|
2133 | RangeRenderer.prototype.draw.apply(this);
|
2134 |
|
2135 | this.drawHeader();
|
2136 | };
|
2137 |
|
2138 | MegalinkRangeRenderer.prototype.drawHeader = function () {
|
2139 | var ctx = this.context;
|
2140 | var rect = this.getHeaderRect();
|
2141 |
|
2142 | ctx.clearRect(rect.x, rect.y, rect.width, rect.height);
|
2143 |
|
2144 | this.drawHost(rect);
|
2145 | this.drawRangeRelay(rect);
|
2146 | this.drawLogo(rect);
|
2147 | };
|
2148 |
|
2149 | MegalinkRangeRenderer.prototype.drawHost = function (rect) {
|
2150 | var ctx = this.context;
|
2151 | var rect = MegalinkRangeRenderer.getHostRect(rect);
|
2152 | var host = this.range.host;
|
2153 |
|
2154 | ctx.fillStyle = this.style.frontColor;
|
2155 | utils.setFont(ctx, host, rect.width, rect.height);
|
2156 | ctx.textAlign = 'center';
|
2157 | ctx.textBaseline = 'middle';
|
2158 | ctx.fillText(host, rect.x + rect.width/2, rect.y + rect.height/2);
|
2159 | ctx.textAlign = 'left';
|
2160 | ctx.textBaseline = 'alphabetic';
|
2161 | };
|
2162 |
|
2163 | MegalinkRangeRenderer.prototype.drawRangeRelay = function (rect) {
|
2164 | var ctx = this.context;
|
2165 | var rangeRelay = this.range.name + ' - Lag nr ' + this.range.relay;
|
2166 | var rangeRelayRect = MegalinkRangeRenderer.getRangeRelayRect(rect);
|
2167 |
|
2168 | ctx.fillStyle = this.style.frontColor;
|
2169 | utils.setFont(ctx, rangeRelay, rangeRelayRect.width, rangeRelayRect.height);
|
2170 |
|
2171 | ctx.textBaseline = 'middle';
|
2172 | ctx.fillText(rangeRelay, rangeRelayRect.x, rangeRelayRect.y + rangeRelayRect.height/2);
|
2173 | ctx.textBaseline = 'alphabetic';
|
2174 | };
|
2175 |
|
2176 | MegalinkRangeRenderer.prototype.drawLogo = function (rect) {
|
2177 | var ctx = this.context;
|
2178 |
|
2179 | if (!this.logo || this.logo.width == 0) {
|
2180 | this.logo = new Image();
|
2181 | this.logo.src = 'images/mllogo.png';
|
2182 |
|
2183 | var self = this;
|
2184 | this.logo.onload = function () {
|
2185 | self.drawLogo(rect);
|
2186 | };
|
2187 |
|
2188 | return;
|
2189 | }
|
2190 |
|
2191 | var maxRect = MegalinkRangeRenderer.getLogoMaxRect(rect);
|
2192 |
|
2193 | var width = this.logo.width;
|
2194 | var height = this.logo.height;
|
2195 | var logoTooLarge = width > maxRect.width || height > maxRect.height;
|
2196 |
|
2197 | if (logoTooLarge) {
|
2198 | var ratio = width / height;
|
2199 |
|
2200 | if (width - maxRect.width > height - maxRect.height) {
|
2201 | width = maxRect.width;
|
2202 | height = maxRect.width / ratio;
|
2203 | } else {
|
2204 | width = maxRect.height * ratio;
|
2205 | height = maxRect.height;
|
2206 | }
|
2207 | }
|
2208 |
|
2209 | var left = rect.x + rect.width - HEADER_MARGIN - width;
|
2210 | var top = rect.y + rect.height/2 - height/2;
|
2211 |
|
2212 | ctx.drawImage(this.logo, left, top, width, height);
|
2213 | };
|
2214 |
|
2215 |
|
2216 | MegalinkRangeRenderer.prototype.getCardsRect = function (rect) {
|
2217 | return MegalinkRangeRenderer.getCardsRect(this.rect);
|
2218 | };
|
2219 |
|
2220 | MegalinkRangeRenderer.prototype.getHeaderRect = function () {
|
2221 | return MegalinkRangeRenderer.getHeaderRect(this.rect);
|
2222 | };
|
2223 |
|
2224 | MegalinkRangeRenderer.getCardsRect = function (rect) {
|
2225 | return {
|
2226 | x: 0,
|
2227 | y: HEADER_HEIGHT,
|
2228 | width: rect.width,
|
2229 | height: rect.height - HEADER_HEIGHT
|
2230 | };
|
2231 | };
|
2232 |
|
2233 | MegalinkRangeRenderer.getHeaderRect = function (rect) {
|
2234 | return {
|
2235 | x: 0,
|
2236 | y: 0,
|
2237 | width: rect.width,
|
2238 | height: HEADER_HEIGHT
|
2239 | };
|
2240 | };
|
2241 |
|
2242 | MegalinkRangeRenderer.getHostRect = function (rect) {
|
2243 | return {
|
2244 | x:rect.x + rect.width/4 + 2*HEADER_MARGIN,
|
2245 | y:rect.y + 2*HEADER_MARGIN,
|
2246 | width:rect.width/2 - 4*HEADER_MARGIN,
|
2247 | height:rect.height - 4*HEADER_MARGIN
|
2248 | };
|
2249 | };
|
2250 |
|
2251 | MegalinkRangeRenderer.getRangeRelayRect = function (rect) {
|
2252 | return {
|
2253 | x:rect.x + 3*HEADER_MARGIN,
|
2254 | y:rect.y + HEADER_MARGIN,
|
2255 | width:rect.width/5,
|
2256 | height:rect.height - 2*HEADER_MARGIN
|
2257 | };
|
2258 | };
|
2259 |
|
2260 | MegalinkRangeRenderer.getLogoMaxRect = function (rect) {
|
2261 | return {
|
2262 | x:rect.x + 5*rect.width/8,
|
2263 | y:rect.y + HEADER_MARGIN,
|
2264 | width:rect.width/4,
|
2265 | height:rect.height - 2*HEADER_MARGIN
|
2266 | };
|
2267 | };
|
2268 |
|
2269 | },{"../RangeRenderer":13,"./MegalinkCardRenderer":19,"./utils":21,"inherits":2}],21:[function(require,module,exports){
|
2270 | module.exports = {
|
2271 | drawFrame: drawFrame,
|
2272 | setFont: setFont,
|
2273 | strokeFrame: strokeFrame
|
2274 | };
|
2275 |
|
2276 | function setFont(ctx, text, width, height) {
|
2277 | var fontName = "arial";
|
2278 | var refSize = 10;
|
2279 |
|
2280 |
|
2281 | ctx.font = refSize + "px " + fontName;
|
2282 | var refTextWidth = ctx.measureText(text).width;
|
2283 |
|
2284 |
|
2285 | var textHeight = Math.min(height, width/refTextWidth * refSize);
|
2286 |
|
2287 |
|
2288 | ctx.font = textHeight + "px " + fontName;
|
2289 | }
|
2290 |
|
2291 | function strokeFrame(ctx, rect, color) {
|
2292 | var pixelRatio = window.devicePixelRatio || 1;
|
2293 |
|
2294 | ctx.strokeStyle = color;
|
2295 | ctx.lineWidth = 1*pixelRatio;
|
2296 | ctx.strokeRect(rect.x, rect.y, rect.width, rect.height);
|
2297 | }
|
2298 |
|
2299 | function drawFrame(ctx, rect, frontColor, backColor) {
|
2300 | ctx.fillStyle = backColor;
|
2301 | ctx.fillRect(rect.x, rect.y, rect.width, rect.height);
|
2302 |
|
2303 | strokeFrame(ctx, rect, frontColor);
|
2304 | }
|
2305 |
|
2306 | },{}],22:[function(require,module,exports){
|
2307 | var Scaler = require('./Scaler');
|
2308 |
|
2309 | function ISSFSilhouetteFinalPistolTargetScaler() {
|
2310 | Scaler.prototype.constructor.apply(this);
|
2311 | }
|
2312 |
|
2313 | ISSFSilhouetteFinalPistolTargetScaler.prototype = new Scaler();
|
2314 | ISSFSilhouetteFinalPistolTargetScaler.prototype.constructor = ISSFSilhouetteFinalPistolTargetScaler;
|
2315 | module.exports = ISSFSilhouetteFinalPistolTargetScaler;
|
2316 |
|
2317 |
|
2318 | ISSFSilhouetteFinalPistolTargetScaler.prototype.getScale = function () {
|
2319 | return 1;
|
2320 | };
|
2321 |
|
2322 | },{"./Scaler":24}],23:[function(require,module,exports){
|
2323 | var Scaler = require('./Scaler');
|
2324 |
|
2325 | function RingTargetScaler() {
|
2326 | Scaler.prototype.constructor.apply(this);
|
2327 | }
|
2328 |
|
2329 | RingTargetScaler.prototype = new Scaler();
|
2330 | RingTargetScaler.prototype.constructor = RingTargetScaler;
|
2331 | module.exports = RingTargetScaler;
|
2332 |
|
2333 |
|
2334 | RingTargetScaler.prototype.setTarget = function (target) {
|
2335 | this.target = target;
|
2336 |
|
2337 | return this;
|
2338 | };
|
2339 |
|
2340 | RingTargetScaler.prototype.getScale = function () {
|
2341 |
|
2342 | var maxDist = 0;
|
2343 | var numShots = 0;
|
2344 | for (var idx in this.shots) {
|
2345 | var shot = this.shots[idx];
|
2346 | var r = Math.sqrt(shot.x*shot.x + shot.y*shot.y);
|
2347 |
|
2348 | maxDist = Math.max(maxDist, r);
|
2349 | ++numShots;
|
2350 | }
|
2351 |
|
2352 | if (numShots == 0) {
|
2353 | maxDist = .2;
|
2354 | }
|
2355 |
|
2356 |
|
2357 | var ringSizes = [];
|
2358 | for (var idx in this.target.ringSizes) {
|
2359 | var ringSize = this.target.ringSizes[idx];
|
2360 |
|
2361 | if (ringSize > maxDist) {
|
2362 | ringSizes.push(ringSize);
|
2363 | } else {
|
2364 | break;
|
2365 | }
|
2366 | }
|
2367 |
|
2368 |
|
2369 | var size = 1;
|
2370 | if (ringSizes.length > 1) {
|
2371 | size = ringSizes[ringSizes.length - 2];
|
2372 | }
|
2373 |
|
2374 | return 1 / size;
|
2375 | };
|
2376 |
|
2377 | },{"./Scaler":24}],24:[function(require,module,exports){
|
2378 | function Scaler() {
|
2379 | this.shots = [];
|
2380 | }
|
2381 |
|
2382 | module.exports = Scaler;
|
2383 |
|
2384 |
|
2385 | Scaler.prototype.setShots = function (shots) {
|
2386 | this.shots = shots;
|
2387 |
|
2388 | return this;
|
2389 | };
|
2390 |
|
2391 | Scaler.prototype.getScale = function () {
|
2392 |
|
2393 | };
|
2394 |
|
2395 | },{}],25:[function(require,module,exports){
|
2396 | function RingTargetBuilder() {
|
2397 | this.reset();
|
2398 | }
|
2399 |
|
2400 | module.exports = RingTargetBuilder;
|
2401 |
|
2402 |
|
2403 | RingTargetBuilder.createBlankTarget = function () {
|
2404 | var target = {
|
2405 | ringSizes:[1],
|
2406 | frontSize:1,
|
2407 | drawVerticalNumbers:true,
|
2408 | drawHorisontalNumbers:true,
|
2409 | numbersFrom:1,
|
2410 | numbersTo:1,
|
2411 | drawSightLines:false
|
2412 | };
|
2413 |
|
2414 | return target;
|
2415 | };
|
2416 |
|
2417 | RingTargetBuilder.prototype.reset = function () {
|
2418 | this.target = this.constructor.createBlankTarget();
|
2419 |
|
2420 | return this;
|
2421 | };
|
2422 |
|
2423 | RingTargetBuilder.prototype.getTarget = function () {
|
2424 | return this.target;
|
2425 | };
|
2426 |
|
2427 | RingTargetBuilder.prototype.setRingSizes = function (ringSizes) {
|
2428 | this.target.ringSizes = ringSizes;
|
2429 |
|
2430 | return this;
|
2431 | };
|
2432 |
|
2433 | RingTargetBuilder.prototype.setFrontSize = function (frontSize) {
|
2434 | this.target.frontSize = frontSize;
|
2435 |
|
2436 | return this;
|
2437 | };
|
2438 |
|
2439 | RingTargetBuilder.prototype.setDrawVerticalNumbers = function (drawVerticalNumbers) {
|
2440 | this.target.drawVerticalNumbers = !!drawVerticalNumbers;
|
2441 |
|
2442 | return this;
|
2443 | };
|
2444 |
|
2445 | RingTargetBuilder.prototype.setDrawHorisontalNumbers = function (drawHorisontalNumbers) {
|
2446 | this.target.drawHorisontalNumbers = !!drawHorisontalNumbers;
|
2447 |
|
2448 | return this;
|
2449 | };
|
2450 |
|
2451 | RingTargetBuilder.prototype.setNumbersFrom = function (numbersFrom) {
|
2452 | this.target.numbersFrom = numbersFrom;
|
2453 |
|
2454 | return this;
|
2455 | };
|
2456 |
|
2457 | RingTargetBuilder.prototype.setNumbersTo = function (numbersTo) {
|
2458 | this.target.numbersTo = numbersTo;
|
2459 |
|
2460 | return this;
|
2461 | };
|
2462 |
|
2463 | RingTargetBuilder.prototype.setDrawSightLines = function (drawSightLines) {
|
2464 | this.target.drawSightLines = !!drawSightLines;
|
2465 |
|
2466 | return this;
|
2467 | };
|
2468 |
|
2469 | },{}],26:[function(require,module,exports){
|
2470 | var RingTargetBuilder = require('../RingTargetBuilder');
|
2471 |
|
2472 | module.exports = new RingTargetBuilder()
|
2473 | .setFrontSize(.4)
|
2474 | .setNumbersFrom(1)
|
2475 | .setNumbersTo(9)
|
2476 | .setRingSizes([1., .9, .8, .7, .6, .5, .4, .3, .2, .1, .05])
|
2477 | .getTarget();
|
2478 |
|
2479 | },{"../RingTargetBuilder":25}],27:[function(require,module,exports){
|
2480 | module.exports = require('./DFSTenRingTarget');
|
2481 |
|
2482 | },{"./DFSTenRingTarget":26}],28:[function(require,module,exports){
|
2483 | var RingTargetBuilder = require('../RingTargetBuilder');
|
2484 |
|
2485 | module.exports = new RingTargetBuilder()
|
2486 | .setFrontSize(.4578)
|
2487 | .setNumbersFrom(1)
|
2488 | .setNumbersTo(8)
|
2489 | .setRingSizes([1., .8916, .7831, .6747, .5663, .4578, .3494, .2410, .1325, .0241])
|
2490 | .getTarget();
|
2491 |
|
2492 | },{"../RingTargetBuilder":25}],29:[function(require,module,exports){
|
2493 | module.exports=require(27)
|
2494 | },{"./DFSTenRingTarget":26,"/Users/martinvl/Dropbox/dev/liveshot/src/target/dfs/NO_DFS_100M.js":27}],30:[function(require,module,exports){
|
2495 | module.exports=require(27)
|
2496 | },{"./DFSTenRingTarget":26,"/Users/martinvl/Dropbox/dev/liveshot/src/target/dfs/NO_DFS_100M.js":27}],31:[function(require,module,exports){
|
2497 | var RingTargetBuilder = require('../RingTargetBuilder');
|
2498 |
|
2499 | module.exports = new RingTargetBuilder()
|
2500 | .setFrontSize(0.3826)
|
2501 | .setNumbersFrom(1)
|
2502 | .setNumbersTo(8)
|
2503 | .setRingSizes([1., 0.8971, 0.7942, 0.6913, 0.5884, 0.4855, 0.3826, 0.2797, 0.1768, 0.0740, 0.0322])
|
2504 | .getTarget();
|
2505 |
|
2506 | },{"../RingTargetBuilder":25}],32:[function(require,module,exports){
|
2507 | var RingTargetBuilder = require('../RingTargetBuilder');
|
2508 |
|
2509 | module.exports = new RingTargetBuilder()
|
2510 | .setFrontSize(0.4)
|
2511 | .setNumbersFrom(1)
|
2512 | .setNumbersTo(9)
|
2513 | .setRingSizes([1., 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0.05])
|
2514 | .getTarget();
|
2515 |
|
2516 | },{"../RingTargetBuilder":25}],33:[function(require,module,exports){
|
2517 | var RingTargetBuilder = require('../RingTargetBuilder');
|
2518 |
|
2519 | module.exports = new RingTargetBuilder()
|
2520 | .setFrontSize(0.6703)
|
2521 | .setNumbersFrom(1)
|
2522 | .setNumbersTo(8)
|
2523 | .setRingSizes([1., 0.8901, 0.7802, 0.6703, 0.5604, 0.4505, 0.3407, 0.2308, 0.1209, 0.0110])
|
2524 | .getTarget();
|
2525 |
|
2526 | },{"../RingTargetBuilder":25}],34:[function(require,module,exports){
|
2527 | var RingTargetBuilder = require('../RingTargetBuilder');
|
2528 |
|
2529 | module.exports = new RingTargetBuilder()
|
2530 | .setFrontSize(1.)
|
2531 | .setDrawHorisontalNumbers(false)
|
2532 | .setDrawVerticalNumbers(false)
|
2533 | .setDrawSightLines(true)
|
2534 | .setRingSizes([1., 0.26])
|
2535 | .getTarget();
|
2536 |
|
2537 | },{"../RingTargetBuilder":25}],35:[function(require,module,exports){
|
2538 | var RingTargetBuilder = require('../RingTargetBuilder');
|
2539 |
|
2540 | module.exports = new RingTargetBuilder()
|
2541 | .setFrontSize(1.)
|
2542 | .setDrawHorisontalNumbers(false)
|
2543 | .setDrawVerticalNumbers(false)
|
2544 | .setDrawSightLines(true)
|
2545 | .setRingSizes([1., 0.16])
|
2546 | .getTarget();
|
2547 |
|
2548 | },{"../RingTargetBuilder":25}],36:[function(require,module,exports){
|
2549 | var RingTargetBuilder = require('../RingTargetBuilder');
|
2550 |
|
2551 | module.exports = new RingTargetBuilder()
|
2552 | .setFrontSize(1.)
|
2553 | .setDrawHorisontalNumbers(false)
|
2554 | .setNumbersFrom(5)
|
2555 | .setNumbersTo(9)
|
2556 | .setDrawSightLines(true)
|
2557 | .setRingSizes([1., 0.84, 0.68, 0.52, 0.36, 0.2, 0.1])
|
2558 | .getTarget();
|
2559 |
|
2560 | },{"../RingTargetBuilder":25}],37:[function(require,module,exports){
|
2561 | var RingTargetScaler = require('../scaler/RingTargetScaler');
|
2562 | var RingTargetRenderer = require('../renderer/RingTargetRenderer');
|
2563 |
|
2564 | var ShotRenderer = require('../renderer/ShotRenderer');
|
2565 |
|
2566 | var ISSFSilhouetteFinalPistolTargetScaler = require('../scaler/ISSFSilhouetteFinalPistolTargetScaler');
|
2567 | var ISSFSilhouetteFinalPistolTargetRenderer = require('../renderer/ISSFSilhouetteFinalPistolTargetRenderer');
|
2568 | var ISSFSilhouetteFinalPistolShotRenderer = require('../renderer/ISSFSilhouetteFinalPistolShotRenderer');
|
2569 |
|
2570 | var targets = {
|
2571 | 'NO_DFS_100M':require('./dfs/NO_DFS_100M'),
|
2572 | 'NO_DFS_200M':require('./dfs/NO_DFS_200M'),
|
2573 | 'NO_DFS_300M':require('./dfs/NO_DFS_300M'),
|
2574 | 'NO_DFS_15M':require('./dfs/NO_DFS_15M'),
|
2575 | 'INT_ISSF_PISTOL_10M':require('./issf/INT_ISSF_PISTOL_10M'),
|
2576 | 'INT_ISSF_RIFLE_10M':require('./issf/INT_ISSF_RIFLE_10M'),
|
2577 | 'INT_ISSF_PRECISION_PISTOL':require('./issf/INT_ISSF_PRECISION_PISTOL'),
|
2578 | 'INT_ISSF_SILHOUETTE_PISTOL':require('./issf/INT_ISSF_SILHOUETTE_PISTOL'),
|
2579 | 'INT_ISSF_SILHOUETTE_FINAL_PISTOL':require('./issf/INT_ISSF_SILHOUETTE_FINAL_PISTOL'),
|
2580 | 'INT_ISSF_SILHOUETTE_FINAL_WOMEN_PISTOL':require('./issf/INT_ISSF_SILHOUETTE_FINAL_WOMEN_PISTOL'),
|
2581 | 'UNKNOWN':require('./dfs/NO_DFS_100M')
|
2582 | };
|
2583 |
|
2584 | function getTarget(targetID) {
|
2585 | return targets[targetID];
|
2586 | }
|
2587 |
|
2588 | function getScaler(targetID) {
|
2589 | switch (targetID) {
|
2590 | case 'NO_DFS_100M':
|
2591 | case 'NO_DFS_200M':
|
2592 | case 'NO_DFS_300M':
|
2593 | case 'NO_DFS_15M':
|
2594 | case 'INT_ISSF_PISTOL_10M':
|
2595 | case 'INT_ISSF_RIFLE_10M':
|
2596 | case 'INT_ISSF_PRECISION_PISTOL':
|
2597 | case 'INT_ISSF_SILHOUETTE_PISTOL':
|
2598 | case 'UNKNOWN':
|
2599 | return new RingTargetScaler()
|
2600 | .setTarget(getTarget(targetID));
|
2601 | case 'INT_ISSF_SILHOUETTE_FINAL_PISTOL':
|
2602 | case 'INT_ISSF_SILHOUETTE_FINAL_WOMEN_PISTOL':
|
2603 | return new ISSFSilhouetteFinalPistolTargetScaler();
|
2604 | }
|
2605 | }
|
2606 |
|
2607 | function getTargetRenderer(targetID) {
|
2608 | switch (targetID) {
|
2609 | case 'NO_DFS_100M':
|
2610 | case 'NO_DFS_200M':
|
2611 | case 'NO_DFS_300M':
|
2612 | case 'NO_DFS_15M':
|
2613 | case 'INT_ISSF_PISTOL_10M':
|
2614 | case 'INT_ISSF_RIFLE_10M':
|
2615 | case 'INT_ISSF_PRECISION_PISTOL':
|
2616 | case 'INT_ISSF_SILHOUETTE_PISTOL':
|
2617 | case 'UNKNOWN':
|
2618 | return new RingTargetRenderer()
|
2619 | .setTarget(getTarget(targetID));
|
2620 | case 'INT_ISSF_SILHOUETTE_FINAL_PISTOL':
|
2621 | case 'INT_ISSF_SILHOUETTE_FINAL_WOMEN_PISTOL':
|
2622 | return new ISSFSilhouetteFinalPistolTargetRenderer()
|
2623 | .setTarget(getTarget(targetID));
|
2624 | }
|
2625 | }
|
2626 |
|
2627 | function getShotRenderer(targetID) {
|
2628 | switch (targetID) {
|
2629 | case 'NO_DFS_100M':
|
2630 | case 'NO_DFS_200M':
|
2631 | case 'NO_DFS_300M':
|
2632 | case 'NO_DFS_15M':
|
2633 | case 'INT_ISSF_PISTOL_10M':
|
2634 | case 'INT_ISSF_RIFLE_10M':
|
2635 | case 'INT_ISSF_PRECISION_PISTOL':
|
2636 | case 'INT_ISSF_SILHOUETTE_PISTOL':
|
2637 | case 'UNKNOWN':
|
2638 | return new ShotRenderer();
|
2639 | case 'INT_ISSF_SILHOUETTE_FINAL_PISTOL':
|
2640 | case 'INT_ISSF_SILHOUETTE_FINAL_WOMEN_PISTOL':
|
2641 | return new ISSFSilhouetteFinalPistolShotRenderer();
|
2642 | }
|
2643 | }
|
2644 |
|
2645 | module.exports = {
|
2646 | getScaler:getScaler,
|
2647 | getTargetRenderer:getTargetRenderer,
|
2648 | getShotRenderer:getShotRenderer
|
2649 | };
|
2650 |
|
2651 | for (var targetID in targets) {
|
2652 | module.exports[targetID] = targets[targetID];
|
2653 | }
|
2654 |
|
2655 | },{"../renderer/ISSFSilhouetteFinalPistolShotRenderer":11,"../renderer/ISSFSilhouetteFinalPistolTargetRenderer":12,"../renderer/RingTargetRenderer":15,"../renderer/ShotRenderer":16,"../scaler/ISSFSilhouetteFinalPistolTargetScaler":22,"../scaler/RingTargetScaler":23,"./dfs/NO_DFS_100M":27,"./dfs/NO_DFS_15M":28,"./dfs/NO_DFS_200M":29,"./dfs/NO_DFS_300M":30,"./issf/INT_ISSF_PISTOL_10M":31,"./issf/INT_ISSF_PRECISION_PISTOL":32,"./issf/INT_ISSF_RIFLE_10M":33,"./issf/INT_ISSF_SILHOUETTE_FINAL_PISTOL":34,"./issf/INT_ISSF_SILHOUETTE_FINAL_WOMEN_PISTOL":35,"./issf/INT_ISSF_SILHOUETTE_PISTOL":36}],38:[function(require,module,exports){
|
2656 | var LiveShot = require('../../../index');
|
2657 |
|
2658 | var width = 300;
|
2659 | var height = 400;
|
2660 | var pixelRatio = window.devicePixelRatio || 1;
|
2661 |
|
2662 | var canvas = document.createElement('canvas');
|
2663 | canvas.width = width*pixelRatio;
|
2664 | canvas.height = height*pixelRatio;
|
2665 | canvas.style.width = width + 'px';
|
2666 | canvas.style.height = height + 'px';
|
2667 |
|
2668 | document.body.appendChild(canvas);
|
2669 |
|
2670 | var ctx = canvas.getContext('2d');
|
2671 | var rect = {x:0, y:0, width:width*pixelRatio, height:height*pixelRatio};
|
2672 |
|
2673 | var builder = new LiveShot.CardBuilder()
|
2674 | .setLane('1')
|
2675 | .setName('Martin Vonheim Larsen')
|
2676 | .setClub('Rygge')
|
2677 | .setClassName('4')
|
2678 | .setCategory('A')
|
2679 | .setTargetID('INT_ISSF_SILHOUETTE_FINAL_PISTOL')
|
2680 | .setGaugeSize(5600/(500000*0.88*5))
|
2681 | .setSeriesName('Ligg');
|
2682 |
|
2683 | builder.resetShots()
|
2684 | .setSeriesSum('5')
|
2685 | .setTotalSum('5');
|
2686 |
|
2687 | for (var i = 0; i < 4; ++i) {
|
2688 | var gauge = 5600/(500000*0.88*5);
|
2689 | var r = Math.random()*0.3;
|
2690 | var theta = Math.random()*2*Math.PI;
|
2691 | var x = r*Math.cos(theta);
|
2692 | var y = r*Math.sin(theta);
|
2693 | var value = (r - gauge/2 <= 4/25) ? '1' : '0';
|
2694 |
|
2695 | builder.addShotData(x, y, value);
|
2696 | }
|
2697 |
|
2698 | var renderer = new LiveShot.MegalinkCardRenderer()
|
2699 | .setContext(ctx)
|
2700 | .setRect(rect)
|
2701 | .setCard(builder.getCard())
|
2702 | .render();
|
2703 |
|
2704 | },{"../../../index":1}]},{},[38]);
|