forked from timoschwarzer/tunic-ocr
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRuneLine.gd
More file actions
46 lines (31 loc) · 780 Bytes
/
RuneLine.gd
File metadata and controls
46 lines (31 loc) · 780 Bytes
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
45
46
extends Line2D
class_name RuneLine
tool
enum Status {
DEFAULT = 0,
DETECTED = 1,
}
export (Status) var status = Status.DEFAULT setget set_status
func _ready():
update_color()
func set_status(value):
status = value
if is_inside_tree():
update_color()
func update_color():
if status == Status.DEFAULT:
default_color = Color(1, 0, 0, 0.1)
elif status == Status.DETECTED:
default_color = Color.blue
func detect(img: Image):
img.lock()
var detected = true
for i in range(10):
var detector = get_node_or_null('Detector%s' % i)
if detector != null:
if ImgUtil.get_value_at(img, detector.global_position) > 0.5:
detected = false
break
img.unlock()
set_status(Status.DETECTED if detected else Status.DEFAULT)
z_index = 1 if detected else 0