?? apollo.c
字號:
break;
case 5 : copy_selected_portion ( );
break;
case 6 : paste( );
printf ( "Paste" );
break;
default : return;
}
}
void paste_inside ( void )
{
int i = sminx;
int j = sminy;
c_c_p = fopen ("temp", "r" );
hide ( );
while ( j < smaxy)
{
putpixel( i, j , getc (c_c_p) - '0' );
i++;
if ( i == smaxx )
{
j++;
i = sminx;
}
}
fclose ( c_c_p );
show ( );
setfillstyle ( SOLID_FILL, LIGHTGRAY );
bar ( 0, 20, 640, 34 );
setcolor ( BLACK );
outtextxy ( 45, 25, "Paste" );
setcolor ( current_color );
}
void translate ( void )
{
union REGS in, out;
int tempx, tempy;
hide ( );
copy_selected_portion ( );
show ( );
first_trans = 1;
while ( 1 )
{
tempx = sminx;
tempy = sminy;
in.x.ax = 0x0003;
int86 ( 0x33, &in, &out );
if ( out.x.bx == 2 )
break;
else if ( out.x.bx == 0 )
continue;
if ( !in_range ( out.x.cx, CANV_X_MIN, CANV_X_MAX-smaxx+sminx ))
continue;
if ( !in_range ( out.x.dx, CANV_Y_MIN, CANV_Y_MAX - smaxy+sminy))
continue;
setfillstyle ( SOLID_FILL, LIGHTGRAY );
bar ( 0, 431, 640, 475 );
setcolor ( BLACK );
show_coords ( out.x.cx, out.x.dx );
hide ( );
copy_selected_portion ( );
show ( );
setfillstyle ( SOLID_FILL, WHITE );
bar ( sminx, sminy, smaxx, smaxy );
setcolor ( current_color );
sminx = out.x.cx;
sminy = out.x.dx;
smaxx = sminx+smaxx-tempx;
smaxy = sminy+smaxy-tempy;
hide ( );
paste_inside ( );
show( );
first_trans = 0;
delay ( 60 );
}
}
void paste_rotate ( int rot )
{
int i, j;
int check_x, check_y;
c_c_p = fopen ("temp", "r" );
if ( rot == 0 )
{
i = sminx;
j = smaxy;
check_x = sminx + smaxy - sminy;
check_y = smaxy - smaxx + sminx;
hide ( );
while ( i < check_x )
{
if ( in_range ( i, CANV_X_MIN, CANV_X_MAX ) && in_range ( j, CANV_Y_MIN, CANV_Y_MAX))
putpixel ( i, j, getc ( c_c_p ) - '0' );
j--;
if ( j == check_y )
{
j = smaxy;
i++;
}
}
}
else if ( rot == 1 )
{
i = sminx;
j = sminy;
while ( j < smaxy )
{
if ( in_range ( i, CANV_X_MIN, CANV_X_MAX ) && in_range ( j, CANV_Y_MIN, CANV_Y_MAX))
putpixel ( i, j, getc ( c_c_p ) - '0' );
i--;
if ( i == sminx - ( smaxx - sminx ))
{
i = sminx;
j++;
}
}
}
else if ( rot == 2 )
{
i = sminx;
j = smaxy;
while ( i < sminx + ( smaxy - sminy ))
{
if ( in_range ( i, CANV_X_MIN, CANV_X_MAX ) && in_range ( j, CANV_Y_MIN, CANV_Y_MAX))
putpixel ( i, j, getc ( c_c_p ) -'0' );
j++;
if ( j == smaxy + ( smaxx - sminx ))
{
j = smaxy;
i++;
}
}
}
else if ( rot == 3 )
{
i = sminx;
j = sminy;
while ( j < smaxy)
{
if ( in_range ( i, CANV_X_MIN, CANV_X_MAX ) && in_range ( j, CANV_Y_MIN, CANV_Y_MAX))
putpixel( i, j , getc (c_c_p) - '0' );
i++;
if ( i == smaxx )
{
j++;
i = sminx;
}
}
}
fclose ( c_c_p );
show ( );
setfillstyle ( SOLID_FILL, LIGHTGRAY );
bar ( 0, 20, 640, 34 );
setcolor ( BLACK );
outtextxy ( 45, 25, "Paste" );
setcolor ( current_color );
}
void rotate ( void )
{
union REGS in, out;
int count = 0;
hide ( );
copy_selected_portion ( );
show ( );
while ( 1 )
{
in.x.ax = 0x0003;
int86 ( 0x33, &in, &out );
if ( out.x.bx == 2 )
break;
else if ( out.x.bx == 0 )
continue;
setfillstyle ( SOLID_FILL, WHITE );
if ( count == 0 )
bar ( max ( sminx, CANV_X_MIN ), max ( sminy, CANV_Y_MIN ), min ( smaxx, CANV_X_MAX), min ( smaxy, CANV_Y_MAX) );
if ( count == 1 )
bar ( max ( CANV_X_MIN, sminx), max ( CANV_Y_MIN, smaxy-smaxx+sminx), min ( CANV_X_MAX, sminx + smaxy-sminy), min ( CANV_Y_MAX, smaxy) );
if ( count == 2 )
bar ( max ( CANV_X_MIN, sminx +sminx - smaxx), max ( CANV_Y_MIN, sminy ), min ( CANV_X_MAX, sminx), min ( CANV_Y_MAX, smaxy) );
if ( count == 3 )
bar ( max ( CANV_X_MIN, sminx), max ( CANV_Y_MIN, smaxy), min ( CANV_X_MAX, sminx + smaxy-sminy ), min ( CANV_Y_MAX, smaxy+smaxx - sminx) );
setfillstyle ( SOLID_FILL, LIGHTGRAY );
bar ( 0, 431, 640, 475 );
setcolor ( BLACK );
show_coords ( out.x.cx, out.x.dx );
setcolor ( current_color );
hide ( );
paste_rotate( count );
show ( );
count++;
if ( count == 4 )
count = 0;
delay ( 150 );
}
}
void draw_line ( )
{
union REGS in,out;
int start_x, start_y, cur_x, cur_y;
while ( 1 )
{
in.x.ax = 0x0003;
int86 ( 0x33, &in, &out );
delay ( 5 );
setfillstyle ( SOLID_FILL, LIGHTGRAY );
bar ( 0, 431, 640, 475 );
setcolor ( BLACK );
show_coords ( out.x.cx, out.x.dx );
setcolor ( current_color );
scan_menu ( );
if ( tool_selected ( out ) && get_tool ( out.x.cx, out.x.dx ) != 2 )
return;
else if ( in_range ( out.x.cx,625, 635 ) && in_range ( out.x.dx, 7, 17 )&& out.x.bx==1)
exit ( 0 );
else if ( color_selected ( out ) )
show_current_color ( out.x.cx, out.x.dx, out.x.bx );
if ( !in_range ( out.x.cx, 50, 605 ) || !in_range ( out.x.dx, 35, 430))
continue;
else if ( out.x.bx == 1 )
{
start_x = out.x.cx;
start_y = out.x.dx;
do
{
in.x.ax = 0x0003;
int86 ( 0x33, &in, &out );
hide ( );
setcolor ( 15 - current_color );
setwritemode ( XOR_PUT );
//fixing limits for my drawing
if ( out.x.cx < 50 )
cur_x = 50;
else if ( out.x.cx > 605 )
cur_x = 605;
else
cur_x = out.x.cx;
if ( out.x.dx < 35 )
cur_y = 35;
else if ( out.x.dx > 430 )
cur_y = 430;
else
cur_y = out.x.dx;
// finished fixing the points
//now start drawing
line ( start_x, start_y, cur_x, cur_y );
//finished drawing
show ( );
delay ( 40 );
hide ( );
line ( start_x, start_y, cur_x, cur_y );
show ();
setfillstyle ( SOLID_FILL, LIGHTGRAY );
bar ( 0, 431, 640, 475);
setcolor ( BLACK );
show_coords ( out.x.cx, out.x.dx );
setcolor ( 15 - current_color );
} while ( out.x.bx == 1 );
setcolor ( current_color );
setwritemode ( COPY_PUT );
hide ( );
line ( start_x, start_y, cur_x, cur_y );
show ( );
}
}
}
void draw_rectangle ( )
{
union REGS in,out;
int start_x, start_y, cur_x, cur_y;
while ( 1 )
{
in.x.ax = 0x0003;
int86 ( 0x33, &in, &out );
delay ( 5 );
setfillstyle ( SOLID_FILL, LIGHTGRAY );
bar ( 0, 431, 640, 475 );
setcolor ( BLACK );
show_coords ( out.x.cx, out.x.dx );
setcolor ( current_color );
scan_menu ( );
if ( select_flag && tool_selected ( out ) && get_tool ( out.x.cx, out.x.dx ) != 10 )
return;
if ( !select_flag && tool_selected ( out ) && get_tool ( out.x.cx, out.x.dx ) != 4 )
return;
else if ( in_range ( out.x.cx,625, 635 ) && in_range ( out.x.dx, 7, 17 )&& out.x.bx==1)
exit ( 0 );
else if ( color_selected ( out ) )
show_current_color ( out.x.cx, out.x.dx, out.x.bx );
if ( !in_range ( out.x.cx, 50, 605 ) || !in_range ( out.x.dx, 35, 430))
continue;
else if ( out.x.bx == 1 )
{
start_x = out.x.cx;
start_y = out.x.dx;
do
{
in.x.ax = 0x0003;
int86 ( 0x33, &in, &out );
hide ( );
setcolor ( 15 - current_color );
setwritemode ( XOR_PUT );
//fixing limits for my drawing
if ( out.x.cx < 50 )
cur_x = 50;
else if ( out.x.cx > 605 )
cur_x = 605;
else
cur_x = out.x.cx;
if ( out.x.dx < 35 )
cur_y = 35;
else if ( out.x.dx > 430 )
cur_y = 430;
else
cur_y = out.x.dx;
// finished fixing the points
//now start drawing
rectangle ( start_x, start_y, cur_x, cur_y );
//finished drawing
show ( );
delay ( 40 );
hide ( );
rectangle ( start_x, start_y, cur_x, cur_y );
show ();
setfillstyle ( SOLID_FILL, LIGHTGRAY );
bar ( 0, 430, 640, 475);
setcolor ( BLACK );
show_coords ( out.x.cx, out.x.dx );
setcolor ( 15 - current_color );
} while ( out.x.bx == 1 );
setcolor ( current_color );
if ( select_flag )
{
sminx = start_x;
sminy = start_y;
smaxx = cur_x;
smaxy = cur_y;
return;
}
setwritemode ( COPY_PUT );
hide ( );
rectangle ( start_x, start_y, cur_x, cur_y );
show ( );
}
}
}
void draw_ellipse ( )
{
union REGS in,out;
int start_x, start_y, cur_x, cur_y, center_x =0 , center_y = 0, rad_x= 0, rad_y= 0;
while ( 1 )
{
in.x.ax = 0x0003;
center_x = center_y = rad_x = rad_y = 0;
int86 ( 0x33, &in, &out );
delay ( 5 );
setfillstyle ( SOLID_FILL, LIGHTGRAY );
bar ( 0, 431, 640, 475 );
setcolor ( BLACK );
show_coords ( out.x.cx, out.x.dx );
setcolor ( current_color );
scan_menu ( );
if ( tool_selected ( out ) && get_tool ( out.x.cx, out.x.dx ) != 3 )
return;
else if ( in_range ( out.x.cx,625, 635 ) && in_range ( out.x.dx, 7, 17 )&& out.x.bx==1)
exit ( 0 );
else if ( color_selected ( out ) )
show_current_color ( out.x.cx, out.x.dx, out.x.bx );
if ( !in_range ( out.x.cx, 50, 605 ) || !in_range ( out.x.dx, 35, 430))
continue;
else if ( out.x.bx == 1 )
{
start_x = out.x.cx;
start_y = out.x.dx;
do
{
in.x.ax = 0x0003;
int86 ( 0x33, &in, &out );
hide ( );
setcolor ( 15 - current_color );
setwritemode ( XOR_PUT );
//fixing limits for my drawing
if ( out.x.cx < 50 )
cur_x = 50;
else if ( out.x.cx > 605 )
cur_x = 605;
else
cur_x = out.x.cx;
if ( out.x.dx < 35 )
cur_y = 35;
else if ( out.x.dx > 430 )
cur_y = 430;
else
cur_y = out.x.dx;
// finished fixing the points
//now start drawing
rectangle ( start_x, start_y, cur_x, cur_y );
//finished drawing
show ( );
delay ( 40 );
hide ( );
rectangle ( start_x, start_y, cur_x, cur_y );
show ();
setfillstyle ( SOLID_FILL, LIGHTGRAY );
bar ( 0, 431, 640, 475);
setcolor ( BLACK );
show_coords ( out.x.cx, out.x.dx );
setcolor ( 15 - current_color );
} while ( out.x.bx == 1 );
if ( cur_x > start_x )
center_x = start_x + (cur_x- start_x)/2;
else
center_x = start_x - (start_x-cur_x)/2;
if ( cur_y > start_y )
center_y = start_y + (-start_y+cur_y)/2;
else
center_y = start_y - (start_y-cur_y)/2;
rad_x = abs ( start_x - cur_x )/2;
rad_y = abs ( start_y - cur_y )/2;
hide ( );
setcolor ( current_color );
ellipse ( center_x, center_y, 0, 360, rad_x, rad_y );
show ( );
}
}
}
void draw_polygon ( )
{
union REGS in,out;
int start_x = 0, start_y = 0;
int cur_x = 0, cur_y = 0;
int flag = 0;
int stx = 0, sty = 0;
while ( 1 )
{
in.x.ax = 0x0003;
int86 ( 0x33, &in, &out );
delay ( 5 );
setfillstyle ( SOLID_FILL, LIGHTGRAY );
bar ( 0, 431, 640, 475 );
setcolor ( BLACK );
show_coords ( out.x.cx, out.x.dx );
setcolor ( current_color );
scan_menu ( );
if ( tool_selected ( out ) && get_tool ( out.x.cx, out.x.dx ) != 5 )
return;
else if ( in_range ( out.x.cx,625, 635 ) && in_range ( out.x.dx, 7, 17 )&& out.x.bx==1)
exit ( 0 );
else if ( color_selected ( out ) )
show_current_color ( out.x.cx, out.x.dx, out.x.bx );
if ( !in_range ( out.x.cx, 50, 605 ) || !in_range ( out.x.dx, 35, 430))
continue;
if ( flag && out.x.bx == 2 )
{
hide ( );
line ( start_x, start_y, stx, sty );
show ( );
flag = 0;
continue;
}
else if ( out.x.bx == 1 )
{
start_x = out.x.cx;
start_y = out.x.dx;
do
{
if (flag)
goto next;
in.x.ax = 0x0003;
int86 ( 0x33, &in, &out );
hide ( );
setcolor ( 15 - current_color );
setwritemode ( XOR_PUT );
//fixing limits for my drawing
if ( out.x.cx < 50 )
cur_x = 50;
else if ( out.x.cx > 605 )
cur_x = 604;
else
cur_x = out.x.cx;
if ( out.x.dx < 35 )
cur_y = 35;
else if ( out.x.dx > 430 )
cur_y = 430;
else
cur_y = out.x.dx;
// finished fixing the point
//now start drawing
stx = start_x;
sty = start_y;
line ( start_x, start_y, cur_x, cur_y );
//finished drawing
show ( );
delay ( 40 );
hide ( );
line ( start_x, start_y, cur_x, cur_y );
show ();
setfillstyle ( SOLID_FILL, LIGHTGRAY );
bar ( 0, 430, 640, 475);
setcolor ( BLACK );
show_coords ( out.x.cx, out.x.dx );
setcolor ( 15 - current_color );
} while ( out.x.bx == 1 );
setcolor ( current_color );
setwritemode ( COPY_PUT );
hide ( );
line ( start_x, start_y, cur_x, cur_y );
flag = 1;
show ( );
}
if ( flag )
continue;
next :
hide ( );
line ( cur_x, cur_y, start_x, start_y );
cur_x = start_x;
cur_y = start_y;
show ( );
}
}
void set_normal_pointer ( void )
{
int normal[] = { 0x3fff, 0x1fff, 0x0fff, 0x07ff,
0x03ff, 0x01ff, 0x00ff, 0x007f,
0x003f, 0x001f, 0x000f, 0x0007,
0x30ff, 0x70ff, 0xf87f, 0xf8ff,
0x0000, 0x4000, 0x6000, 0x7000,
0x7800, 0x7c00, 0x7e00, 0x7f00,
0x7f80, 0x7fc0, 0x7fe0, 0x4e00,
0x0600, 0x0700, 0x0300, 0x0000
};
union REGS in ,out;
struct SREGS s;
current_pointer = NORMAL;
in.x.ax = 0x0009;
in.x.bx = 0;
in.x.cx = 0;
in.x.dx = ( unsigned )normal;
segread ( &s );
s.es = s.ds;
int86x ( 0x33, &in, &out, &s );
}
void set_eraser ( void )
{
int eraseptr[] = { 0x01ff, 0x03ff, 0x03ff, 0x03ff,
0x03ff, 0x03ff, 0x03ff, 0x01ff,
0xffff, 0xffff, 0xffff, 0xffff,
0xffff, 0xffff, 0xffff, 0xffff,
0x0000, 0x7e00, 0x7e00, 0x7e00,
0x7e00, 0x7e00, 0x7e00, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000
};
union REGS in ,out;
struct SREGS s;
current_pointer = ERASER;
in.x.ax = 0x0009;
in.x.bx = 0;
in.x.cx = 0;
in.x.dx = ( unsigned ) eraseptr;
segread ( &s );
s.es = s.ds;
int86x ( 0x33, &in, &out, &s );
show ();
}
void erase ( void )
{
union REGS in, out;
while ( 1 )
{
restrict ( 0, 0, getmaxx ( ), getmaxy ( ) );
do
{
in.x.ax = 0x0003;
int86 ( 0x33, &in, &out );
delay ( 5 );
setfillstyle ( SOLID_FILL, LIGHTGRAY );
bar ( 0, 431, 640, 475 );
setcolor ( BLACK );
show_coords ( out.x.cx, out.x.dx );
setcolor ( current_color );
scan_menu ( );
if ( in_range ( out.x.cx, 50, 598 ) && in_range ( out.x.dx, 35, 623 ) && current_pointer != ERASER)
set_eraser ( );
else if ( (in_range ( out.x.cx, 50, 605 ) == 0 || in_range ( out.x.dx, 35, 430)==0) && current_pointer != NORMAL )
set_normal_pointer ( );
if ( tool_selected ( out ) && get_tool ( out.x.cx, out.x.dx ) != 6 )
{
current_pointer = NORMAL;
set_normal_pointer ( );
return;
}
else if ( in_range ( out.x.cx,625, 635 ) && in_range ( out.x.dx, 7, 17 )&& out.x.bx==1)
exit ( 0 );
else if ( color_selected ( out ) )
show_current_color ( out.x.cx, out.x.dx, out.x.bx );
if ( !in_range ( out.x.cx, 50, 605 ) || !in_range ( out.x.dx, 35, 430))
continue;
}while ( out.x.bx != 1 );
set_eraser ( );
current_pointer = ERASER;
do
{
in.x.ax = 0x0003;
int86 ( 0x33, &in, &out );
delay ( 5 );
setfillstyle ( SOLID_FILL, LIGHTGRAY );
bar ( 0, 431, 640, 475 );
setcolor ( BLACK );
show_coords ( out.x.cx, out.x.dx );
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -