modified: src/color.c
This commit is contained in:
parent
c1ba91a6e8
commit
dd3d885a31
51
src/color.c
51
src/color.c
@ -6,22 +6,13 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <math.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) {
|
int main(void) {
|
||||||
@ -41,8 +32,8 @@ int main(void) {
|
|||||||
GC text_prompt_gc;
|
GC text_prompt_gc;
|
||||||
|
|
||||||
int text_buffer_space;
|
int text_buffer_space;
|
||||||
unsigned int channel_step;
|
unsigned int color_step;
|
||||||
int is_prompt = 1;
|
int is_prompt = 0;
|
||||||
|
|
||||||
|
|
||||||
unsigned int textpos_y;
|
unsigned int textpos_y;
|
||||||
@ -52,9 +43,6 @@ int main(void) {
|
|||||||
|
|
||||||
XWindowAttributes win_info;
|
XWindowAttributes win_info;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if((display = XOpenDisplay(NULL)) == NULL) {
|
if((display = XOpenDisplay(NULL)) == NULL) {
|
||||||
printf("Couldn't open display due to fatal error: %s\n", strerror(errno));
|
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.green = 0xffff - background_color.green;
|
||||||
foreground_color.blue = 0xffff - background_color.blue;
|
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, &background_color);
|
||||||
XAllocColor(display, colormap, &foreground_color);
|
XAllocColor(display, colormap, &foreground_color);
|
||||||
|
|
||||||
@ -89,7 +79,8 @@ int main(void) {
|
|||||||
XMapWindow(display, window);
|
XMapWindow(display, window);
|
||||||
XSelectInput(display, window, KeyPressMask | ExposureMask);
|
XSelectInput(display, window, KeyPressMask | ExposureMask);
|
||||||
XGetWindowAttributes(display, window, &win_info);
|
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
|
//text struct
|
||||||
@ -108,12 +99,19 @@ int main(void) {
|
|||||||
XGetWindowAttributes(display, window, &win_info);
|
XGetWindowAttributes(display, window, &win_info);
|
||||||
textpos_y = win_info.height - TEXT_CORNER_OFFSET;
|
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(;;) {
|
for(;;) {
|
||||||
XNextEvent(display, &event);
|
XNextEvent(display, &event);
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case KeyPress:
|
case KeyPress:
|
||||||
printf("-->%i\n", event.xkey.keycode);
|
|
||||||
if(is_prompt) {
|
if(is_prompt) {
|
||||||
XClearWindow(display, window);
|
XClearWindow(display, window);
|
||||||
|
|
||||||
@ -130,11 +128,20 @@ int main(void) {
|
|||||||
XDrawText(display, window, text_prompt_gc, TEXT_CORNER_OFFSET, textpos_y, &text_prompt, 1);
|
XDrawText(display, window, text_prompt_gc, TEXT_CORNER_OFFSET, textpos_y, &text_prompt, 1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("%i\n", win_info.depth);
|
|
||||||
switch(event.xkey.keycode) {
|
switch(event.xkey.keycode) {
|
||||||
case X_ENTER_KEY:
|
case X_ENTER_KEY:
|
||||||
break;
|
break;
|
||||||
case X_Q_KEY:
|
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;
|
break;
|
||||||
case X_W_KEY:
|
case X_W_KEY:
|
||||||
break;
|
break;
|
||||||
@ -159,10 +166,8 @@ int main(void) {
|
|||||||
XGetWindowAttributes(display, window, &win_info);
|
XGetWindowAttributes(display, window, &win_info);
|
||||||
textpos_y = win_info.height - TEXT_CORNER_OFFSET;
|
textpos_y = win_info.height - TEXT_CORNER_OFFSET;
|
||||||
XDrawText(display, window, text_prompt_gc, TEXT_CORNER_OFFSET, textpos_y, &text_prompt, 1);
|
XDrawText(display, window, text_prompt_gc, TEXT_CORNER_OFFSET, textpos_y, &text_prompt, 1);
|
||||||
printf("%i\n", textpos_y);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printf("testing\n");
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user