some config possibilities and making color selection more effective

This commit is contained in:
Roland Hollós 2020-11-22 15:48:36 +01:00
parent f02047262b
commit aba6487d1e
2 changed files with 42 additions and 25 deletions

39
config.h Normal file
View File

@ -0,0 +1,39 @@
typedef struct _color {
float red;
float green;
float blue;
} color;
color colors[4]={
//base
{
.red = 0.5,
.green = 0.5,
.blue = 0.5,
},
//minute
{
.red = 1.,
.green = 0.,
.blue = 0.
},
//hour
{
.red = 0.,
.green = 0.,
.blue = 1
},
//both
{
.red = 0.,
.green = 1.,
.blue = 0.
}
};

28
main.c
View File

@ -7,6 +7,7 @@
#include <X11/Xatom.h>
#include <cairo.h>
#include <cairo-xlib.h>
#include "config.h"
typedef struct _rectangle {
int pos_x;
@ -83,32 +84,9 @@ void getFibbTime(myTime t, int* res){
}
void drawRectangle(cairo_t* cr, rectangle R){
int color[3];
switch(R.color){
case 0:
color[0] = 1;
color[1] = 1;
color[2] = 1;
break;
case 1:
color[0] = 1;
color[1] = 0;
color[2] = 0;
break;
case 2:
color[0] = 0;
color[1] = 0;
color[2] = 1;
break;
case 3:
color[0] = 0;
color[1] = 1;
color[2] = 0;
break;
}
color rectColor = colors[R.color]; // colors is defined in config.h
cairo_rectangle(cr, R.pos_x, R.pos_y, R.width, R.height); /* set rectangle */
cairo_set_source_rgb(cr, color[0], color[1], color[2]); /* set fill color */
cairo_set_source_rgb(cr, rectColor.red, rectColor.green, rectColor.blue); /* set fill color */
cairo_fill(cr); /* fill rectangle */
}