/* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2
of the License.
Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Grafx2; if not, see or
write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include
#include
#include "const.h"
#include "struct.h"
#include "global.h"
#include "graph.h"
#include "moteur.h"
#include "windows.h"
//---------------------- Modifier le pinceau spécial -------------------------
void Set_paintbrush_size(int width, int height)
{
int x_pos,y_pos;
int x,y;
float radius2;
if (width<1) width=1;
if (height<1) height=1;
if (width>MAX_PAINTBRUSH_SIZE) width=MAX_PAINTBRUSH_SIZE;
if (height>MAX_PAINTBRUSH_SIZE) height=MAX_PAINTBRUSH_SIZE;
Paintbrush_width=width;
Paintbrush_height=height;
Paintbrush_offset_X=Paintbrush_width>>1;
Paintbrush_offset_Y=Paintbrush_height>>1;
switch (Paintbrush_shape)
{
case PAINTBRUSH_SHAPE_ROUND :
radius2=Paintbrush_offset_X+0.414213562; // [0.410..0.415[
radius2*=radius2;
for (y_pos=0; y_pos>1;
for (y_pos=0; y_pos>1;
for (y_pos=0; y_pos>1;
for (y_pos=0; y_pos>1;
for (y_pos=0; y_pos>1;
for (y_pos=0; y_pos1)
|| (Paintbrush_height>1) ) )
{
Hide_cursor();
switch (Paintbrush_shape)
{
case PAINTBRUSH_SHAPE_ROUND:
case PAINTBRUSH_SHAPE_SIEVE_ROUND:
case PAINTBRUSH_SHAPE_CROSS:
case PAINTBRUSH_SHAPE_PLUS:
case PAINTBRUSH_SHAPE_DIAMOND:
case PAINTBRUSH_SHAPE_RANDOM:
if (Paintbrush_width&1)
Set_paintbrush_size(Paintbrush_width-2,Paintbrush_height-2);
else
Set_paintbrush_size(Paintbrush_width-1,Paintbrush_height-1);
break;
case PAINTBRUSH_SHAPE_SQUARE:
case PAINTBRUSH_SHAPE_SLASH:
case PAINTBRUSH_SHAPE_ANTISLASH:
case PAINTBRUSH_SHAPE_SIEVE_SQUARE:
Set_paintbrush_size(Paintbrush_width-1,Paintbrush_height-1);
break;
case PAINTBRUSH_SHAPE_HORIZONTAL_BAR:
Set_paintbrush_size(Paintbrush_width-1,1);
break;
case PAINTBRUSH_SHAPE_VERTICAL_BAR:
Set_paintbrush_size(1,Paintbrush_height-1);
}
Display_paintbrush_in_menu();
Display_cursor();
}
}
void Bigger_paintbrush(void)
{
if ( (Paintbrush_shapeMain_image_width)
temp_x_offset=Main_image_width-Screen_width;
if (temp_y_offset+Menu_Y>Main_image_height)
temp_y_offset=Main_image_height-Menu_Y;
if (temp_x_offset<0)
temp_x_offset=0;
if (temp_y_offset<0)
temp_y_offset=0;
if ( (Main_offset_X!=temp_x_offset) ||
(Main_offset_Y!=temp_y_offset) )
{
Hide_cursor();
Main_offset_X=temp_x_offset;
Main_offset_Y=temp_y_offset;
Compute_limits();
Compute_paintbrush_coordinates();
Display_all_screen(); // <=> Display_screen + Display_image_limits
Display_cursor();
}
}
// ---------------------- Scroller la fenêtre de la loupe --------------------
void Scroll_magnifier(short delta_x,short delta_y)
{
short temp_x_offset;
short temp_y_offset;
temp_x_offset=Main_magnifier_offset_X+delta_x;
temp_y_offset=Main_magnifier_offset_Y+delta_y;
if (temp_x_offset+Main_magnifier_width>Main_image_width)
temp_x_offset=Main_image_width-Main_magnifier_width;
if (temp_y_offset+Main_magnifier_height>Main_image_height)
temp_y_offset=Main_image_height-Main_magnifier_height;
if (temp_x_offset<0)
temp_x_offset=0;
if (temp_y_offset<0)
temp_y_offset=0;
if ( (Main_magnifier_offset_X!=temp_x_offset) ||
(Main_magnifier_offset_Y!=temp_y_offset) )
{
Hide_cursor();
Main_magnifier_offset_X=temp_x_offset;
Main_magnifier_offset_Y=temp_y_offset;
Position_screen_according_to_zoom();
Compute_limits();
Compute_paintbrush_coordinates();
Display_all_screen();
Display_cursor();
}
}
// -------------- Changer le Zoom (grâce aux touches [+] et [-]) -------------
void Zoom(short delta)
{
short index;
for (index=0; ZOOM_FACTOR[index]!=Main_magnifier_factor; index++);
index+=delta;
if ( (index>=0) && (index