imtk

view src/progress.c @ 14:df2bc9406561

added gradients
author John Tsiombikas <nuclear@siggraph.org>
date Tue, 19 Apr 2011 03:01:46 +0300
parents 9c7987064bb0
children 6893b4dca5a3
line source
1 #include <string.h>
2 #include "imtk.h"
3 #include "draw.h"
5 #define PROGR_SIZE 100
6 #define PROGR_HEIGHT 15
8 static void draw_progress(int id, float pos, int x, int y);
10 void imtk_progress(int id, float pos, int x, int y)
11 {
12 draw_progress(id, pos, x, y);
13 }
15 static void draw_progress(int id, float pos, int x, int y)
16 {
17 int bar_size = PROGR_SIZE * pos;
18 float b = imtk_get_bevel_width();
19 float tcol[4], bcol[4];
21 if(pos < 0.0) pos = 0.0;
22 if(pos > 1.0) pos = 1.0;
24 memcpy(tcol, imtk_get_color(IMTK_BOTTOM_COLOR), sizeof tcol);
25 memcpy(bcol, imtk_get_color(IMTK_TOP_COLOR), sizeof bcol);
27 /* through */
28 imtk_draw_rect(x - b, y - b, PROGR_SIZE + b * 2, PROGR_HEIGHT + b * 2, tcol, bcol);
29 imtk_draw_frame(x - b, y - b, PROGR_SIZE + b * 2, PROGR_HEIGHT + b * 2, FRAME_INSET);
31 /* bar */
32 if(pos > 0.0) {
33 memcpy(tcol, imtk_get_color(IMTK_TOP_COLOR), sizeof tcol);
34 memcpy(bcol, imtk_get_color(IMTK_BOTTOM_COLOR), sizeof bcol);
36 imtk_draw_rect(x, y, bar_size, PROGR_HEIGHT, tcol, bcol);
37 imtk_draw_frame(x, y, bar_size, PROGR_HEIGHT, FRAME_OUTSET);
38 }
39 }