-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHydresColor.c
More file actions
50 lines (44 loc) · 1.29 KB
/
Copy pathHydresColor.c
File metadata and controls
50 lines (44 loc) · 1.29 KB
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
#include "HydresColor.h"
void fieldPaint(field* terrain, const int color)
{
fieldPaintPart(terrain, color, 0, terrain->fsize_x - 1, 0, terrain->fsize_y - 1);
}
field* fieldCPaint(const field* terrain, const int color)
{
field* resultat = fieldCopy(terrain);
fieldPaint(resultat, color);
return resultat;
}
void fieldPaintPart(field* terrain, const int color, const int s_x, const int e_x, const int s_y, const int e_y)
{
if (!terrain)
{
HydresErr(err_paint_nosource);
return;
}
if ((s_x < 0) || (s_y < 0) || (e_x >= terrain->fsize_x) || (e_y >= terrain->fsize_y))
{
herr.t[0] = s_x;
herr.t[1] = s_y;
herr.t[2] = e_x;
herr.t[3] = e_y;
herr.x = terrain->fsize_x;
herr.y = terrain->fsize_y;
HydresErr(err_paint_miscall);
return;
}
int i, j;
for (i = s_x ; i <= e_x ; i++)
{
for (j = s_y ; j <= e_y ; j++)
{
terrain->fbody[i][j].color = color;
}
}
}
field* fieldCPaintPart(const field* source, const int color, const int s_x, const int e_x, const int s_y, const int e_y)
{
field* resultat = fieldCopy(source);
fieldPaintPart(resultat, color, s_x, e_x, s_y, e_y);
return resultat;
}