path:
root/
src/
util/
pick_convert.c (
plain)
blob: eca819a8d57dd1a44ad699b6e321cdce959c8e1a
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
|
#include "pick_convert.h"
/*
* Width and height of a selection box about a single-click selection.
*/
#define N 3.0
void
pick_convert (int select_x, int select_y, int x, int y,
double *c_x, double *c_y, double *w, double *h)
{
/*
* Calculate X and the width.
*/
if (x > select_x)
{
*c_x = (x - select_x) / 2.0 + select_x;
*w = x - select_x;
}
else if (x < select_x)
{
*c_x = (select_x - x) / 2.0 + x;
*w = select_x - x;
}
else
{
*c_x = x;
*w = N;
}
/*
* Calculate Y and the width.
*/
if (y > select_y)
{
*c_y = (y - select_y) / 2.0 + select_y;
*h = y - select_y;
}
else if (y < select_y)
{
*c_y = (select_y - y) / 2.0 + y;
*h = select_y - y;
}
else
{
*c_y = y;
*h = N;
}
return;
}
|