forked from jimppan/osrs-gimp-tracker-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoverlays.js
56 lines (41 loc) · 1.3 KB
/
overlays.js
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
47
48
49
50
51
52
53
54
55
56
import { Overlay, SpawnObject, DeleteObject } from "./object.js";
// used if the camera zoom changes or if the object position/scale changes
export function updateOverlay(object)
{
var overlay = getOverlay(object);
if(overlay == null)
return;
overlay.graphic.clear();
overlay.graphic.beginFill(0xffff00);
overlay.graphic.alpha = 0.3;
var box = object.getScreenRect(true);
overlay.setPosition(box.x, box.y);
overlay.graphic.drawRect(0, 0, box.width, box.height);
overlay.graphic.endFill();
}
export function createOverlay(object)
{
var overlay = new Overlay("HighlightObject");
overlay.graphic = new PIXI.Graphics();
overlay.graphic.beginFill(0xffff00);
overlay.graphic.alpha = 0.3;
overlay.setZIndex(HUD_LAYERS.WORLD_BACKGROUND);
var box = object.getScreenRect(true);
overlay.graphic.drawRect(0, 0, box.width, box.height);
overlay.graphic.endFill();
overlay.setPosition(box.x, box.y);
overlay.attachTo(object, false, 0, 0);
overlay.interactable = false;
OVERLAYS.set(object, overlay);
SpawnObject(overlay);
return overlay;
}
export function deleteOverlay(object)
{
DeleteObject(getOverlay(object));
OVERLAYS.delete(object);
}
export function getOverlay(object)
{
return OVERLAYS.get(object);
}