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
|
import hypermedia.net.*;
PImage bgmap;
UDP udp;
int x,y;
float lat1,lng1,lat2,lng2,fw,fh;
void setup()
{
bgmap = loadImage("gentmap.png");
size(bgmap.width,bgmap.height);
frameRate(30);
udp = new UDP(this);
x=width/2;
y=height/2;
lat1=51.050608;
lng1=3.724698;
lat2=51.046878;
lng2=3.732852;
fw=lng2-lng1;
fh=lat1-lat2;
}
void draw()
{
background(bgmap);
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(((fx*fw)+lng1)+","+((fy*fh)+lat2)+"\n","127.0.0.1",5204);
}
}
|