1997-11-25 06:05:25 +08:00
/* The GIMP -- an image manipulation program
* Copyright ( C ) 1995 Spencer Kimball and Peter Mattis
*
* This program 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 ; either version 2 of the License , or
* ( at your option ) any later version .
*
* This program 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 this program ; if not , write to the Free Software
1998-04-13 13:44:11 +08:00
* Foundation , Inc . , 59 Temple Place - Suite 330 , Boston , MA 02111 - 1307 , USA .
1997-11-25 06:05:25 +08:00
*/
# include <stdlib.h>
1998-12-16 19:23:30 +08:00
# include <stdio.h>
1997-11-25 06:05:25 +08:00
# include <math.h>
# include "appenv.h"
1998-07-09 13:31:06 +08:00
# include "gimpbrushlist.h"
1997-11-25 06:05:25 +08:00
# include "drawable.h"
# include "errors.h"
# include "gdisplay.h"
1999-03-17 13:40:16 +08:00
# include "gradient.h"
1997-11-25 06:05:25 +08:00
# include "paint_funcs.h"
# include "paint_core.h"
# include "palette.h"
# include "paintbrush.h"
# include "selection.h"
1999-04-13 01:55:06 +08:00
# include "tool_options_ui.h"
1997-11-25 06:05:25 +08:00
# include "tools.h"
1998-12-16 08:37:09 +08:00
# include "libgimp/gimpintl.h"
1997-11-25 06:05:25 +08:00
/* defines */
# define PAINT_LEFT_THRESHOLD 0.05
1999-04-09 06:25:54 +08:00
/* the paintbrush structures */
1997-11-25 06:05:25 +08:00
typedef struct _PaintOptions PaintOptions ;
struct _PaintOptions
{
1999-04-13 01:55:06 +08:00
ToolOptions tool_options ;
1999-04-09 06:25:54 +08:00
1999-04-13 01:55:06 +08:00
double fade_out ;
double fade_out_d ;
GtkObject * fade_out_w ;
1999-04-09 06:25:54 +08:00
1999-04-13 01:55:06 +08:00
int use_gradient ;
int use_gradient_d ;
GtkWidget * use_gradient_w ;
1999-04-09 06:25:54 +08:00
1999-04-13 01:55:06 +08:00
double gradient_length ;
double gradient_length_d ;
GtkObject * gradient_length_w ;
int gradient_type ;
int gradient_type_d ;
1999-04-18 07:18:43 +08:00
GtkWidget * gradient_type_w [ 4 ] ; /* 4 radio buttons */
1999-04-13 01:55:06 +08:00
gboolean incremental ;
gboolean incremental_d ;
GtkWidget * incremental_w ;
1997-11-25 06:05:25 +08:00
} ;
1999-04-13 01:55:06 +08:00
/* the paint brush tool options */
static PaintOptions * paintbrush_options = NULL ;
1997-11-25 06:05:25 +08:00
1999-04-09 06:25:54 +08:00
/* local variables */
static double non_gui_fade_out ;
static double non_gui_gradient_length ;
static int non_gui_gradient_type ;
static double non_gui_incremental ;
/* forward function declarations */
static void paintbrush_motion ( PaintCore * , GimpDrawable * , double , double , gboolean , int ) ;
static Argument * paintbrush_invoker ( Argument * ) ;
static Argument * paintbrush_extended_invoker ( Argument * ) ;
static Argument * paintbrush_extended_gradient_invoker ( Argument * ) ;
/* functions */
1997-11-25 06:05:25 +08:00
1998-03-01 09:18:45 +08:00
static void
1999-04-13 01:55:06 +08:00
paintbrush_gradient_toggle_callback ( GtkWidget * widget ,
gpointer data )
1998-03-01 09:18:45 +08:00
{
1999-04-13 01:55:06 +08:00
PaintOptions * options = paintbrush_options ;
1998-03-01 09:18:45 +08:00
1999-04-13 01:55:06 +08:00
static int incremental_save = FALSE ;
1998-03-01 09:18:45 +08:00
1999-04-13 01:55:06 +08:00
tool_options_toggle_update ( widget , data ) ;
1998-03-01 09:18:45 +08:00
1999-04-13 01:55:06 +08:00
if ( paintbrush_options - > use_gradient )
{
incremental_save = options - > incremental ;
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( options - > incremental_w ) ,
TRUE ) ;
}
1999-03-28 13:27:34 +08:00
else
1999-04-09 06:25:54 +08:00
{
1999-04-13 01:55:06 +08:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( options - > incremental_w ) ,
incremental_save ) ;
1999-04-09 06:25:54 +08:00
}
1997-11-25 06:05:25 +08:00
}
1999-03-22 12:10:58 +08:00
static void
1999-04-13 01:55:06 +08:00
paintbrush_gradient_type_callback ( GtkWidget * widget ,
gpointer data )
1999-03-22 12:10:58 +08:00
{
1999-04-13 01:55:06 +08:00
if ( paintbrush_options )
paintbrush_options - > gradient_type = ( int ) data ;
1999-03-28 13:27:34 +08:00
}
1999-04-09 06:25:54 +08:00
static void
1999-04-13 01:55:06 +08:00
paintbrush_options_reset ( void )
1999-04-09 06:25:54 +08:00
{
1999-04-13 01:55:06 +08:00
PaintOptions * options = paintbrush_options ;
1999-04-09 06:25:54 +08:00
gtk_adjustment_set_value ( GTK_ADJUSTMENT ( options - > fade_out_w ) ,
options - > fade_out_d ) ;
1999-04-13 01:55:06 +08:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( options - > use_gradient_w ) ,
options - > use_gradient_d ) ;
1999-04-09 06:25:54 +08:00
gtk_adjustment_set_value ( GTK_ADJUSTMENT ( options - > gradient_length_w ) ,
options - > gradient_length_d ) ;
1999-04-18 07:18:43 +08:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( options - > gradient_type_w [ options - > gradient_type_d ] ) ,
1999-04-09 06:25:54 +08:00
TRUE ) ;
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( options - > incremental_w ) ,
options - > incremental_d ) ;
}
1999-03-28 13:27:34 +08:00
1997-11-25 06:05:25 +08:00
static PaintOptions *
1999-04-13 01:55:06 +08:00
paintbrush_options_new ( void )
1997-11-25 06:05:25 +08:00
{
PaintOptions * options ;
1999-04-13 01:55:06 +08:00
1997-11-25 06:05:25 +08:00
GtkWidget * vbox ;
1999-04-09 06:25:54 +08:00
GtkWidget * abox ;
GtkWidget * table ;
1997-11-25 06:05:25 +08:00
GtkWidget * label ;
1999-04-09 06:25:54 +08:00
GtkWidget * scale ;
GSList * group = NULL ;
1999-03-28 13:27:34 +08:00
GtkWidget * radio_frame ;
GtkWidget * radio_box ;
GtkWidget * radio_button ;
1999-04-13 01:55:06 +08:00
1999-03-28 13:27:34 +08:00
int i ;
char * gradient_types [ 4 ] =
{
N_ ( " Once Forward " ) ,
N_ ( " Once Backward " ) ,
N_ ( " Loop Sawtooth " ) ,
N_ ( " Loop Triangle " )
} ;
1999-03-19 08:42:27 +08:00
1999-04-13 01:55:06 +08:00
/* the new paint tool options structure */
1997-11-25 06:05:25 +08:00
options = ( PaintOptions * ) g_malloc ( sizeof ( PaintOptions ) ) ;
1999-04-13 01:55:06 +08:00
tool_options_init ( ( ToolOptions * ) options ,
_ ( " Paintbrush Options " ) ,
paintbrush_options_reset ) ;
1999-04-09 06:25:54 +08:00
options - > fade_out = options - > fade_out_d = 0.0 ;
options - > incremental = options - > incremental_d = FALSE ;
1999-04-13 01:55:06 +08:00
options - > use_gradient = options - > use_gradient_d = FALSE ;
options - > gradient_length = options - > gradient_length_d = 10.0 ;
1999-04-09 06:25:54 +08:00
options - > gradient_type = options - > gradient_type_d = 3 ;
1999-03-17 13:40:16 +08:00
1997-11-25 06:05:25 +08:00
/* the main vbox */
1999-04-13 01:55:06 +08:00
vbox = options - > tool_options . main_vbox ;
1997-11-25 06:05:25 +08:00
/* the fade-out scale */
1999-04-09 06:25:54 +08:00
table = gtk_table_new ( 4 , 2 , FALSE ) ;
gtk_table_set_col_spacing ( GTK_TABLE ( table ) , 0 , 6 ) ;
gtk_table_set_row_spacing ( GTK_TABLE ( table ) , 0 , 2 ) ;
gtk_table_set_row_spacing ( GTK_TABLE ( table ) , 2 , 3 ) ;
gtk_box_pack_start ( GTK_BOX ( vbox ) , table , FALSE , FALSE , 0 ) ;
label = gtk_label_new ( _ ( " Fade Out: " ) ) ;
gtk_misc_set_alignment ( GTK_MISC ( label ) , 1.0 , 1.0 ) ;
gtk_table_attach ( GTK_TABLE ( table ) , label , 0 , 1 , 0 , 1 ,
GTK_SHRINK | GTK_FILL , GTK_SHRINK | GTK_FILL , 0 , 0 ) ;
1997-11-25 06:05:25 +08:00
gtk_widget_show ( label ) ;
1999-04-09 06:25:54 +08:00
options - > fade_out_w =
gtk_adjustment_new ( options - > fade_out_d , 0.0 , 1000.0 , 1.0 , 1.0 , 0.0 ) ;
scale = gtk_hscale_new ( GTK_ADJUSTMENT ( options - > fade_out_w ) ) ;
gtk_table_attach_defaults ( GTK_TABLE ( table ) , scale , 1 , 2 , 0 , 1 ) ;
gtk_scale_set_value_pos ( GTK_SCALE ( scale ) , GTK_POS_TOP ) ;
gtk_range_set_update_policy ( GTK_RANGE ( scale ) , GTK_UPDATE_DELAYED ) ;
gtk_signal_connect ( GTK_OBJECT ( options - > fade_out_w ) , " value_changed " ,
1999-04-13 01:55:06 +08:00
( GtkSignalFunc ) tool_options_double_adjustment_update ,
1999-04-13 02:09:55 +08:00
& options - > fade_out ) ;
1999-04-09 06:25:54 +08:00
gtk_widget_show ( scale ) ;
1997-11-25 06:05:25 +08:00
1999-04-13 01:55:06 +08:00
/* the use gradient toggle */
options - > use_gradient_w =
gtk_check_button_new_with_label ( _ ( " Gradient " ) ) ;
gtk_table_attach ( GTK_TABLE ( table ) , options - > use_gradient_w , 0 , 1 , 1 , 2 ,
1999-04-09 06:25:54 +08:00
GTK_SHRINK | GTK_FILL , GTK_SHRINK , 0 , 0 ) ;
1999-04-13 01:55:06 +08:00
gtk_signal_connect ( GTK_OBJECT ( options - > use_gradient_w ) , " toggled " ,
( GtkSignalFunc ) paintbrush_gradient_toggle_callback ,
& options - > use_gradient ) ;
gtk_widget_show ( options - > use_gradient_w ) ;
1999-03-17 13:40:16 +08:00
1999-04-09 06:25:54 +08:00
label = gtk_label_new ( _ ( " Length: " ) ) ;
gtk_misc_set_alignment ( GTK_MISC ( label ) , 1.0 , 1.0 ) ;
gtk_table_attach ( GTK_TABLE ( table ) , label , 0 , 1 , 2 , 3 ,
1999-04-13 01:55:06 +08:00
GTK_SHRINK | GTK_FILL , GTK_SHRINK | GTK_FILL , 0 , 0 ) ;
1999-03-17 13:40:16 +08:00
gtk_widget_show ( label ) ;
1999-04-13 01:55:06 +08:00
/* the gradient length scale */
1999-04-09 06:25:54 +08:00
abox = gtk_alignment_new ( 0.5 , 1.0 , 1.0 , 0.0 ) ;
gtk_table_attach ( GTK_TABLE ( table ) , abox , 1 , 2 , 1 , 3 ,
GTK_EXPAND | GTK_FILL , GTK_SHRINK | GTK_FILL , 0 , 0 ) ;
gtk_widget_show ( abox ) ;
options - > gradient_length_w =
1999-04-13 01:55:06 +08:00
gtk_adjustment_new ( options - > gradient_length_d , 1.0 , 50.0 , 1.1 , 0.1 , 0.0 ) ;
1999-04-09 06:25:54 +08:00
scale = gtk_hscale_new ( GTK_ADJUSTMENT ( options - > gradient_length_w ) ) ;
gtk_container_add ( GTK_CONTAINER ( abox ) , scale ) ;
gtk_scale_set_value_pos ( GTK_SCALE ( scale ) , GTK_POS_TOP ) ;
gtk_range_set_update_policy ( GTK_RANGE ( scale ) , GTK_UPDATE_DELAYED ) ;
gtk_signal_connect ( GTK_OBJECT ( options - > gradient_length_w ) , " value_changed " ,
1999-04-13 01:55:06 +08:00
( GtkSignalFunc ) tool_options_double_adjustment_update ,
& options - > gradient_length ) ;
1999-04-09 06:25:54 +08:00
gtk_widget_show ( scale ) ;
gtk_widget_show ( table ) ;
1998-03-01 09:18:45 +08:00
1999-03-28 13:27:34 +08:00
/* the radio frame and box */
radio_frame = gtk_frame_new ( _ ( " Gradient Type " ) ) ;
1999-04-09 06:25:54 +08:00
gtk_table_attach_defaults ( GTK_TABLE ( table ) , radio_frame , 0 , 2 , 3 , 4 ) ;
1999-03-28 13:27:34 +08:00
radio_box = gtk_vbox_new ( FALSE , 1 ) ;
1999-04-09 06:25:54 +08:00
gtk_container_set_border_width ( GTK_CONTAINER ( radio_box ) , 2 ) ;
1999-03-28 13:27:34 +08:00
gtk_container_add ( GTK_CONTAINER ( radio_frame ) , radio_box ) ;
/* the radio buttons */
group = NULL ;
for ( i = 0 ; i < 4 ; i + + )
{
radio_button = gtk_radio_button_new_with_label ( group , gradient_types [ i ] ) ;
group = gtk_radio_button_group ( GTK_RADIO_BUTTON ( radio_button ) ) ;
gtk_signal_connect ( GTK_OBJECT ( radio_button ) , " toggled " ,
( GtkSignalFunc ) paintbrush_gradient_type_callback ,
( void * ) ( ( long ) i ) ) ;
gtk_box_pack_start ( GTK_BOX ( radio_box ) , radio_button , FALSE , FALSE , 0 ) ;
gtk_widget_show ( radio_button ) ;
1999-04-18 07:18:43 +08:00
options - > gradient_type_w [ i ] = radio_button ;
1999-03-28 13:27:34 +08:00
}
1999-04-18 07:18:43 +08:00
1999-03-28 13:27:34 +08:00
gtk_widget_show ( radio_box ) ;
gtk_widget_show ( radio_frame ) ;
1998-03-01 09:18:45 +08:00
/* the incremental toggle */
1999-04-09 06:25:54 +08:00
options - > incremental_w = gtk_check_button_new_with_label ( _ ( " Incremental " ) ) ;
gtk_box_pack_start ( GTK_BOX ( vbox ) , options - > incremental_w , FALSE , FALSE , 0 ) ;
gtk_signal_connect ( GTK_OBJECT ( options - > incremental_w ) , " toggled " ,
1999-04-13 01:55:06 +08:00
( GtkSignalFunc ) tool_options_toggle_update ,
1998-03-01 09:18:45 +08:00
& options - > incremental ) ;
1999-04-09 06:25:54 +08:00
gtk_widget_show ( options - > incremental_w ) ;
1998-03-01 09:18:45 +08:00
1999-04-19 02:55:49 +08:00
/* automatically set the sensitive state of the gradient stuff */
gtk_widget_set_sensitive ( scale , options - > use_gradient_d ) ;
gtk_widget_set_sensitive ( label , options - > use_gradient_d ) ;
gtk_widget_set_sensitive ( radio_frame , options - > use_gradient_d ) ;
gtk_widget_set_sensitive ( options - > incremental_w , ! options - > use_gradient_d ) ;
gtk_object_set_data ( GTK_OBJECT ( options - > use_gradient_w ) , " set_sensitive " ,
scale ) ;
gtk_object_set_data ( GTK_OBJECT ( scale ) , " set_sensitive " ,
label ) ;
gtk_object_set_data ( GTK_OBJECT ( label ) , " set_sensitive " ,
radio_frame ) ;
gtk_object_set_data ( GTK_OBJECT ( options - > use_gradient_w ) , " inverse_sensitive " ,
options - > incremental_w ) ;
1997-11-25 06:05:25 +08:00
return options ;
}
1999-03-19 08:42:27 +08:00
1998-12-16 19:23:30 +08:00
# define USE_SPEEDSHOP_CALIPERS 0
# define TIMED_BRUSH 0
# if USE_SPEEDSHOP_CALIPERS
# include <SpeedShop/api.h>
# endif
1997-11-25 06:05:25 +08:00
void *
paintbrush_paint_func ( PaintCore * paint_core ,
1998-01-22 15:02:57 +08:00
GimpDrawable * drawable ,
1997-11-25 06:05:25 +08:00
int state )
{
1998-12-16 19:23:30 +08:00
# if TIMED_BRUSH
static GTimer * timer ;
# endif
1997-11-25 06:05:25 +08:00
switch ( state )
{
case INIT_PAINT :
1998-12-16 19:23:30 +08:00
# if TIMED_BRUSH
timer = g_timer_new ( ) ;
g_timer_start ( timer ) ;
# if USE_SPEEDSHOP_CALIPERS
ssrt_caliper_point ( 0 , " Painting " ) ;
# endif /* USE_SPEEDSHOP_CALIPERS */
# endif /* TIMED_BRUSH */
1997-11-25 06:05:25 +08:00
break ;
case MOTION_PAINT :
1999-03-17 13:40:16 +08:00
paintbrush_motion ( paint_core , drawable ,
1999-04-13 01:55:06 +08:00
paintbrush_options - > fade_out ,
paintbrush_options - > use_gradient ?
exp ( paintbrush_options - > gradient_length / 10 ) : 0 ,
paintbrush_options - > incremental ,
paintbrush_options - > gradient_type ) ;
1997-11-25 06:05:25 +08:00
break ;
case FINISH_PAINT :
1998-12-16 19:23:30 +08:00
# if TIMED_BRUSH
# if USE_SPEEDSHOP_CALIPERS
ssrt_caliper_point ( 0 , " Not Painting Anymore " ) ;
# endif /* USE_SPEEDSHOP_CALIPERS */
g_timer_stop ( timer ) ;
printf ( " painting took %f: \n " , g_timer_elapsed ( timer , NULL ) ) ;
g_timer_destroy ( timer ) ;
# endif /* TIMED_BRUSH */
1997-11-25 06:05:25 +08:00
break ;
default :
break ;
}
return NULL ;
}
Tool *
tools_new_paintbrush ( )
{
Tool * tool ;
PaintCore * private ;
1999-04-13 01:55:06 +08:00
/* The tool options */
if ( ! paintbrush_options )
{
paintbrush_options = paintbrush_options_new ( ) ;
tools_register ( PAINTBRUSH , ( ToolOptions * ) paintbrush_options ) ;
1999-04-18 07:18:43 +08:00
/* press all default buttons */
paintbrush_options_reset ( ) ;
1999-04-13 01:55:06 +08:00
}
1997-11-25 06:05:25 +08:00
tool = paint_core_new ( PAINTBRUSH ) ;
private = ( PaintCore * ) tool - > private ;
private - > paint_func = paintbrush_paint_func ;
return tool ;
}
void
tools_free_paintbrush ( Tool * tool )
{
paint_core_free ( tool ) ;
}
1998-03-19 06:35:31 +08:00
static void
1997-11-25 06:05:25 +08:00
paintbrush_motion ( PaintCore * paint_core ,
1998-01-22 15:02:57 +08:00
GimpDrawable * drawable ,
1998-03-01 09:18:45 +08:00
double fade_out ,
1999-03-17 13:40:16 +08:00
double gradient_length ,
1999-03-28 13:27:34 +08:00
gboolean incremental ,
int gradient_type )
1997-11-25 06:05:25 +08:00
{
GImage * gimage ;
TempBuf * area ;
double x , paint_left ;
1999-03-19 08:42:27 +08:00
double position ;
unsigned char local_blend = OPAQUE_OPACITY ;
1999-03-17 13:40:16 +08:00
unsigned char temp_blend = OPAQUE_OPACITY ;
1997-11-25 06:05:25 +08:00
unsigned char col [ MAX_CHANNELS ] ;
1999-03-17 13:40:16 +08:00
double r , g , b , a ;
1999-03-19 08:42:27 +08:00
int mode ;
1997-11-25 06:05:25 +08:00
1999-03-17 13:40:16 +08:00
position = 0.0 ;
1998-01-22 15:02:57 +08:00
if ( ! ( gimage = drawable_gimage ( drawable ) ) )
1997-11-25 06:05:25 +08:00
return ;
1998-01-22 15:02:57 +08:00
gimage_get_foreground ( gimage , drawable , col ) ;
1997-11-25 06:05:25 +08:00
1999-03-19 08:42:27 +08:00
/* Get a region which can be used to p\\aint to */
1998-01-22 15:02:57 +08:00
if ( ! ( area = paint_core_get_paint_area ( paint_core , drawable ) ) )
1997-11-25 06:05:25 +08:00
return ;
/* factor in the fade out value */
if ( fade_out )
{
/* Model the amount of paint left as a gaussian curve */
x = ( ( double ) paint_core - > distance / fade_out ) ;
paint_left = exp ( - x * x * 0.5 ) ;
1999-03-19 08:42:27 +08:00
local_blend = ( int ) ( 255 * paint_left ) ;
1999-03-17 13:40:16 +08:00
}
1999-03-19 08:42:27 +08:00
if ( local_blend )
1997-11-25 06:05:25 +08:00
{
/* set the alpha channel */
1998-01-25 09:24:46 +08:00
col [ area - > bytes - 1 ] = OPAQUE_OPACITY ;
1999-03-19 08:42:27 +08:00
temp_blend = local_blend ;
1999-03-17 13:40:16 +08:00
1999-03-19 08:42:27 +08:00
/* hard core to mode LOOP_TRIANGLE */
/* need to maek a gui to handle this */
1999-03-28 13:27:34 +08:00
mode = gradient_type ;
1999-03-19 08:42:27 +08:00
if ( gradient_length )
1999-03-17 13:40:16 +08:00
{
1999-03-19 08:42:27 +08:00
paint_core_get_color_from_gradient ( paint_core , gradient_length , & r , & g , & b , & a , mode ) ;
1999-03-17 13:40:16 +08:00
r = r * 255.0 ;
g = g * 255.0 ;
b = b * 255.0 ;
a = a * 255.0 ;
1999-03-19 08:42:27 +08:00
temp_blend = ( gint ) ( ( a * local_blend ) / 255 ) ;
1999-03-17 13:40:16 +08:00
col [ 0 ] = ( gint ) r ;
col [ 1 ] = ( gint ) g ;
col [ 2 ] = ( gint ) b ;
1999-03-19 08:42:27 +08:00
/* always use incremental mode with gradients */
/* make the gui cool later */
incremental = INCREMENTAL ;
1999-03-17 13:40:16 +08:00
}
1999-03-19 08:42:27 +08:00
/* just leave this because I know as soon as i delete it i'll find a bug */
/* printf("temp_blend: %u grad_len: %f distance: %f \n",temp_blend, gradient_length, distance); */
1999-03-17 13:40:16 +08:00
1997-11-25 06:05:25 +08:00
/* color the pixels */
color_pixels ( temp_buf_data ( area ) , col ,
area - > width * area - > height , area - > bytes ) ;
/* paste the newly painted canvas to the gimage which is being worked on */
1999-03-17 13:40:16 +08:00
paint_core_paste_canvas ( paint_core , drawable , temp_blend ,
1998-07-09 13:31:06 +08:00
( int ) ( gimp_brush_get_opacity ( ) * 255 ) ,
gimp_brush_get_paint_mode ( ) , PRESSURE ,
1998-03-01 09:18:45 +08:00
incremental ? INCREMENTAL : CONSTANT ) ;
1997-11-25 06:05:25 +08:00
}
}
static void *
paintbrush_non_gui_paint_func ( PaintCore * paint_core ,
1998-01-22 15:02:57 +08:00
GimpDrawable * drawable ,
1997-11-25 06:05:25 +08:00
int state )
1998-03-01 09:18:45 +08:00
{
1999-04-09 06:25:54 +08:00
paintbrush_motion ( paint_core , drawable , non_gui_fade_out , non_gui_gradient_length , non_gui_incremental , non_gui_gradient_type ) ;
1997-11-25 06:05:25 +08:00
return NULL ;
}
/* The paintbrush procedure definition */
ProcArg paintbrush_args [ ] =
{
{ PDB_DRAWABLE ,
" drawable " ,
" the drawable "
} ,
{ PDB_FLOAT ,
" fade_out " ,
" fade out parameter: fade_out > 0 "
} ,
{ PDB_INT32 ,
" num_strokes " ,
" number of stroke control points (count each coordinate as 2 points) "
} ,
{ PDB_FLOATARRAY ,
" strokes " ,
" array of stroke coordinates: {s1.x, s1.y, s2.x, s2.y, ..., sn.x, sn.y} "
}
} ;
1998-03-01 09:18:45 +08:00
ProcArg paintbrush_extended_args [ ] =
{
{ PDB_DRAWABLE ,
" drawable " ,
" the drawable "
} ,
{ PDB_FLOAT ,
" fade_out " ,
" fade out parameter: fade_out > 0 "
} ,
{ PDB_INT32 ,
" num_strokes " ,
" number of stroke control points (count each coordinate as 2 points) "
} ,
{ PDB_FLOATARRAY ,
" strokes " ,
" array of stroke coordinates: {s1.x, s1.y, s2.x, s2.y, ..., sn.x, sn.y} "
} ,
{ PDB_INT32 ,
" method " ,
" CONTINUOUS(0) or INCREMENTAL(1) "
}
} ;
1999-03-17 13:40:16 +08:00
ProcArg paintbrush_extended_gradient_args [ ] =
{
{ PDB_DRAWABLE ,
" drawable " ,
" the drawable "
} ,
{ PDB_FLOAT ,
" fade_out " ,
" fade out parameter: fade_out > 0 "
} ,
{ PDB_FLOAT ,
" gradient_length " ,
" Length of gradient to draw: gradient_lengtth >0 "
} ,
{ PDB_INT32 ,
" num_strokes " ,
" number of stroke control points (count each coordinate as 2 points) "
} ,
{ PDB_FLOATARRAY ,
" strokes " ,
" array of stroke coordinates: {s1.x, s1.y, s2.x, s2.y, ..., sn.x, sn.y} "
} ,
{ PDB_INT32 ,
" method " ,
" CONTINUOUS(0) or INCREMENTAL(1) "
}
} ;
1997-11-25 06:05:25 +08:00
ProcRecord paintbrush_proc =
{
" gimp_paintbrush " ,
" Paint in the current brush with optional fade out parameter " ,
" This tool is the standard paintbrush. It draws linearly interpolated lines through the specified stroke coordinates. It operates on the specified drawable in the foreground color with the active brush. The \" fade_out \" parameter is measured in pixels and allows the brush stroke to linearly fall off. The pressure is set to the maximum at the beginning of the stroke. As the distance of the stroke nears the fade_out value, the pressure will approach zero. " ,
" Spencer Kimball & Peter Mattis " ,
" Spencer Kimball & Peter Mattis " ,
" 1995-1996 " ,
PDB_INTERNAL ,
/* Input arguments */
API-mega-break-it-all patch part one: removed the unnecessary PDB_IMAGE
* airbrush.c, blend.c, brightness_contrast.c, bucket_fill.c
by_color_select.c, channel_ops.c, clone.c, color_balance.c
color_picker.c, convolve.c, curves.c, desaturate.c, edit_cmds.c
equalize.c, eraser.c, flip_tool.c, fuzzy_select.c,
gimage_mask_cmds.c histogram_tool.c, hue_saturation.c, invert.c,
levels.c, pencil.c paintbrush.c, perspective_tool.c, posterize.c,
rotate_tool.c scale_tool.c, shear_tool.c, text_tool.c, threshold.c:
API-mega-break-it-all patch part one: removed the unnecessary
PDB_IMAGE argument from many functions.
Affected functions:
gimp_airbrush gimp_blend gimp_brightness_contrast gimp_bucket_fill
gimp_by_color_select gimp_channel_ops_offset gimp_clone gimp_color_balance
gimp_color_picker gimp_convolve gimp_curves_explicit gimp_curves_spline
gimp_desaturate gimp_edit_clear gimp_edit_copy gimp_edit_cut gimp_edit_fill
gimp_edit_paste gimp_edit_stroke gimp_equalize gimp_eraser
gimp_eraser_extended gimp_flip gimp_fuzzy_select gimp_histogram
gimp_hue_saturation gimp_invert gimp_levels gimp_paintbrush
gimp_paintbrush_extended gimp_pencil gimp_perspective gimp_posterize
gimp_rotate gimp_scale gimp_selection_float gimp_selection_layer_alpha
gimp_selection_load gimp_shear gimp_threshold
1998-11-14 04:40:00 +08:00
4 ,
1997-11-25 06:05:25 +08:00
paintbrush_args ,
/* Output arguments */
0 ,
NULL ,
/* Exec method */
{ { paintbrush_invoker } } ,
} ;
1998-03-01 09:18:45 +08:00
ProcRecord paintbrush_extended_proc =
{
1998-03-01 14:06:19 +08:00
" gimp_paintbrush_extended " ,
1998-03-01 09:18:45 +08:00
" Paint in the current brush with optional fade out parameter " ,
" This tool is the standard paintbrush. It draws linearly interpolated lines through the specified stroke coordinates. It operates on the specified drawable in the foreground color with the active brush. The \" fade_out \" parameter is measured in pixels and allows the brush stroke to linearly fall off. The pressure is set to the maximum at the beginning of the stroke. As the distance of the stroke nears the fade_out value, the pressure will approach zero. " ,
" Spencer Kimball & Peter Mattis " ,
" Spencer Kimball & Peter Mattis " ,
" 1995-1996 " ,
PDB_INTERNAL ,
/* Input arguments */
API-mega-break-it-all patch part one: removed the unnecessary PDB_IMAGE
* airbrush.c, blend.c, brightness_contrast.c, bucket_fill.c
by_color_select.c, channel_ops.c, clone.c, color_balance.c
color_picker.c, convolve.c, curves.c, desaturate.c, edit_cmds.c
equalize.c, eraser.c, flip_tool.c, fuzzy_select.c,
gimage_mask_cmds.c histogram_tool.c, hue_saturation.c, invert.c,
levels.c, pencil.c paintbrush.c, perspective_tool.c, posterize.c,
rotate_tool.c scale_tool.c, shear_tool.c, text_tool.c, threshold.c:
API-mega-break-it-all patch part one: removed the unnecessary
PDB_IMAGE argument from many functions.
Affected functions:
gimp_airbrush gimp_blend gimp_brightness_contrast gimp_bucket_fill
gimp_by_color_select gimp_channel_ops_offset gimp_clone gimp_color_balance
gimp_color_picker gimp_convolve gimp_curves_explicit gimp_curves_spline
gimp_desaturate gimp_edit_clear gimp_edit_copy gimp_edit_cut gimp_edit_fill
gimp_edit_paste gimp_edit_stroke gimp_equalize gimp_eraser
gimp_eraser_extended gimp_flip gimp_fuzzy_select gimp_histogram
gimp_hue_saturation gimp_invert gimp_levels gimp_paintbrush
gimp_paintbrush_extended gimp_pencil gimp_perspective gimp_posterize
gimp_rotate gimp_scale gimp_selection_float gimp_selection_layer_alpha
gimp_selection_load gimp_shear gimp_threshold
1998-11-14 04:40:00 +08:00
5 ,
1998-03-01 09:18:45 +08:00
paintbrush_extended_args ,
/* Output arguments */
0 ,
NULL ,
/* Exec method */
{ { paintbrush_extended_invoker } } ,
} ;
1999-03-17 13:40:16 +08:00
ProcRecord paintbrush_extended_gradient_proc =
{
" gimp_paintbrush_extended_gradient " ,
" Paint in the current brush with optional fade out parameter and a pull colors from a gradient " ,
" This tool is the gradient paintbrush. It draws linearly interpolated lines through the specified stroke coordinates. It operates on the specified drawable with colors drawn from the current active gradient with the active brush. The \" fade_out \" parameter is measured in pixels and allows the brush stroke to linearly fall off. The pressure is set to the maximum at the beginning of the stroke. As the distance of the stroke nears the fade_out value, the pressure will approach zero. The gradient_length is the distance to spread the gradient over. It is measured in pixels. " ,
" Spencer Kimball & Peter Mattis " ,
" Spencer Kimball & Peter Mattis " ,
" 1995-1996 " ,
PDB_INTERNAL ,
/* Input arguments */
6 ,
paintbrush_extended_gradient_args ,
/* Output arguments */
0 ,
NULL ,
/* Exec method */
{ { paintbrush_extended_gradient_invoker } } ,
} ;
1997-11-25 06:05:25 +08:00
static Argument *
paintbrush_invoker ( Argument * args )
{
int success = TRUE ;
GImage * gimage ;
1998-01-22 15:02:57 +08:00
GimpDrawable * drawable ;
1997-11-25 06:05:25 +08:00
int num_strokes ;
double * stroke_array ;
int int_value ;
double fp_value ;
int i ;
1998-01-22 15:02:57 +08:00
drawable = NULL ;
1997-11-25 06:05:25 +08:00
num_strokes = 0 ;
/* the drawable */
if ( success )
{
API-mega-break-it-all patch part one: removed the unnecessary PDB_IMAGE
* airbrush.c, blend.c, brightness_contrast.c, bucket_fill.c
by_color_select.c, channel_ops.c, clone.c, color_balance.c
color_picker.c, convolve.c, curves.c, desaturate.c, edit_cmds.c
equalize.c, eraser.c, flip_tool.c, fuzzy_select.c,
gimage_mask_cmds.c histogram_tool.c, hue_saturation.c, invert.c,
levels.c, pencil.c paintbrush.c, perspective_tool.c, posterize.c,
rotate_tool.c scale_tool.c, shear_tool.c, text_tool.c, threshold.c:
API-mega-break-it-all patch part one: removed the unnecessary
PDB_IMAGE argument from many functions.
Affected functions:
gimp_airbrush gimp_blend gimp_brightness_contrast gimp_bucket_fill
gimp_by_color_select gimp_channel_ops_offset gimp_clone gimp_color_balance
gimp_color_picker gimp_convolve gimp_curves_explicit gimp_curves_spline
gimp_desaturate gimp_edit_clear gimp_edit_copy gimp_edit_cut gimp_edit_fill
gimp_edit_paste gimp_edit_stroke gimp_equalize gimp_eraser
gimp_eraser_extended gimp_flip gimp_fuzzy_select gimp_histogram
gimp_hue_saturation gimp_invert gimp_levels gimp_paintbrush
gimp_paintbrush_extended gimp_pencil gimp_perspective gimp_posterize
gimp_rotate gimp_scale gimp_selection_float gimp_selection_layer_alpha
gimp_selection_load gimp_shear gimp_threshold
1998-11-14 04:40:00 +08:00
int_value = args [ 0 ] . value . pdb_int ;
1998-01-22 15:02:57 +08:00
drawable = drawable_get_ID ( int_value ) ;
API-mega-break-it-all patch part one: removed the unnecessary PDB_IMAGE
* airbrush.c, blend.c, brightness_contrast.c, bucket_fill.c
by_color_select.c, channel_ops.c, clone.c, color_balance.c
color_picker.c, convolve.c, curves.c, desaturate.c, edit_cmds.c
equalize.c, eraser.c, flip_tool.c, fuzzy_select.c,
gimage_mask_cmds.c histogram_tool.c, hue_saturation.c, invert.c,
levels.c, pencil.c paintbrush.c, perspective_tool.c, posterize.c,
rotate_tool.c scale_tool.c, shear_tool.c, text_tool.c, threshold.c:
API-mega-break-it-all patch part one: removed the unnecessary
PDB_IMAGE argument from many functions.
Affected functions:
gimp_airbrush gimp_blend gimp_brightness_contrast gimp_bucket_fill
gimp_by_color_select gimp_channel_ops_offset gimp_clone gimp_color_balance
gimp_color_picker gimp_convolve gimp_curves_explicit gimp_curves_spline
gimp_desaturate gimp_edit_clear gimp_edit_copy gimp_edit_cut gimp_edit_fill
gimp_edit_paste gimp_edit_stroke gimp_equalize gimp_eraser
gimp_eraser_extended gimp_flip gimp_fuzzy_select gimp_histogram
gimp_hue_saturation gimp_invert gimp_levels gimp_paintbrush
gimp_paintbrush_extended gimp_pencil gimp_perspective gimp_posterize
gimp_rotate gimp_scale gimp_selection_float gimp_selection_layer_alpha
gimp_selection_load gimp_shear gimp_threshold
1998-11-14 04:40:00 +08:00
if ( drawable = = NULL )
success = FALSE ;
else
gimage = drawable_gimage ( drawable ) ;
1997-11-25 06:05:25 +08:00
}
/* fade out */
if ( success )
{
API-mega-break-it-all patch part one: removed the unnecessary PDB_IMAGE
* airbrush.c, blend.c, brightness_contrast.c, bucket_fill.c
by_color_select.c, channel_ops.c, clone.c, color_balance.c
color_picker.c, convolve.c, curves.c, desaturate.c, edit_cmds.c
equalize.c, eraser.c, flip_tool.c, fuzzy_select.c,
gimage_mask_cmds.c histogram_tool.c, hue_saturation.c, invert.c,
levels.c, pencil.c paintbrush.c, perspective_tool.c, posterize.c,
rotate_tool.c scale_tool.c, shear_tool.c, text_tool.c, threshold.c:
API-mega-break-it-all patch part one: removed the unnecessary
PDB_IMAGE argument from many functions.
Affected functions:
gimp_airbrush gimp_blend gimp_brightness_contrast gimp_bucket_fill
gimp_by_color_select gimp_channel_ops_offset gimp_clone gimp_color_balance
gimp_color_picker gimp_convolve gimp_curves_explicit gimp_curves_spline
gimp_desaturate gimp_edit_clear gimp_edit_copy gimp_edit_cut gimp_edit_fill
gimp_edit_paste gimp_edit_stroke gimp_equalize gimp_eraser
gimp_eraser_extended gimp_flip gimp_fuzzy_select gimp_histogram
gimp_hue_saturation gimp_invert gimp_levels gimp_paintbrush
gimp_paintbrush_extended gimp_pencil gimp_perspective gimp_posterize
gimp_rotate gimp_scale gimp_selection_float gimp_selection_layer_alpha
gimp_selection_load gimp_shear gimp_threshold
1998-11-14 04:40:00 +08:00
fp_value = args [ 1 ] . value . pdb_float ;
1997-11-25 06:05:25 +08:00
if ( fp_value > = 0.0 )
non_gui_fade_out = fp_value ;
else
success = FALSE ;
}
1999-03-17 13:40:16 +08:00
/* FIXME FIXME FIXME */
/* but we need to change the pdb call to gimp_paintbrush...ouch!! */
/* should this be enough to do this without breaking PDB? */
if ( success )
{
non_gui_gradient_length = 0.0 ;
1999-04-09 06:25:54 +08:00
non_gui_gradient_type = 0 ;
1999-03-17 13:40:16 +08:00
}
1997-11-25 06:05:25 +08:00
/* num strokes */
if ( success )
{
API-mega-break-it-all patch part one: removed the unnecessary PDB_IMAGE
* airbrush.c, blend.c, brightness_contrast.c, bucket_fill.c
by_color_select.c, channel_ops.c, clone.c, color_balance.c
color_picker.c, convolve.c, curves.c, desaturate.c, edit_cmds.c
equalize.c, eraser.c, flip_tool.c, fuzzy_select.c,
gimage_mask_cmds.c histogram_tool.c, hue_saturation.c, invert.c,
levels.c, pencil.c paintbrush.c, perspective_tool.c, posterize.c,
rotate_tool.c scale_tool.c, shear_tool.c, text_tool.c, threshold.c:
API-mega-break-it-all patch part one: removed the unnecessary
PDB_IMAGE argument from many functions.
Affected functions:
gimp_airbrush gimp_blend gimp_brightness_contrast gimp_bucket_fill
gimp_by_color_select gimp_channel_ops_offset gimp_clone gimp_color_balance
gimp_color_picker gimp_convolve gimp_curves_explicit gimp_curves_spline
gimp_desaturate gimp_edit_clear gimp_edit_copy gimp_edit_cut gimp_edit_fill
gimp_edit_paste gimp_edit_stroke gimp_equalize gimp_eraser
gimp_eraser_extended gimp_flip gimp_fuzzy_select gimp_histogram
gimp_hue_saturation gimp_invert gimp_levels gimp_paintbrush
gimp_paintbrush_extended gimp_pencil gimp_perspective gimp_posterize
gimp_rotate gimp_scale gimp_selection_float gimp_selection_layer_alpha
gimp_selection_load gimp_shear gimp_threshold
1998-11-14 04:40:00 +08:00
int_value = args [ 2 ] . value . pdb_int ;
1997-11-25 06:05:25 +08:00
if ( int_value > 0 )
num_strokes = int_value / 2 ;
else
success = FALSE ;
}
/* point array */
if ( success )
API-mega-break-it-all patch part one: removed the unnecessary PDB_IMAGE
* airbrush.c, blend.c, brightness_contrast.c, bucket_fill.c
by_color_select.c, channel_ops.c, clone.c, color_balance.c
color_picker.c, convolve.c, curves.c, desaturate.c, edit_cmds.c
equalize.c, eraser.c, flip_tool.c, fuzzy_select.c,
gimage_mask_cmds.c histogram_tool.c, hue_saturation.c, invert.c,
levels.c, pencil.c paintbrush.c, perspective_tool.c, posterize.c,
rotate_tool.c scale_tool.c, shear_tool.c, text_tool.c, threshold.c:
API-mega-break-it-all patch part one: removed the unnecessary
PDB_IMAGE argument from many functions.
Affected functions:
gimp_airbrush gimp_blend gimp_brightness_contrast gimp_bucket_fill
gimp_by_color_select gimp_channel_ops_offset gimp_clone gimp_color_balance
gimp_color_picker gimp_convolve gimp_curves_explicit gimp_curves_spline
gimp_desaturate gimp_edit_clear gimp_edit_copy gimp_edit_cut gimp_edit_fill
gimp_edit_paste gimp_edit_stroke gimp_equalize gimp_eraser
gimp_eraser_extended gimp_flip gimp_fuzzy_select gimp_histogram
gimp_hue_saturation gimp_invert gimp_levels gimp_paintbrush
gimp_paintbrush_extended gimp_pencil gimp_perspective gimp_posterize
gimp_rotate gimp_scale gimp_selection_float gimp_selection_layer_alpha
gimp_selection_load gimp_shear gimp_threshold
1998-11-14 04:40:00 +08:00
stroke_array = ( double * ) args [ 3 ] . value . pdb_pointer ;
1997-11-25 06:05:25 +08:00
if ( success )
/* init the paint core */
1998-01-22 15:02:57 +08:00
success = paint_core_init ( & non_gui_paint_core , drawable ,
1997-11-25 06:05:25 +08:00
stroke_array [ 0 ] , stroke_array [ 1 ] ) ;
if ( success )
{
1998-03-01 09:18:45 +08:00
non_gui_incremental = 0 ;
/* set the paint core's paint func */
non_gui_paint_core . paint_func = paintbrush_non_gui_paint_func ;
non_gui_paint_core . startx = non_gui_paint_core . lastx = stroke_array [ 0 ] ;
non_gui_paint_core . starty = non_gui_paint_core . lasty = stroke_array [ 1 ] ;
if ( num_strokes = = 1 )
paintbrush_non_gui_paint_func ( & non_gui_paint_core , drawable , 0 ) ;
for ( i = 1 ; i < num_strokes ; i + + )
{
non_gui_paint_core . curx = stroke_array [ i * 2 + 0 ] ;
non_gui_paint_core . cury = stroke_array [ i * 2 + 1 ] ;
paint_core_interpolate ( & non_gui_paint_core , drawable ) ;
non_gui_paint_core . lastx = non_gui_paint_core . curx ;
non_gui_paint_core . lasty = non_gui_paint_core . cury ;
}
/* finish the painting */
paint_core_finish ( & non_gui_paint_core , drawable , - 1 ) ;
/* cleanup */
paint_core_cleanup ( ) ;
}
return procedural_db_return_args ( & paintbrush_proc , success ) ;
}
1999-03-17 13:40:16 +08:00
1998-03-01 09:18:45 +08:00
static Argument *
paintbrush_extended_invoker ( Argument * args )
{
int success = TRUE ;
GImage * gimage ;
GimpDrawable * drawable ;
int num_strokes ;
double * stroke_array ;
int int_value ;
double fp_value ;
int i ;
drawable = NULL ;
num_strokes = 0 ;
/* the drawable */
if ( success )
{
API-mega-break-it-all patch part one: removed the unnecessary PDB_IMAGE
* airbrush.c, blend.c, brightness_contrast.c, bucket_fill.c
by_color_select.c, channel_ops.c, clone.c, color_balance.c
color_picker.c, convolve.c, curves.c, desaturate.c, edit_cmds.c
equalize.c, eraser.c, flip_tool.c, fuzzy_select.c,
gimage_mask_cmds.c histogram_tool.c, hue_saturation.c, invert.c,
levels.c, pencil.c paintbrush.c, perspective_tool.c, posterize.c,
rotate_tool.c scale_tool.c, shear_tool.c, text_tool.c, threshold.c:
API-mega-break-it-all patch part one: removed the unnecessary
PDB_IMAGE argument from many functions.
Affected functions:
gimp_airbrush gimp_blend gimp_brightness_contrast gimp_bucket_fill
gimp_by_color_select gimp_channel_ops_offset gimp_clone gimp_color_balance
gimp_color_picker gimp_convolve gimp_curves_explicit gimp_curves_spline
gimp_desaturate gimp_edit_clear gimp_edit_copy gimp_edit_cut gimp_edit_fill
gimp_edit_paste gimp_edit_stroke gimp_equalize gimp_eraser
gimp_eraser_extended gimp_flip gimp_fuzzy_select gimp_histogram
gimp_hue_saturation gimp_invert gimp_levels gimp_paintbrush
gimp_paintbrush_extended gimp_pencil gimp_perspective gimp_posterize
gimp_rotate gimp_scale gimp_selection_float gimp_selection_layer_alpha
gimp_selection_load gimp_shear gimp_threshold
1998-11-14 04:40:00 +08:00
int_value = args [ 0 ] . value . pdb_int ;
1998-03-01 09:18:45 +08:00
drawable = drawable_get_ID ( int_value ) ;
API-mega-break-it-all patch part one: removed the unnecessary PDB_IMAGE
* airbrush.c, blend.c, brightness_contrast.c, bucket_fill.c
by_color_select.c, channel_ops.c, clone.c, color_balance.c
color_picker.c, convolve.c, curves.c, desaturate.c, edit_cmds.c
equalize.c, eraser.c, flip_tool.c, fuzzy_select.c,
gimage_mask_cmds.c histogram_tool.c, hue_saturation.c, invert.c,
levels.c, pencil.c paintbrush.c, perspective_tool.c, posterize.c,
rotate_tool.c scale_tool.c, shear_tool.c, text_tool.c, threshold.c:
API-mega-break-it-all patch part one: removed the unnecessary
PDB_IMAGE argument from many functions.
Affected functions:
gimp_airbrush gimp_blend gimp_brightness_contrast gimp_bucket_fill
gimp_by_color_select gimp_channel_ops_offset gimp_clone gimp_color_balance
gimp_color_picker gimp_convolve gimp_curves_explicit gimp_curves_spline
gimp_desaturate gimp_edit_clear gimp_edit_copy gimp_edit_cut gimp_edit_fill
gimp_edit_paste gimp_edit_stroke gimp_equalize gimp_eraser
gimp_eraser_extended gimp_flip gimp_fuzzy_select gimp_histogram
gimp_hue_saturation gimp_invert gimp_levels gimp_paintbrush
gimp_paintbrush_extended gimp_pencil gimp_perspective gimp_posterize
gimp_rotate gimp_scale gimp_selection_float gimp_selection_layer_alpha
gimp_selection_load gimp_shear gimp_threshold
1998-11-14 04:40:00 +08:00
if ( drawable = = NULL )
success = FALSE ;
else
gimage = drawable_gimage ( drawable ) ;
1998-03-01 09:18:45 +08:00
}
/* fade out */
if ( success )
{
API-mega-break-it-all patch part one: removed the unnecessary PDB_IMAGE
* airbrush.c, blend.c, brightness_contrast.c, bucket_fill.c
by_color_select.c, channel_ops.c, clone.c, color_balance.c
color_picker.c, convolve.c, curves.c, desaturate.c, edit_cmds.c
equalize.c, eraser.c, flip_tool.c, fuzzy_select.c,
gimage_mask_cmds.c histogram_tool.c, hue_saturation.c, invert.c,
levels.c, pencil.c paintbrush.c, perspective_tool.c, posterize.c,
rotate_tool.c scale_tool.c, shear_tool.c, text_tool.c, threshold.c:
API-mega-break-it-all patch part one: removed the unnecessary
PDB_IMAGE argument from many functions.
Affected functions:
gimp_airbrush gimp_blend gimp_brightness_contrast gimp_bucket_fill
gimp_by_color_select gimp_channel_ops_offset gimp_clone gimp_color_balance
gimp_color_picker gimp_convolve gimp_curves_explicit gimp_curves_spline
gimp_desaturate gimp_edit_clear gimp_edit_copy gimp_edit_cut gimp_edit_fill
gimp_edit_paste gimp_edit_stroke gimp_equalize gimp_eraser
gimp_eraser_extended gimp_flip gimp_fuzzy_select gimp_histogram
gimp_hue_saturation gimp_invert gimp_levels gimp_paintbrush
gimp_paintbrush_extended gimp_pencil gimp_perspective gimp_posterize
gimp_rotate gimp_scale gimp_selection_float gimp_selection_layer_alpha
gimp_selection_load gimp_shear gimp_threshold
1998-11-14 04:40:00 +08:00
fp_value = args [ 1 ] . value . pdb_float ;
1998-03-01 09:18:45 +08:00
if ( fp_value > = 0.0 )
non_gui_fade_out = fp_value ;
else
success = FALSE ;
}
1999-03-17 13:40:16 +08:00
/* FIXME FIXME FIXME */
/* but we need to change the pdb call to gimp_paintbrush...ouch!! */
/* should this be enough to do this without breaking PDB? */
if ( success )
{
non_gui_gradient_length = 0.0 ;
1999-04-09 06:25:54 +08:00
non_gui_gradient_type = 3 ;
1999-03-17 13:40:16 +08:00
}
1998-03-01 09:18:45 +08:00
/* num strokes */
if ( success )
{
API-mega-break-it-all patch part one: removed the unnecessary PDB_IMAGE
* airbrush.c, blend.c, brightness_contrast.c, bucket_fill.c
by_color_select.c, channel_ops.c, clone.c, color_balance.c
color_picker.c, convolve.c, curves.c, desaturate.c, edit_cmds.c
equalize.c, eraser.c, flip_tool.c, fuzzy_select.c,
gimage_mask_cmds.c histogram_tool.c, hue_saturation.c, invert.c,
levels.c, pencil.c paintbrush.c, perspective_tool.c, posterize.c,
rotate_tool.c scale_tool.c, shear_tool.c, text_tool.c, threshold.c:
API-mega-break-it-all patch part one: removed the unnecessary
PDB_IMAGE argument from many functions.
Affected functions:
gimp_airbrush gimp_blend gimp_brightness_contrast gimp_bucket_fill
gimp_by_color_select gimp_channel_ops_offset gimp_clone gimp_color_balance
gimp_color_picker gimp_convolve gimp_curves_explicit gimp_curves_spline
gimp_desaturate gimp_edit_clear gimp_edit_copy gimp_edit_cut gimp_edit_fill
gimp_edit_paste gimp_edit_stroke gimp_equalize gimp_eraser
gimp_eraser_extended gimp_flip gimp_fuzzy_select gimp_histogram
gimp_hue_saturation gimp_invert gimp_levels gimp_paintbrush
gimp_paintbrush_extended gimp_pencil gimp_perspective gimp_posterize
gimp_rotate gimp_scale gimp_selection_float gimp_selection_layer_alpha
gimp_selection_load gimp_shear gimp_threshold
1998-11-14 04:40:00 +08:00
int_value = args [ 2 ] . value . pdb_int ;
1998-03-01 09:18:45 +08:00
if ( int_value > 0 )
num_strokes = int_value / 2 ;
else
success = FALSE ;
}
/* point array */
if ( success )
API-mega-break-it-all patch part one: removed the unnecessary PDB_IMAGE
* airbrush.c, blend.c, brightness_contrast.c, bucket_fill.c
by_color_select.c, channel_ops.c, clone.c, color_balance.c
color_picker.c, convolve.c, curves.c, desaturate.c, edit_cmds.c
equalize.c, eraser.c, flip_tool.c, fuzzy_select.c,
gimage_mask_cmds.c histogram_tool.c, hue_saturation.c, invert.c,
levels.c, pencil.c paintbrush.c, perspective_tool.c, posterize.c,
rotate_tool.c scale_tool.c, shear_tool.c, text_tool.c, threshold.c:
API-mega-break-it-all patch part one: removed the unnecessary
PDB_IMAGE argument from many functions.
Affected functions:
gimp_airbrush gimp_blend gimp_brightness_contrast gimp_bucket_fill
gimp_by_color_select gimp_channel_ops_offset gimp_clone gimp_color_balance
gimp_color_picker gimp_convolve gimp_curves_explicit gimp_curves_spline
gimp_desaturate gimp_edit_clear gimp_edit_copy gimp_edit_cut gimp_edit_fill
gimp_edit_paste gimp_edit_stroke gimp_equalize gimp_eraser
gimp_eraser_extended gimp_flip gimp_fuzzy_select gimp_histogram
gimp_hue_saturation gimp_invert gimp_levels gimp_paintbrush
gimp_paintbrush_extended gimp_pencil gimp_perspective gimp_posterize
gimp_rotate gimp_scale gimp_selection_float gimp_selection_layer_alpha
gimp_selection_load gimp_shear gimp_threshold
1998-11-14 04:40:00 +08:00
stroke_array = ( double * ) args [ 3 ] . value . pdb_pointer ;
1998-03-01 09:18:45 +08:00
if ( success )
/* init the paint core */
success = paint_core_init ( & non_gui_paint_core , drawable ,
stroke_array [ 0 ] , stroke_array [ 1 ] ) ;
if ( success )
{
API-mega-break-it-all patch part one: removed the unnecessary PDB_IMAGE
* airbrush.c, blend.c, brightness_contrast.c, bucket_fill.c
by_color_select.c, channel_ops.c, clone.c, color_balance.c
color_picker.c, convolve.c, curves.c, desaturate.c, edit_cmds.c
equalize.c, eraser.c, flip_tool.c, fuzzy_select.c,
gimage_mask_cmds.c histogram_tool.c, hue_saturation.c, invert.c,
levels.c, pencil.c paintbrush.c, perspective_tool.c, posterize.c,
rotate_tool.c scale_tool.c, shear_tool.c, text_tool.c, threshold.c:
API-mega-break-it-all patch part one: removed the unnecessary
PDB_IMAGE argument from many functions.
Affected functions:
gimp_airbrush gimp_blend gimp_brightness_contrast gimp_bucket_fill
gimp_by_color_select gimp_channel_ops_offset gimp_clone gimp_color_balance
gimp_color_picker gimp_convolve gimp_curves_explicit gimp_curves_spline
gimp_desaturate gimp_edit_clear gimp_edit_copy gimp_edit_cut gimp_edit_fill
gimp_edit_paste gimp_edit_stroke gimp_equalize gimp_eraser
gimp_eraser_extended gimp_flip gimp_fuzzy_select gimp_histogram
gimp_hue_saturation gimp_invert gimp_levels gimp_paintbrush
gimp_paintbrush_extended gimp_pencil gimp_perspective gimp_posterize
gimp_rotate gimp_scale gimp_selection_float gimp_selection_layer_alpha
gimp_selection_load gimp_shear gimp_threshold
1998-11-14 04:40:00 +08:00
non_gui_incremental = args [ 4 ] . value . pdb_int ;
1997-11-25 06:05:25 +08:00
/* set the paint core's paint func */
non_gui_paint_core . paint_func = paintbrush_non_gui_paint_func ;
non_gui_paint_core . startx = non_gui_paint_core . lastx = stroke_array [ 0 ] ;
non_gui_paint_core . starty = non_gui_paint_core . lasty = stroke_array [ 1 ] ;
if ( num_strokes = = 1 )
1998-01-22 15:02:57 +08:00
paintbrush_non_gui_paint_func ( & non_gui_paint_core , drawable , 0 ) ;
1997-11-25 06:05:25 +08:00
for ( i = 1 ; i < num_strokes ; i + + )
{
non_gui_paint_core . curx = stroke_array [ i * 2 + 0 ] ;
non_gui_paint_core . cury = stroke_array [ i * 2 + 1 ] ;
1998-01-22 15:02:57 +08:00
paint_core_interpolate ( & non_gui_paint_core , drawable ) ;
1997-11-25 06:05:25 +08:00
non_gui_paint_core . lastx = non_gui_paint_core . curx ;
non_gui_paint_core . lasty = non_gui_paint_core . cury ;
}
/* finish the painting */
1998-01-22 15:02:57 +08:00
paint_core_finish ( & non_gui_paint_core , drawable , - 1 ) ;
1997-11-25 06:05:25 +08:00
/* cleanup */
paint_core_cleanup ( ) ;
}
1999-03-17 13:40:16 +08:00
return procedural_db_return_args ( & paintbrush_extended_proc , success ) ;
}
static Argument *
paintbrush_extended_gradient_invoker ( Argument * args )
{
int success = TRUE ;
GImage * gimage ;
GimpDrawable * drawable ;
int num_strokes ;
double * stroke_array ;
int int_value ;
double fp_value ;
int i ;
drawable = NULL ;
num_strokes = 0 ;
/* the drawable */
if ( success )
{
int_value = args [ 0 ] . value . pdb_int ;
drawable = drawable_get_ID ( int_value ) ;
if ( drawable = = NULL )
success = FALSE ;
else
gimage = drawable_gimage ( drawable ) ;
}
/* fade out */
if ( success )
{
fp_value = args [ 1 ] . value . pdb_float ;
if ( fp_value > = 0.0 )
non_gui_fade_out = fp_value ;
else
success = FALSE ;
}
/* gradient length */
if ( success )
{
fp_value = args [ 2 ] . value . pdb_float ;
if ( fp_value > = 0.0 )
non_gui_gradient_length = fp_value ;
else
success = FALSE ;
}
/* num strokes */
if ( success )
{
int_value = args [ 3 ] . value . pdb_int ;
if ( int_value > 0 )
num_strokes = int_value / 2 ;
else
success = FALSE ;
}
/* point array */
if ( success )
stroke_array = ( double * ) args [ 4 ] . value . pdb_pointer ;
if ( success )
/* init the paint core */
success = paint_core_init ( & non_gui_paint_core , drawable ,
stroke_array [ 0 ] , stroke_array [ 1 ] ) ;
if ( success )
{
non_gui_incremental = args [ 5 ] . value . pdb_int ;
/* set the paint core's paint func */
non_gui_paint_core . paint_func = paintbrush_non_gui_paint_func ;
non_gui_paint_core . startx = non_gui_paint_core . lastx = stroke_array [ 0 ] ;
non_gui_paint_core . starty = non_gui_paint_core . lasty = stroke_array [ 1 ] ;
if ( num_strokes = = 1 )
paintbrush_non_gui_paint_func ( & non_gui_paint_core , drawable , 0 ) ;
for ( i = 1 ; i < num_strokes ; i + + )
{
non_gui_paint_core . curx = stroke_array [ i * 2 + 0 ] ;
non_gui_paint_core . cury = stroke_array [ i * 2 + 1 ] ;
paint_core_interpolate ( & non_gui_paint_core , drawable ) ;
non_gui_paint_core . lastx = non_gui_paint_core . curx ;
non_gui_paint_core . lasty = non_gui_paint_core . cury ;
}
/* finish the painting */
paint_core_finish ( & non_gui_paint_core , drawable , - 1 ) ;
/* cleanup */
paint_core_cleanup ( ) ;
}
return procedural_db_return_args ( & paintbrush_extended_gradient_proc , success ) ;
1997-11-25 06:05:25 +08:00
}