-
Notifications
You must be signed in to change notification settings - Fork 0
/
reticle.m
44 lines (36 loc) · 1.11 KB
/
reticle.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
% Authors: Alejandro R. Mosteo, Danilo Tardioli, Eduardo Montijano
% Copyright 2018-9999 Monmostar
% Licensed under GPLv3 https://www.gnu.org/licenses/gpl-3.0.en.html
%
classdef reticle < handle
properties(Constant)
X = [0 0 -1 -2 -1 0 0 0 1 2 1 0]*3;
Y = [2 1 0 0 0 -1 -2 -1 0 0 0 1]*3;
end
properties
id = 0 % last target id to detect changes
flash = 0 % counter to flash the reticle on target change
h % drawer()
end
methods
function this = reticle()
this.h = drawer();
end
function draw(this, fig, id, x, y, scale, color)
if id ~= this.id
this.flash = 5;
this.id = id;
end
should_draw = mod(this.flash, 2) == 0 && id ~=0;
this.flash = max(0, this.flash - 1);
if should_draw
this.h.plot(fig, (x+reticle.X)'*scale, (y+reticle.Y)'*scale, ...
'Color', color, 'LineWidth', 1);
this.h.show;
this.h.bring_to_front;
else
this.h.show(false);
end
end
end
end