1 |
/* |
2 |
* This file contains the public interface of libbubblemon. |
3 |
* Libbubblemon is a library for making bubbling load monitors for |
4 |
* different platforms. See for example |
5 |
* "http://www.nongnu.org/bubblemon/". |
6 |
* |
7 |
* Copyright (C) 1999-2000 Johan Walles - d92-jwa@nada.kth.se |
8 |
* http://www.nongnu.org/libbubblemon/ |
9 |
* |
10 |
* This program is free software; you can redistribute it and/or modify |
11 |
* it under the terms of the GNU General Public License as published by |
12 |
* the Free Software Foundation; either version 2 of the License, or |
13 |
* (at your option) any later version. |
14 |
* |
15 |
* This program is distributed in the hope that it will be useful, |
16 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 |
* GNU General Public License for more details. |
19 |
* |
20 |
* You should have received a copy of the GNU General Public License |
21 |
* along with this program; if not, write to the Free Software |
22 |
* Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. |
23 |
*/ |
24 |
|
25 |
#ifndef BUBBLEMON_H |
26 |
#define BUBBLEMON_H |
27 |
|
28 |
/*************************************************************** |
29 |
* |
30 |
* Data types. |
31 |
*/ |
32 |
|
33 |
// The current state of your bubblemon |
34 |
typedef void* bubblemon_t; |
35 |
|
36 |
// An rgba color value |
37 |
typedef union { |
38 |
unsigned int value; |
39 |
struct { |
40 |
unsigned char r; |
41 |
unsigned char g; |
42 |
unsigned char b; |
43 |
unsigned char a; |
44 |
} components; |
45 |
} bubblemon_color_t; |
46 |
|
47 |
// An image for on-screen rendering |
48 |
typedef struct |
49 |
{ |
50 |
int width; |
51 |
int height; |
52 |
|
53 |
bubblemon_color_t *pixels; |
54 |
} bubblemon_picture_t; |
55 |
|
56 |
|
57 |
/*************************************************************** |
58 |
* |
59 |
* The essentials: |
60 |
*/ |
61 |
|
62 |
// Create a new bubblemon, start by calling this function |
63 |
// |
64 |
// Returns NULL on out of memory |
65 |
bubblemon_t bubblemon_create(void); |
66 |
|
67 |
// Render a frame. Before calling this function, you are responsible |
68 |
// for that picture->pixels is pointing to a memory area of at least |
69 |
// picture->width * picture->height * sizeof(bubblemon_color_t) bytes. |
70 |
// |
71 |
// Returns: |
72 |
// 0 on success |
73 |
// ENOMEM (as defined in <errno.h>) on out of memory |
74 |
int bubblemon_render(bubblemon_t bubblemon, bubblemon_picture_t *picture); |
75 |
|
76 |
// Free all resources of a bubblemon previously allocated by |
77 |
// bubblemon_create(). |
78 |
void bubblemon_destroy(bubblemon_t bubblemon); |
79 |
|
80 |
|
81 |
/*************************************************************** |
82 |
* |
83 |
* Sensor input that will be visualized: |
84 |
*/ |
85 |
|
86 |
// Set the water level to 0-100 |
87 |
void bubblemon_setWaterLevel(bubblemon_t bubblemon, int level); |
88 |
|
89 |
// Set the color intensity to 0-100 |
90 |
void bubblemon_setColorIntensity(bubblemon_t bubblemon, int intensity); |
91 |
|
92 |
// Set the amount of bubbles to 0-100 |
93 |
void bubblemon_setBubbles(bubblemon_t bubblemon, int bubbles); |
94 |
|
95 |
// Set the amount of growth to 0-100 |
96 |
void bubblemon_setGrowthIntensity(bubblemon_t bubblemon, int growth); |
97 |
|
98 |
// Set whether the floater is visible (true / false) |
99 |
void bubblemon_setFloaterVisible(bubblemon_t bubblemon, int visible); |
100 |
|
101 |
|
102 |
/*************************************************************** |
103 |
* |
104 |
* Settings |
105 |
*/ |
106 |
|
107 |
// Get / set the water and air colors |
108 |
bubblemon_color_t bubblemon_getMaxWaterColor(bubblemon_t bubblemon); |
109 |
void bubblemon_setMaxWaterColor(bubblemon_t bubblemon, |
110 |
bubblemon_color_t color); |
111 |
|
112 |
bubblemon_color_t bubblemon_getMinWaterColor(bubblemon_t bubblemon); |
113 |
void bubblemon_setMinWaterColor(bubblemon_t bubblemon, |
114 |
bubblemon_color_t color); |
115 |
|
116 |
bubblemon_color_t bubblemon_getMaxAirColor(bubblemon_t bubblemon); |
117 |
void bubblemon_setMaxAirColor(bubblemon_t bubblemon, |
118 |
bubblemon_color_t color); |
119 |
|
120 |
bubblemon_color_t bubblemon_getMinAirColor(bubblemon_t bubblemon); |
121 |
void bubblemon_setMinAirColor(bubblemon_t bubblemon, |
122 |
bubblemon_color_t color); |
123 |
|
124 |
// Change the floater image (default is a message-in-a-bottle). The |
125 |
// horizontal center of gravity is counted from the top down, so lower |
126 |
// values are higher up. |
127 |
// |
128 |
// Returns: |
129 |
// 0 on success |
130 |
// ENOMEM (as defined in <errno.h>) on out of memory. In this case, |
131 |
// the previous image is preserved. |
132 |
int bubblemon_setFloaterImage(bubblemon_t bubblemon, |
133 |
bubblemon_picture_t *picture, |
134 |
int horizontalCenterOfGravity, |
135 |
int verticalCenterOfGravity); |
136 |
|
137 |
// Change the color of the stuff growing from the bottom. The growth |
138 |
// color is randomized between these two values. |
139 |
void bubblemon_setGrowthColor(bubblemon_t bubblemon, |
140 |
bubblemon_color_t color1, |
141 |
bubblemon_color_t color2); |
142 |
|
143 |
// Fetch the current color of the stuff growing from the bottom. If |
144 |
// any of the parameters is NULL, that parameter will be ignored. |
145 |
void bubblemon_getGrowthColor(bubblemon_t bubblemon, |
146 |
bubblemon_color_t *color1, |
147 |
bubblemon_color_t *color2); |
148 |
|
149 |
#endif // !defined(BUBBLEMON_H) |