Remove Circle_limit global variable
This commit is contained in:
parent
ce1b55be03
commit
d6ce86cae4
@ -599,8 +599,7 @@ int L_DrawCircle(lua_State* L)
|
||||
LUA_ARG_NUMBER(4, "drawcircle", c, INT_MIN, INT_MAX);
|
||||
|
||||
Set_Pixel_figure((void (*) (word,word,byte))Pixel_figure_no_screen);
|
||||
Circle_limit = r*r;
|
||||
Draw_empty_circle_general(x1, y1, r, c);
|
||||
Draw_empty_circle_general(x1, y1, r*r, c);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -566,10 +566,6 @@ GFX2_GLOBAL byte Mask_table[256];
|
||||
extern word ZOOM_FACTOR[NB_ZOOM_FACTORS];
|
||||
#endif
|
||||
|
||||
// -- Data for ellipses and circles
|
||||
// FIXME: move this to graph.c
|
||||
GFX2_GLOBAL long Circle_limit;
|
||||
|
||||
// -- Data for gradients
|
||||
|
||||
/// First color of the gradient.
|
||||
|
||||
40
src/graph.c
40
src/graph.c
@ -104,9 +104,9 @@ static byte Pixel_in_ellipse(long x, long y, const T_Ellipse_limits * Ellipse)
|
||||
// Circle_cursor_Y pixels (Circle_cursor_Y>0 = en bas,
|
||||
// Circle_cursor_Y<0 = en haut) du centre se trouve dans le cercle en
|
||||
// cours.
|
||||
static byte Pixel_in_circle(long x, long y)
|
||||
static byte Pixel_in_circle(long x, long y, long limit)
|
||||
{
|
||||
if((x * x + y * y) <= Circle_limit)
|
||||
if((x * x + y * y) <= limit)
|
||||
return 255;
|
||||
return 0;
|
||||
}
|
||||
@ -1219,13 +1219,16 @@ void Fill_general(byte fill_color)
|
||||
|
||||
// -- Tracer général d'un cercle vide -------------------------------------
|
||||
|
||||
void Draw_empty_circle_general(short center_x,short center_y,short radius,byte color)
|
||||
void Draw_empty_circle_general(short center_x,short center_y, long sqradius,byte color)
|
||||
{
|
||||
short start_x;
|
||||
short start_y;
|
||||
short x_pos;
|
||||
short y_pos;
|
||||
long x, y;
|
||||
short radius;
|
||||
|
||||
radius = sqrt(sqradius);
|
||||
|
||||
// Ensuite, on va parcourire le quart haut gauche du cercle
|
||||
start_x=center_x-radius;
|
||||
@ -1234,7 +1237,7 @@ void Draw_empty_circle_general(short center_x,short center_y,short radius,byte c
|
||||
// Affichage des extremitées du cercle sur chaque quart du cercle:
|
||||
for (y_pos=start_y,y=-radius;y_pos<center_y;y_pos++,y++)
|
||||
for (x_pos=start_x,x=-radius;x_pos<center_x;x_pos++,x++)
|
||||
if (Pixel_in_circle(x, y))
|
||||
if (Pixel_in_circle(x, y, sqradius))
|
||||
{
|
||||
// On vient de tomber sur le premier point sur la ligne horizontale
|
||||
// qui fait partie du cercle.
|
||||
@ -1252,7 +1255,7 @@ void Draw_empty_circle_general(short center_x,short center_y,short radius,byte c
|
||||
// On peut ensuite afficher tous les points qui le suivent dont le
|
||||
// pixel voisin du haut n'appartient pas au cercle:
|
||||
for (y--,x_pos++,x++;x_pos<center_x;x_pos++,x++)
|
||||
if (!Pixel_in_circle(x, y))
|
||||
if (!Pixel_in_circle(x, y, sqradius))
|
||||
{
|
||||
// Quart Haut-gauche
|
||||
Pixel_figure(x_pos,y_pos,color);
|
||||
@ -1280,35 +1283,38 @@ void Draw_empty_circle_general(short center_x,short center_y,short radius,byte c
|
||||
|
||||
// -- Tracé définitif d'un cercle vide --
|
||||
|
||||
void Draw_empty_circle_permanent(short center_x,short center_y,short radius,byte color)
|
||||
void Draw_empty_circle_permanent(short center_x,short center_y,long sqradius,byte color)
|
||||
{
|
||||
short radius = sqrt(sqradius);
|
||||
Pixel_figure=Pixel_figure_permanent;
|
||||
Init_permanent_draw();
|
||||
Draw_empty_circle_general(center_x,center_y,radius,color);
|
||||
Draw_empty_circle_general(center_x,center_y,sqradius,color);
|
||||
Update_part_of_screen(center_x - radius, center_y - radius, 2* radius+1, 2*radius+1);
|
||||
}
|
||||
|
||||
// -- Tracer la preview d'un cercle vide --
|
||||
|
||||
void Draw_empty_circle_preview(short center_x,short center_y,short radius,byte color)
|
||||
void Draw_empty_circle_preview(short center_x,short center_y,long sqradius,byte color)
|
||||
{
|
||||
short radius = sqrt(sqradius);
|
||||
Pixel_figure=Pixel_figure_preview;
|
||||
Draw_empty_circle_general(center_x,center_y,radius,color);
|
||||
Draw_empty_circle_general(center_x,center_y,sqradius,color);
|
||||
Update_part_of_screen(center_x - radius, center_y - radius, 2* radius+1, 2*radius+1);
|
||||
}
|
||||
|
||||
// -- Effacer la preview d'un cercle vide --
|
||||
|
||||
void Hide_empty_circle_preview(short center_x,short center_y,short radius)
|
||||
void Hide_empty_circle_preview(short center_x,short center_y,long sqradius)
|
||||
{
|
||||
short radius = sqrt(sqradius);
|
||||
Pixel_figure=Pixel_figure_clear_preview;
|
||||
Draw_empty_circle_general(center_x,center_y,radius,0);
|
||||
Draw_empty_circle_general(center_x,center_y,sqradius,0);
|
||||
Update_part_of_screen(center_x - radius, center_y - radius, 2* radius+1, 2*radius+1);
|
||||
}
|
||||
|
||||
// -- Tracer un cercle plein --
|
||||
|
||||
void Draw_filled_circle(short center_x,short center_y,short radius,byte color)
|
||||
void Draw_filled_circle(short center_x,short center_y,long sqradius,byte color)
|
||||
{
|
||||
short start_x;
|
||||
short start_y;
|
||||
@ -1317,6 +1323,7 @@ void Draw_filled_circle(short center_x,short center_y,short radius,byte color)
|
||||
short end_x;
|
||||
short end_y;
|
||||
long x, y;
|
||||
short radius = sqrt(sqradius);
|
||||
|
||||
start_x=center_x-radius;
|
||||
start_y=center_y-radius;
|
||||
@ -1336,7 +1343,7 @@ void Draw_filled_circle(short center_x,short center_y,short radius,byte color)
|
||||
// Affichage du cercle
|
||||
for (y_pos=start_y,y=(long)start_y-center_y;y_pos<=end_y;y_pos++,y++)
|
||||
for (x_pos=start_x,x=(long)start_x-center_x;x_pos<=end_x;x_pos++,x++)
|
||||
if (Pixel_in_circle(x, y))
|
||||
if (Pixel_in_circle(x, y, sqradius))
|
||||
Display_pixel(x_pos,y_pos,color);
|
||||
|
||||
Update_part_of_screen(start_x,start_y,end_x+1-start_x,end_y+1-start_y);
|
||||
@ -2209,7 +2216,7 @@ void Gradient_extra_dithered(long index,short x_pos,short y_pos)
|
||||
|
||||
// -- Tracer un cercle degradé (une sphère) --
|
||||
|
||||
void Draw_grad_circle(short center_x,short center_y,short radius,short spot_x,short spot_y)
|
||||
void Draw_grad_circle(short center_x,short center_y,long sqradius,short spot_x,short spot_y)
|
||||
{
|
||||
long start_x;
|
||||
long start_y;
|
||||
@ -2220,6 +2227,7 @@ void Draw_grad_circle(short center_x,short center_y,short radius,short spot_x,sh
|
||||
long distance_x; // Distance (au carré) sur les X du point en cours au centre d'éclairage
|
||||
long distance_y; // Distance (au carré) sur les Y du point en cours au centre d'éclairage
|
||||
long x, y;
|
||||
short radius = sqrt(sqradius);
|
||||
|
||||
start_x=center_x-radius;
|
||||
start_y=center_y-radius;
|
||||
@ -2236,7 +2244,7 @@ void Draw_grad_circle(short center_x,short center_y,short radius,short spot_x,sh
|
||||
if (end_x>Limit_right)
|
||||
end_x=Limit_right;
|
||||
|
||||
Gradient_total_range=Circle_limit+
|
||||
Gradient_total_range=sqradius+
|
||||
((center_x-spot_x)*(center_x-spot_x))+
|
||||
((center_y-spot_y)*(center_y-spot_y))+
|
||||
(2L*radius*sqrt(
|
||||
@ -2252,7 +2260,7 @@ void Draw_grad_circle(short center_x,short center_y,short radius,short spot_x,sh
|
||||
distance_y =(y_pos-spot_y);
|
||||
distance_y*=distance_y;
|
||||
for (x_pos=start_x,x=(long)start_x-center_x;x_pos<=end_x;x_pos++,x++)
|
||||
if (Pixel_in_circle(x, y))
|
||||
if (Pixel_in_circle(x, y, sqradius))
|
||||
{
|
||||
distance_x =(x_pos-spot_x);
|
||||
distance_x*=distance_x;
|
||||
|
||||
14
src/graph.h
14
src/graph.h
@ -60,13 +60,13 @@ void Pixel_figure_preview_xor(short x_pos,short y_pos,byte color);
|
||||
void Pixel_figure_preview_xorback(word x_pos,word y_pos,byte color);
|
||||
void Pixel_figure_in_brush(word x_pos,word y_pos,byte color);
|
||||
|
||||
void Draw_empty_circle_general(short center_x,short center_y,short radius,byte color);
|
||||
void Draw_empty_circle_general(short center_x,short center_y,long sqradius,byte color);
|
||||
|
||||
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_circle_permanent(short center_x,short center_y,long sqradius,byte color);
|
||||
void Draw_empty_circle_preview (short center_x,short center_y,long sqradius,byte color);
|
||||
void Hide_empty_circle_preview (short center_x,short center_y,long sqradius);
|
||||
void Draw_empty_circle_general(short center_x,short center_y,long sqradius,byte color);
|
||||
void Draw_filled_circle (short center_x,short center_y,long sqradius,byte color);
|
||||
|
||||
int Circle_squared_diameter(int diameter);
|
||||
|
||||
@ -97,7 +97,7 @@ void Gradient_dithered (long index,short x_pos,short y_pos);
|
||||
void Gradient_extra_dithered(long index,short x_pos,short y_pos);
|
||||
void Degrade_aleatoire (long index,short x_pos,short y_pos);
|
||||
|
||||
void Draw_grad_circle (short center_x,short center_y,short radius,short spot_x,short spot_y);
|
||||
void Draw_grad_circle (short center_x,short center_y,long sqradius,short spot_x,short spot_y);
|
||||
void Draw_grad_ellipse(short center_x,short center_y,short horizontal_radius,short vertical_radius,short spot_x,short spot_y);
|
||||
void Draw_grad_rectangle(short rax,short ray,short rbx,short rby,short vax,short vay, short vbx, short vby);
|
||||
|
||||
|
||||
@ -996,7 +996,7 @@ void Circle_12_5(void)
|
||||
short center_x;
|
||||
short center_y;
|
||||
short color;
|
||||
short radius;
|
||||
long limit;
|
||||
char str[5];
|
||||
|
||||
Operation_pop(&tangent_y);
|
||||
@ -1017,15 +1017,13 @@ void Circle_12_5(void)
|
||||
else
|
||||
Print_coordinates();
|
||||
|
||||
Circle_limit=((tangent_x-center_x)*(tangent_x-center_x))+
|
||||
((tangent_y-center_y)*(tangent_y-center_y));
|
||||
radius=sqrt(Circle_limit);
|
||||
Hide_empty_circle_preview(center_x,center_y,radius);
|
||||
limit=((tangent_x-center_x)*(tangent_x-center_x))+
|
||||
((tangent_y-center_y)*(tangent_y-center_y));
|
||||
Hide_empty_circle_preview(center_x,center_y,limit);
|
||||
|
||||
Circle_limit=((Paintbrush_X-center_x)*(Paintbrush_X-center_x))+
|
||||
((Paintbrush_Y-center_y)*(Paintbrush_Y-center_y));
|
||||
radius=sqrt(Circle_limit);
|
||||
Draw_empty_circle_preview(center_x,center_y,radius,color);
|
||||
limit=((Paintbrush_X-center_x)*(Paintbrush_X-center_x))+
|
||||
((Paintbrush_Y-center_y)*(Paintbrush_Y-center_y));
|
||||
Draw_empty_circle_preview(center_x,center_y,limit,color);
|
||||
|
||||
Display_cursor();
|
||||
}
|
||||
@ -1052,7 +1050,7 @@ void Empty_circle_0_5(void)
|
||||
short center_x;
|
||||
short center_y;
|
||||
short color;
|
||||
short radius;
|
||||
long limit;
|
||||
|
||||
Operation_pop(&tangent_y);
|
||||
Operation_pop(&tangent_x);
|
||||
@ -1060,14 +1058,13 @@ void Empty_circle_0_5(void)
|
||||
Operation_pop(¢er_x);
|
||||
Operation_pop(&color);
|
||||
|
||||
Circle_limit=((tangent_x-center_x)*(tangent_x-center_x))+
|
||||
((tangent_y-center_y)*(tangent_y-center_y));
|
||||
radius=sqrt(Circle_limit);
|
||||
Hide_empty_circle_preview(center_x,center_y,radius);
|
||||
limit=((tangent_x-center_x)*(tangent_x-center_x))+
|
||||
((tangent_y-center_y)*(tangent_y-center_y));
|
||||
Hide_empty_circle_preview(center_x,center_y,limit);
|
||||
|
||||
Paintbrush_shape=Paintbrush_shape_before_operation;
|
||||
|
||||
Draw_empty_circle_permanent(center_x,center_y,radius,color);
|
||||
Draw_empty_circle_permanent(center_x,center_y,limit,color);
|
||||
|
||||
End_of_modification();
|
||||
|
||||
@ -1094,7 +1091,7 @@ void Filled_circle_0_5(void)
|
||||
short center_x;
|
||||
short center_y;
|
||||
short color;
|
||||
short radius;
|
||||
long limit;
|
||||
|
||||
Operation_pop(&tangent_y);
|
||||
Operation_pop(&tangent_x);
|
||||
@ -1102,14 +1099,13 @@ void Filled_circle_0_5(void)
|
||||
Operation_pop(¢er_x);
|
||||
Operation_pop(&color);
|
||||
|
||||
Circle_limit=((tangent_x-center_x)*(tangent_x-center_x))+
|
||||
((tangent_y-center_y)*(tangent_y-center_y));
|
||||
radius=sqrt(Circle_limit);
|
||||
Hide_empty_circle_preview(center_x,center_y,radius);
|
||||
limit=((tangent_x-center_x)*(tangent_x-center_x))+
|
||||
((tangent_y-center_y)*(tangent_y-center_y));
|
||||
Hide_empty_circle_preview(center_x,center_y,limit);
|
||||
|
||||
Paintbrush_shape=Paintbrush_shape_before_operation;
|
||||
|
||||
Draw_filled_circle(center_x,center_y,radius,color);
|
||||
Draw_filled_circle(center_x,center_y,limit,color);
|
||||
|
||||
End_of_modification();
|
||||
if ( (Config.Coords_rel) && (Menu_is_visible) )
|
||||
@ -2983,7 +2979,7 @@ void Grad_circle_12_6(void)
|
||||
short center_x;
|
||||
short center_y;
|
||||
short color;
|
||||
short radius;
|
||||
long limit;
|
||||
char str[5];
|
||||
|
||||
Operation_pop(&tangent_y);
|
||||
@ -3005,15 +3001,13 @@ void Grad_circle_12_6(void)
|
||||
else
|
||||
Print_coordinates();
|
||||
|
||||
Circle_limit=((tangent_x-center_x)*(tangent_x-center_x))+
|
||||
((tangent_y-center_y)*(tangent_y-center_y));
|
||||
radius=sqrt(Circle_limit);
|
||||
Hide_empty_circle_preview(center_x,center_y,radius);
|
||||
limit=((tangent_x-center_x)*(tangent_x-center_x))+
|
||||
((tangent_y-center_y)*(tangent_y-center_y));
|
||||
Hide_empty_circle_preview(center_x,center_y,limit);
|
||||
|
||||
Circle_limit=((Paintbrush_X-center_x)*(Paintbrush_X-center_x))+
|
||||
limit=((Paintbrush_X-center_x)*(Paintbrush_X-center_x))+
|
||||
((Paintbrush_Y-center_y)*(Paintbrush_Y-center_y));
|
||||
radius=sqrt(Circle_limit);
|
||||
Draw_empty_circle_preview(center_x,center_y,radius,color);
|
||||
Draw_empty_circle_preview(center_x,center_y,limit,color);
|
||||
|
||||
Display_cursor();
|
||||
}
|
||||
@ -3041,7 +3035,6 @@ void Grad_circle_0_6(void)
|
||||
short center_y;
|
||||
short color;
|
||||
short click;
|
||||
short radius;
|
||||
|
||||
Operation_pop(&tangent_y);
|
||||
Operation_pop(&tangent_x);
|
||||
@ -3081,15 +3074,15 @@ void Grad_circle_0_6(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
Circle_limit=((tangent_x-center_x)*(tangent_x-center_x))+
|
||||
((tangent_y-center_y)*(tangent_y-center_y));
|
||||
radius=sqrt(Circle_limit);
|
||||
Hide_empty_circle_preview(center_x,center_y,radius);
|
||||
long limit;
|
||||
limit=((tangent_x-center_x)*(tangent_x-center_x))+
|
||||
((tangent_y-center_y)*(tangent_y-center_y));
|
||||
Hide_empty_circle_preview(center_x,center_y,limit);
|
||||
|
||||
Paintbrush_hidden=Paintbrush_hidden_before_scroll;
|
||||
Cursor_shape=CURSOR_SHAPE_TARGET;
|
||||
|
||||
Draw_filled_circle(center_x,center_y,radius,Back_color);
|
||||
Draw_filled_circle(center_x,center_y,limit,Back_color);
|
||||
|
||||
End_of_modification();
|
||||
if ((Config.Coords_rel) && (Menu_is_visible))
|
||||
@ -3116,8 +3109,7 @@ void Grad_circle_12_8(void)
|
||||
short center_y;
|
||||
short color;
|
||||
short old_mouse_k;
|
||||
|
||||
short radius;
|
||||
long limit;
|
||||
|
||||
Operation_stack_size-=2; // On fait sauter les 2 derniers élts de la pile
|
||||
Operation_pop(&tangent_y);
|
||||
@ -3131,16 +3123,15 @@ void Grad_circle_12_8(void)
|
||||
// On efface la croix XOR au centre du cercle
|
||||
Draw_curve_cross(center_x,center_y);
|
||||
|
||||
Circle_limit=((tangent_x-center_x)*(tangent_x-center_x))+
|
||||
((tangent_y-center_y)*(tangent_y-center_y));
|
||||
radius=sqrt(Circle_limit);
|
||||
Hide_empty_circle_preview(center_x,center_y,radius);
|
||||
limit=((tangent_x-center_x)*(tangent_x-center_x))+
|
||||
((tangent_y-center_y)*(tangent_y-center_y));
|
||||
Hide_empty_circle_preview(center_x,center_y,limit);
|
||||
|
||||
Paintbrush_hidden=Paintbrush_hidden_before_scroll;
|
||||
Cursor_shape=CURSOR_SHAPE_TARGET;
|
||||
|
||||
if (Mouse_K==old_mouse_k)
|
||||
Draw_grad_circle(center_x,center_y,radius,Paintbrush_X,Paintbrush_Y);
|
||||
Draw_grad_circle(center_x,center_y,limit,Paintbrush_X,Paintbrush_Y);
|
||||
Cursor_shape=CURSOR_SHAPE_XOR_TARGET;
|
||||
|
||||
Display_cursor();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user