projects
/
my-code
/
api.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
last fixes
[my-code/api.git]
/
display
/
display.c
diff --git
a/display/display.c
b/display/display.c
index
178ec62
..
b7612d6
100644
(file)
--- a/
display/display.c
+++ b/
display/display.c
@@
-8,7
+8,7
@@
#define USE_NCURSES
#define USE_NCURSES
-int display_init(t_display *display) {
+int display_init(t_display *display
,int outfd
) {
struct winsize ws;
struct winsize ws;
@@
-20,8
+20,10
@@
int display_init(t_display *display) {
display->max_x=ws.ws_col;
display->max_y=ws.ws_row;
display->max_x=ws.ws_col;
display->max_y=ws.ws_row;
- fprintf(stderr,"[display] initializing display, width: %02d / height: %02d \n"
- ,ws.ws_col,ws.ws_row);
+ display->outfd=outfd;
+
+ dprintf(display->outfd,"[display] initializing display, w: %02d / h: %02d\n",
+ ws.ws_col,ws.ws_row);
/* allocating 'screen' buffer */
if((display->screen=(char *)malloc(display->max_x*display->max_y))
/* allocating 'screen' buffer */
if((display->screen=(char *)malloc(display->max_x*display->max_y))
@@
-110,7
+112,7
@@
int display_shutdown(t_display *display) {
free(display->screen);
free(display->screen);
-
fprintf(stderr
,"[display] shutdown\n");
+
dprintf(display->outfd
,"[display] shutdown\n");
return D_SUCCESS;
}
return D_SUCCESS;
}
@@
-122,9
+124,10
@@
int display_line(t_display *display,int X,int Y,int X_,int Y_,char sym) {
m=(Y_-Y)/(X_-X);
m=(Y_-Y)/(X_-X);
- for(y=0;y<display->max_y;y++)
- for(x=0;x<display->max_x;x++)
- if((int)((x-X)*m+Y)==y) *(display->screen+y*display->max_x+x)=sym;
+ for(x=X;x<=X_;x++) {
+ y=(x-X)*m+Y;
+ *(display->screen+y*display->max_x+x)=sym;
+ }
return D_SUCCESS;
}
return D_SUCCESS;
}