summaryrefslogtreecommitdiff
path: root/tomorrowthegroundGUI/tomorrowthegroundGUI.pde
blob: cf6d07abff13491176a41b9d9c2e553f64ddd4bc (plain)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import hypermedia.net.*;

PImage[] bgmaps;
int usemap;
UDP udp;
int x,y;
float lat1,lng1,lat2,lng2,fw,fh;
String sendIP;


void setup() 
{
  bgmaps=new PImage[2];
  sendIP="127.0.0.1";
  int map=1;
  switch (map) {
    case 1:
      bgmaps[0] = loadImage("gentmap.png");
      bgmaps[1] = loadImage("indexmapV1.gif");
      lat1=51.050608;
      lng1=3.724698;
      lat2=51.046878;
      lng2=3.732852;
      break;
    case 2:
      bgmaps[0] = loadImage("TimelabTestAreaGUI.jpg");
      bgmaps[1] = loadImage("TimelabTestAreaGRADIENT.png");
      lat1=51.043293;
      lng1=3.737025;
      lat2=51.042154;
      lng2=3.739584;
      break;
  }
  usemap=0;
  size(bgmaps[0].width,bgmaps[0].height);
  frameRate(15);
  udp = new UDP(this);
  x=width/2;
  y=height/2;
  
  fw=lng2-lng1;
  fh=lat1-lat2;
}

void draw() 
{
  background(bgmaps[usemap]);
  fill(255);
  stroke(255,0,0);
  ellipse(x,y,5,5);
}

void mouseDragged() 
{
  if (mousePressed) {
    x=mouseX;
    y=mouseY;
    float fx=((float)mouseX)/width;
    float fy=((float)mouseY)/height;
    udp.send(((fy*fh)+lat2)+","+((fx*fw)+lng1)+"\n",sendIP,5400);
  }
}

void keyPressed() {
  switch(key) {
    case '0':
      usemap=0;
      break;
    case '1':
      usemap=1;
      break;
  }
}