diff options
author | Brett Weiland <techcrazybsw@gmail.com> | 2020-07-25 20:43:41 -0500 |
---|---|---|
committer | Brett Weiland <techcrazybsw@gmail.com> | 2020-07-25 20:43:41 -0500 |
commit | dd3d885a31eefd44f0026d726372f53781947927 (patch) | |
tree | 715d9ac2d72f774c0dda1a9128f003f2cc200e56 /src | |
parent | c1ba91a6e88797057d274e9147b2f55669df876c (diff) |
modified: src/color.c
Diffstat (limited to 'src')
-rw-r--r-- | src/color.c | 49 |
1 files changed, 27 insertions, 22 deletions
diff --git a/src/color.c b/src/color.c index cc4e4ef..8ff1612 100644 --- a/src/color.c +++ b/src/color.c @@ -6,22 +6,13 @@ #include <errno.h> #include <math.h> -#define PROMPT_BUFSIZE 32 +#include "color.h" -#define X_ENTER_KEY 36 -#define X_BACKSPACE 22 -#define X_Q_KEY 24 -#define X_W_KEY 25 -#define X_E_KEY 26 -#define X_A_KEY 38 -#define X_S_KEY 39 -#define X_D_KEY 40 - - -#define TEXT_CORNER_OFFSET 100 +int add_color(color_info color) { +} int main(void) { @@ -41,8 +32,8 @@ int main(void) { GC text_prompt_gc; int text_buffer_space; - unsigned int channel_step; - int is_prompt = 1; + unsigned int color_step; + int is_prompt = 0; unsigned int textpos_y; @@ -52,9 +43,6 @@ int main(void) { XWindowAttributes win_info; - - - if((display = XOpenDisplay(NULL)) == NULL) { printf("Couldn't open display due to fatal error: %s\n", strerror(errno)); @@ -74,6 +62,8 @@ int main(void) { foreground_color.green = 0xffff - background_color.green; foreground_color.blue = 0xffff - background_color.blue; + unsigned long live_pixels[2] = {foreground_color.pixel, foreground_color.pixel}; + XAllocColor(display, colormap, &background_color); XAllocColor(display, colormap, &foreground_color); @@ -89,7 +79,8 @@ int main(void) { XMapWindow(display, window); XSelectInput(display, window, KeyPressMask | ExposureMask); XGetWindowAttributes(display, window, &win_info); - channel_step = 0xffff / pow((win_info.depth / 3), 2) ; + color_step = 0xffff / pow(2, (win_info.depth / 3)) ; + //text struct @@ -108,12 +99,19 @@ int main(void) { XGetWindowAttributes(display, window, &win_info); textpos_y = win_info.height - TEXT_CORNER_OFFSET; + update_info display_summary = { + .window = window, + .display = display, + .colormap = colormap, + .background = background_color, + .foreground = foreground_color, + .channel_step = color_step + }; for(;;) { XNextEvent(display, &event); switch (event.type) { case KeyPress: - printf("-->%i\n", event.xkey.keycode); if(is_prompt) { XClearWindow(display, window); @@ -130,11 +128,20 @@ int main(void) { XDrawText(display, window, text_prompt_gc, TEXT_CORNER_OFFSET, textpos_y, &text_prompt, 1); } else { - printf("%i\n", win_info.depth); switch(event.xkey.keycode) { case X_ENTER_KEY: break; case X_Q_KEY: + printf("%i\n", channel_step); + XFreeColors(display, colormap, &background_color.pixel, 1, 0); + XFreeColors(display, colormap, &foreground_color.pixel, 1, 0); + background_color.red += channel_step; + foreground_color.red = 0xffff - background_color.red; //we could just sub channel_step, but eh. i donno. + printf("----%i\n", background_color.red); + XAllocColor(display, colormap, &foreground_color); + XAllocColor(display, colormap, &background_color); + XClearWindow(display, window); + XSetWindowBackground(display, window, background_color.pixel); break; case X_W_KEY: break; @@ -159,10 +166,8 @@ int main(void) { XGetWindowAttributes(display, window, &win_info); textpos_y = win_info.height - TEXT_CORNER_OFFSET; XDrawText(display, window, text_prompt_gc, TEXT_CORNER_OFFSET, textpos_y, &text_prompt, 1); - printf("%i\n", textpos_y); break; default: - printf("testing\n"); break; } } |