a rotate tool! ctrl-r, then select the area, it will rotate counterclockwise, no properties are saved right now, it deletes and recreates.
This commit is contained in:
parent
5b2c689394
commit
327ccb7bba
@ -634,6 +634,8 @@ void update_particles_i(pixel *vid, int start, int inc);
|
|||||||
|
|
||||||
void update_particles(pixel *vid);
|
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 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);
|
void create_box(int x1, int y1, int x2, int y2, int c);
|
||||||
|
26
src/main.c
26
src/main.c
@ -1463,8 +1463,6 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
if(sdl_key=='d')
|
if(sdl_key=='d')
|
||||||
DEBUG_MODE = !DEBUG_MODE;
|
DEBUG_MODE = !DEBUG_MODE;
|
||||||
if(sdl_key=='r')
|
|
||||||
GENERATION = 0;
|
|
||||||
if(sdl_key=='i')
|
if(sdl_key=='i')
|
||||||
{
|
{
|
||||||
int nx, ny;
|
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)))
|
if(sdl_key=='x'&&(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL)))
|
||||||
{
|
{
|
||||||
save_mode = 1;
|
save_mode = 1;
|
||||||
@ -1868,6 +1873,14 @@ int main(int argc, char *argv[])
|
|||||||
copy_mode = 0;
|
copy_mode = 0;
|
||||||
clear_area(save_x*CELL, save_y*CELL, save_w*CELL, save_h*CELL);
|
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
|
else
|
||||||
{
|
{
|
||||||
stamp_save(save_x*CELL, save_y*CELL, save_w*CELL, save_h*CELL);
|
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)
|
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;
|
da = 51;
|
||||||
db = 269;
|
db = 269;
|
||||||
}
|
}
|
||||||
|
55
src/powder.c
55
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; cy<area_h; cy++)
|
||||||
|
{
|
||||||
|
for(cx=0; cx<area_w; cx++)
|
||||||
|
{
|
||||||
|
if(area_x + cx<XRES&&area_y + cy<YRES)
|
||||||
|
bmap[(cy+area_y)/CELL][(cx+area_x)/CELL] = 0;
|
||||||
|
//tbmap[cy][cx] = bmap[(cy+area_y)/CELL][(cx+area_x)/CELL];//does not do walls right now, very glitchy
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(cy=0; cy<area_h; cy++)
|
||||||
|
{
|
||||||
|
for(cx=0; cx<area_w; cx++)
|
||||||
|
{
|
||||||
|
if((area_x + cx<XRES&&area_y + cy<YRES) && !bmap[(cy+area_y)/CELL][(cx+area_x)/CELL])
|
||||||
|
{
|
||||||
|
tpmap[cy][cx] = pmap[(int)(cy+area_y+0.5f)][(int)(cx+area_x+0.5f)]&0xFF;
|
||||||
|
delete_part(cx+area_x, cy+area_y);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
tpmap[cy][cx] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(cy=0; cy<area_w; cy++)
|
||||||
|
{
|
||||||
|
for(cx=0; cx<area_h; cx++)
|
||||||
|
{
|
||||||
|
//rtbmap[(area_h-1)-cx][cy] = tbmap[cy][cx];
|
||||||
|
rtpmap[(area_h-1)-cx][cy] = tpmap[cy][cx];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(cy=0; cy<area_w; cy++)
|
||||||
|
{
|
||||||
|
for(cx=0; cx<area_h; cx++)
|
||||||
|
{
|
||||||
|
//bmap[area_y+cy][area_x+cx] = rtbmap[cy][cx];
|
||||||
|
if(area_x + cx<XRES&&area_y + cy<YRES)
|
||||||
|
if(rtpmap[cy][cx]>0&&rtpmap[cy][cx]<PT_NUM)
|
||||||
|
create_part(-1,area_x + cx,area_y + cy,rtpmap[cy][cx]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void clear_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)
|
||||||
{
|
{
|
||||||
int cx = 0;
|
int cx = 0;
|
||||||
@ -5152,7 +5202,10 @@ int create_parts(int x, int y, int rx, int ry, int c)
|
|||||||
for(j=-ry; j<=ry; j++)
|
for(j=-ry; j<=ry; j++)
|
||||||
for(i=-rx; i<=rx; i++)
|
for(i=-rx; i<=rx; i++)
|
||||||
if((CURRENT_BRUSH==CIRCLE_BRUSH && (pow(i,2))/(pow(rx,2))+(pow(j,2))/(pow(ry,2))<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=ry*rx))
|
if((CURRENT_BRUSH==CIRCLE_BRUSH && (pow(i,2))/(pow(rx,2))+(pow(j,2))/(pow(ry,2))<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=ry*rx))
|
||||||
create_part(-2, x+i, y+j, c);
|
if(!REPLACE_MODE)
|
||||||
|
create_part(-2, x+i, y+j, c);
|
||||||
|
else if((pmap[y+j][x+i]&0xFF)==SLALT&&SLALT!=0)
|
||||||
|
create_part(-2, x+i, y+j, c);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user