-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththermometer.c
62 lines (45 loc) · 1.64 KB
/
thermometer.c
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
#include "sal.h"
#include "config.h"
#include "image.h"
#include "window.h"
#include "aquarium.h"
#include "cpuload.h"
static Imlib_Image thermometer_image;
void thermometer_init(struct aquarium *aquarium)
{
if (aquarium->termometer == AL_NO)
return;
thermometer_image = image_load("thermometer.png");
}
void thermometer_update(struct aquarium *aquarium)
{
int x, y, h;
if (aquarium->termometer == AL_NO)
return;
imlib_context_set_image(thermometer_image);
aquarium_transform(aquarium->termometer,
imlib_image_get_width(),
imlib_image_get_height(),
&x, &y);
h = (100 - cpuload()) * (imlib_image_get_height() - 7) / 100;
imlib_context_set_color(0xa0, 0x0, 0x0, 0xff);
imlib_image_draw_line(3, 2,
3, h+2,
0);
imlib_image_draw_line(4, 2,
4, h+2,
0);
imlib_context_set_color(0xff, 0x0, 0x0, 0xff);
imlib_image_draw_line(3, h+2,
3, imlib_image_get_height() - 5,
0);
imlib_image_draw_line(4, h+2,
4, imlib_image_get_height() - 5,
0);
window_draw_blend((unsigned char *)imlib_image_get_data_for_reading_only(),
0, 0,
imlib_image_get_width(),
imlib_image_get_height(),
x, y,
220);
}