diff --git a/includes/powder.h b/includes/powder.h index c061a144c..05b4a69c4 100644 --- a/includes/powder.h +++ b/includes/powder.h @@ -634,6 +634,8 @@ void update_particles_i(pixel *vid, int start, int inc); void update_particles(pixel *vid); +void rotate_area(int area_x, int area_y, int area_w, int area_h); + void clear_area(int area_x, int area_y, int area_w, int area_h); void create_box(int x1, int y1, int x2, int y2, int c); diff --git a/src/main.c b/src/main.c index 92caf3a7c..300d593fe 100644 --- a/src/main.c +++ b/src/main.c @@ -1463,8 +1463,6 @@ int main(int argc, char *argv[]) } if(sdl_key=='d') DEBUG_MODE = !DEBUG_MODE; - if(sdl_key=='r') - GENERATION = 0; if(sdl_key=='i') { int nx, ny; @@ -1512,6 +1510,13 @@ int main(int argc, char *argv[]) } } } + if(sdl_key=='r'&&(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL))) + { + save_mode = 1; + copy_mode = 3;//rotate + } + else if(sdl_key=='r') + GENERATION = 0; if(sdl_key=='x'&&(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL))) { save_mode = 1; @@ -1868,6 +1873,14 @@ int main(int argc, char *argv[]) copy_mode = 0; clear_area(save_x*CELL, save_y*CELL, save_w*CELL, save_h*CELL); } + else if(copy_mode==3)//rotation + { + if(save_h>save_w) + save_w = save_h; + rotate_area(save_x*CELL, save_y*CELL, save_w*CELL, save_w*CELL);//just do squares for now + save_mode = 0; + copy_mode = 0; + } else { stamp_save(save_x*CELL, save_y*CELL, save_w*CELL, save_h*CELL); @@ -2148,7 +2161,14 @@ int main(int argc, char *argv[]) if(save_mode) { - xor_rect(vid_buf, save_x*CELL, save_y*CELL, save_w*CELL, save_h*CELL); + if(copy_mode==3)//special drawing for rotate, can remove once it can do rectangles + { + if(save_h>save_w) + save_w = save_h; + xor_rect(vid_buf, save_x*CELL, save_y*CELL, save_w*CELL, save_w*CELL); + } + else + xor_rect(vid_buf, save_x*CELL, save_y*CELL, save_w*CELL, save_h*CELL); da = 51; db = 269; } diff --git a/src/powder.c b/src/powder.c index 1ba31f9ca..be6735ad4 100644 --- a/src/powder.c +++ b/src/powder.c @@ -4918,6 +4918,56 @@ void update_particles(pixel *vid) } +void rotate_area(int area_x, int area_y, int area_w, int area_h) +{ + int cx = 0; + int cy = 0; + char tpmap[area_h][area_w]; + char rtpmap[area_w][area_h]; + unsigned char tbmap[area_h][area_w]; + unsigned char rtbmap[area_h][area_w]; + for(cy=0; cy0&&rtpmap[cy][cx]