mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-17 10:35:10 +00:00
Refactor hsv code.
This commit is contained in:
parent
cb9c5e22e5
commit
3c43c4c7fe
@ -33,15 +33,9 @@
|
||||
|
||||
unsigned int adjust_colours(unsigned int);
|
||||
unsigned long *do_gradient(int, unsigned long, unsigned long);
|
||||
unsigned long *do_hsv_gradient(int, unsigned long, unsigned long);
|
||||
|
||||
long get_x11_color(const std::string &colour);
|
||||
// XXX: when everyone uses C++ strings, remove this C version
|
||||
long get_x11_color(const char *);
|
||||
|
||||
// needed by hsv_gradient
|
||||
extern short colour_depth;
|
||||
extern long redmask, greenmask, bluemask;
|
||||
extern void set_up_gradient();
|
||||
|
||||
#endif /* _COLOURS_H */
|
||||
|
@ -1464,10 +1464,10 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied) {
|
||||
#ifdef BUILD_HSV_GRADIENT
|
||||
tmpcolour = do_hsv_gradient(w - 1, current->last_colour,
|
||||
current->first_colour);
|
||||
#else
|
||||
#else /* BUILD_HSV_GRADIENT */
|
||||
tmpcolour = do_gradient(w - 1, current->last_colour,
|
||||
current->first_colour);
|
||||
#endif
|
||||
#endif /* BUILD_HSV_GRADIENT */
|
||||
}
|
||||
colour_idx = 0;
|
||||
for (i = w - 2; i > -1; i--) {
|
||||
|
@ -26,13 +26,14 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#include "hsv_gradient.h"
|
||||
#include "colours.h"
|
||||
#include "conky.h"
|
||||
#include "logging.h"
|
||||
|
||||
#ifdef BUILD_X11
|
||||
#include "x11.h"
|
||||
|
||||
#endif
|
||||
#endif /* BUILD_X11 */
|
||||
|
||||
#define CONST_SCALE 512L
|
||||
#define CONST_SCALE_HALF (CONST_SCALE / 2)
|
||||
@ -150,7 +151,7 @@ unsigned long *do_hsv_gradient(int width, unsigned long first_colour,
|
||||
|
||||
int redshift = (2 * colour_depth / 3 + colour_depth % 3);
|
||||
int greenshift = (colour_depth / 3);
|
||||
auto *colours =
|
||||
unsigned long *colours =
|
||||
static_cast<unsigned long *>(malloc(width * sizeof(unsigned long)));
|
||||
int i;
|
||||
|
||||
@ -212,5 +213,6 @@ unsigned long *do_hsv_gradient(int width, unsigned long first_colour,
|
||||
|
||||
colours[i] = (red3 << redshift) | (green3 << greenshift) | blue3;
|
||||
}
|
||||
|
||||
return colours;
|
||||
}
|
||||
|
@ -29,6 +29,11 @@
|
||||
#ifndef _HSV_GRADIENT_H
|
||||
#define _HSV_GRADIENT_H
|
||||
|
||||
// needed by hsv_gradient
|
||||
extern short colour_depth;
|
||||
extern long redmask, greenmask, bluemask;
|
||||
extern void set_up_gradient();
|
||||
|
||||
unsigned long *do_hsv_gradient(int, unsigned long, unsigned long);
|
||||
|
||||
long to_decimal_scale(long value, long max_value);
|
||||
|
@ -17,7 +17,9 @@ endif()
|
||||
set(test_srcs ${test_srcs} test-core.cc)
|
||||
set(test_srcs ${test_srcs} test-diskio.cc)
|
||||
set(test_srcs ${test_srcs} test-fs.cc)
|
||||
if(BUILD_HSV_GRADIENT)
|
||||
set(test_srcs ${test_srcs} test-hsv.cc)
|
||||
endif(BUILD_HSV_GRADIENT)
|
||||
|
||||
add_executable(test-conky test-common.cc ${test_srcs})
|
||||
target_link_libraries(test-conky conky_core)
|
||||
|
Loading…
Reference in New Issue
Block a user