diff --git a/src/Makefile.dep b/src/Makefile.dep index 27c8461b..0059f24d 100644 --- a/src/Makefile.dep +++ b/src/Makefile.dep @@ -61,6 +61,9 @@ $(OBJDIR)/pages.o: pages.c global.h struct.h const.h pages.h errors.h loadsave.h $(OBJDIR)/palette.o: palette.c const.h struct.h global.h misc.h engine.h readline.h \ buttons.h pages.h help.h sdlscreen.h errors.h op_c.h windows.h input.h \ palette.h shade.h +$(OBJDIR)/palette_test.o: palette_test.c const.h struct.h global.h misc.h engine.h \ + readline.h buttons.h pages.h help.h sdlscreen.h errors.h op_c.h \ + windows.h input.h palette.h shade.h $(OBJDIR)/pversion.o: pversion.c $(OBJDIR)/pxdouble.o: pxdouble.c global.h struct.h const.h sdlscreen.h misc.h \ graph.h pxdouble.h pxwide.h @@ -81,7 +84,7 @@ $(OBJDIR)/pxwide2.o: pxwide2.c global.h struct.h const.h sdlscreen.h misc.h grap $(OBJDIR)/readini.o: readini.c const.h errors.h global.h struct.h misc.h readini.h \ setup.h $(OBJDIR)/readline.o: readline.c const.h struct.h global.h misc.h errors.h \ - sdlscreen.h readline.h windows.h input.h + sdlscreen.h readline.h windows.h input.h engine.h $(OBJDIR)/realpath.o: realpath.c $(OBJDIR)/saveini.o: saveini.c const.h global.h struct.h readini.h io.h errors.h \ misc.h saveini.h setup.h diff --git a/src/factory.c b/src/factory.c index 50b5674c..a31a6312 100644 --- a/src/factory.c +++ b/src/factory.c @@ -42,6 +42,7 @@ #include "palette.h" #include "input.h" // Is_shortcut() #include "help.h" // Window_help() +#include "graph.h" /// Lua scripts bound to shortcut keys. char * Bound_script[10]; @@ -148,6 +149,13 @@ void Update_colors_during_script(void) } } +/// Paint a pixel in image without updating the screen +void Pixel_figure_no_screen(short x_pos,short y_pos,byte color) +{ + if (x_pos>0 && y_pos >0 && x_posx1) + { + min_x=x1; + max_x=x2; + } + else + { + min_x=x2; + max_x=x1; + } + if (y2>y1) + { + min_y=y1; + max_y=y2; + } + else + { + min_y=y2; + max_y=y1; + } + // Clipping limits + if (max_x>Main_image_width) + max_x=Main_image_width-1; + if (max_y>Main_image_height) + max_y=Main_image_height-1; + if (min_x<0) + min_x=0; + if (min_y<0) + min_y=0; + + // Perform drawing + for (y_pos=min_y; y_pos<=max_y;y_pos++) + for (x_pos=min_x; x_pos<=max_x;x_pos++) + Pixel_in_current_screen(x_pos,y_pos,c,0); return 0; + } @@ -400,7 +444,7 @@ int L_DrawCircle(lua_State* L) LUA_ARG_NUMBER(3, "drawcircle", r, INT_MIN, INT_MAX); LUA_ARG_NUMBER(4, "drawcircle", c, INT_MIN, INT_MAX); - Pixel_figure = Display_pixel; + Pixel_figure = (void (*) (word,word,byte))Pixel_figure_no_screen; Circle_limit = r*r; Draw_empty_circle_general(x1, y1, r, c); @@ -410,18 +454,30 @@ int L_DrawCircle(lua_State* L) int L_DrawDisk(lua_State* L) { - int x1, y1, r, c; + int center_x, center_y, r, c; + long circle_limit; + short x_pos,y_pos; + short min_x,max_x,min_y,max_y; int nb_args = lua_gettop(L); LUA_ARG_LIMIT(4, "drawdisk"); - LUA_ARG_NUMBER(1, "drawdisk", x1, INT_MIN, INT_MAX); - LUA_ARG_NUMBER(2, "drawdisk", y1, INT_MIN, INT_MAX); + LUA_ARG_NUMBER(1, "drawdisk", center_x, INT_MIN, INT_MAX); + LUA_ARG_NUMBER(2, "drawdisk", center_y, INT_MIN, INT_MAX); LUA_ARG_NUMBER(3, "drawdisk", r, INT_MIN, INT_MAX); LUA_ARG_NUMBER(4, "drawdisk", c, INT_MIN, INT_MAX); - Circle_limit = r*r; - Draw_filled_circle(x1, y1, r, c); + circle_limit = r*r; + + // Compute clipping limits + min_x=center_x-r<0 ? 0 : center_x-r; + max_x=center_x+r>=Main_image_width? Main_image_width-1 : center_x+r; + min_y=center_y-r<0 ? 0 : center_y-r; + max_y=center_y+r>=Main_image_height? Main_image_height-1 : center_y+r; + + for (y_pos=min_y;y_pos<=max_y;y_pos++) + for (x_pos=min_x;x_pos<=max_x;x_pos++) + Pixel_in_current_screen(x_pos,y_pos,c,0); return 0; } diff --git a/src/graph.c b/src/graph.c index 077e062e..06c99716 100644 --- a/src/graph.c +++ b/src/graph.c @@ -1275,7 +1275,6 @@ void Draw_empty_circle_general(short center_x,short center_y,short radius,byte c Pixel_figure(center_x+radius,center_y,color); // Droite Pixel_figure(center_x,center_y+radius,color); // Bas - if(Main_magnifier_mode) Update_part_of_screen(center_x-radius,center_y-radius,2*radius+1,2*radius+1); } // -- Tracé définitif d'un cercle vide -- diff --git a/src/graph.h b/src/graph.h index efa74664..70c49d3c 100644 --- a/src/graph.h +++ b/src/graph.h @@ -63,6 +63,7 @@ void Draw_empty_circle_general(short center_x,short center_y,short radius,byte c void Draw_empty_circle_permanent(short center_x,short center_y,short radius,byte color); void Draw_empty_circle_preview (short center_x,short center_y,short radius,byte color); void Hide_empty_circle_preview (short center_x,short center_y,short radius); +void Draw_empty_circle_general(short center_x,short center_y,short radius,byte color); void Draw_filled_circle (short center_x,short center_y,short radius,byte color); void Draw_empty_ellipse_permanent(short center_x,short center_y,short horizontal_radius,short vertical_radius,byte color);