115
114
void query (void)
117
static GimpParamDef args[] =
116
static const GimpParamDef args[] =
119
{ GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive" },
120
{ GIMP_PDB_IMAGE, "image", "Input image" },
121
{ GIMP_PDB_DRAWABLE, "drawable", "Input drawable" },
123
{ GIMP_PDB_INT32, "hwidth", "Horizontal Width (>= 0)" },
124
{ GIMP_PDB_INT32, "hspace", "Horizontal Spacing (>= 1)" },
125
{ GIMP_PDB_INT32, "hoffset", "Horizontal Offset (>= 0)" },
126
{ GIMP_PDB_COLOR, "hcolor", "Horizontal Colour" },
127
{ GIMP_PDB_INT8, "hopacity", "Horizontal Opacity (0...255)" },
129
{ GIMP_PDB_INT32, "vwidth", "Vertical Width (>= 0)" },
130
{ GIMP_PDB_INT32, "vspace", "Vertical Spacing (>= 1)" },
131
{ GIMP_PDB_INT32, "voffset", "Vertical Offset (>= 0)" },
132
{ GIMP_PDB_COLOR, "vcolor", "Vertical Colour" },
133
{ GIMP_PDB_INT8, "vopacity", "Vertical Opacity (0...255)" },
135
{ GIMP_PDB_INT32, "iwidth", "Intersection Width (>= 0)" },
136
{ GIMP_PDB_INT32, "ispace", "Intersection Spacing (>= 0)" },
137
{ GIMP_PDB_INT32, "ioffset", "Intersection Offset (>= 0)" },
138
{ GIMP_PDB_COLOR, "icolor", "Intersection Colour" },
118
{ GIMP_PDB_INT32, "run-mode", "Interactive, non-interactive" },
119
{ GIMP_PDB_IMAGE, "image", "Input image" },
120
{ GIMP_PDB_DRAWABLE, "drawable", "Input drawable" },
122
{ GIMP_PDB_INT32, "hwidth", "Horizontal Width (>= 0)" },
123
{ GIMP_PDB_INT32, "hspace", "Horizontal Spacing (>= 1)" },
124
{ GIMP_PDB_INT32, "hoffset", "Horizontal Offset (>= 0)" },
125
{ GIMP_PDB_COLOR, "hcolor", "Horizontal Colour" },
126
{ GIMP_PDB_INT8, "hopacity", "Horizontal Opacity (0...255)" },
128
{ GIMP_PDB_INT32, "vwidth", "Vertical Width (>= 0)" },
129
{ GIMP_PDB_INT32, "vspace", "Vertical Spacing (>= 1)" },
130
{ GIMP_PDB_INT32, "voffset", "Vertical Offset (>= 0)" },
131
{ GIMP_PDB_COLOR, "vcolor", "Vertical Colour" },
132
{ GIMP_PDB_INT8, "vopacity", "Vertical Opacity (0...255)" },
134
{ GIMP_PDB_INT32, "iwidth", "Intersection Width (>= 0)" },
135
{ GIMP_PDB_INT32, "ispace", "Intersection Spacing (>= 0)" },
136
{ GIMP_PDB_INT32, "ioffset", "Intersection Offset (>= 0)" },
137
{ GIMP_PDB_COLOR, "icolor", "Intersection Colour" },
139
138
{ GIMP_PDB_INT8, "iopacity", "Intersection Opacity (0...255)" }
142
gimp_install_procedure ("plug_in_grid",
141
gimp_install_procedure (PLUG_IN_PROC,
142
N_("Draw a grid on the image"),
144
143
"Draws a grid using the specified colors. "
145
144
"The grid origin is the upper left corner.",
427
425
for (x = sx1; x < sx2; x++)
429
x_offset = grid_cfg.vspace + x - grid_cfg.voffset;
427
x_offset = grid_cfg.hspace + x - grid_cfg.hoffset;
430
428
while (x_offset < 0)
431
x_offset += grid_cfg.vspace;
429
x_offset += grid_cfg.hspace;
434
(grid_cfg.vwidth / 2)) % grid_cfg.vspace < grid_cfg.vwidth)
432
(grid_cfg.vwidth / 2)) % grid_cfg.hspace < grid_cfg.vwidth)
436
434
pix_composite (&dest[(x-sx1) * bytes],
437
435
vcolor, bytes, blend, alpha);
441
(grid_cfg.iwidth / 2)) % grid_cfg.vspace < grid_cfg.iwidth
439
(grid_cfg.iwidth / 2)) % grid_cfg.hspace < grid_cfg.iwidth
443
((y_offset % grid_cfg.hspace >= grid_cfg.ispace
441
((y_offset % grid_cfg.vspace >= grid_cfg.ispace
445
y_offset % grid_cfg.hspace < grid_cfg.ioffset)
443
y_offset % grid_cfg.vspace < grid_cfg.ioffset)
448
(y_offset % grid_cfg.hspace) >= grid_cfg.ispace
446
(y_offset % grid_cfg.vspace) >= grid_cfg.ispace
451
(y_offset % grid_cfg.hspace) < grid_cfg.ioffset)))
449
(y_offset % grid_cfg.vspace) < grid_cfg.ioffset)))
453
451
pix_composite (&dest[(x-sx1) * bytes],
454
452
icolor, bytes, blend, alpha);
459
(grid_cfg.iwidth / 2)) % grid_cfg.hspace < grid_cfg.iwidth)
457
(grid_cfg.iwidth / 2)) % grid_cfg.vspace < grid_cfg.iwidth)
461
459
for (x = sx1; x < sx2; x++)
463
x_offset = grid_cfg.vspace + x - grid_cfg.voffset;
461
x_offset = grid_cfg.hspace + x - grid_cfg.hoffset;
464
462
while (x_offset < 0)
465
x_offset += grid_cfg.vspace;
463
x_offset += grid_cfg.hspace;
467
if ((x_offset % grid_cfg.vspace >= grid_cfg.ispace
465
if ((x_offset % grid_cfg.hspace >= grid_cfg.ispace
469
x_offset % grid_cfg.vspace < grid_cfg.ioffset)
467
x_offset % grid_cfg.hspace < grid_cfg.ioffset)
472
(x_offset % grid_cfg.vspace) >= grid_cfg.ispace
470
(x_offset % grid_cfg.hspace) >= grid_cfg.ispace
475
(x_offset % grid_cfg.vspace) < grid_cfg.ioffset))
473
(x_offset % grid_cfg.hspace) < grid_cfg.ioffset))
477
475
pix_composite (&dest[(x-sx1) * bytes],
478
476
icolor, bytes, blend, alpha);
631
631
g_return_val_if_fail (main_dialog == NULL, FALSE);
633
gimp_ui_init ("grid", TRUE);
633
gimp_ui_init (PLUG_IN_BINARY, TRUE);
635
main_dialog = dlg = gimp_dialog_new (_("Grid"), "grid",
635
main_dialog = dlg = gimp_dialog_new (_("Grid"), PLUG_IN_BINARY,
637
gimp_standard_help_func, "plug-in-grid",
637
gimp_standard_help_func, PLUG_IN_PROC,
639
639
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
640
640
GTK_STOCK_OK, GTK_RESPONSE_OK,
644
gtk_dialog_set_alternative_button_order (GTK_DIALOG (dlg),
649
gimp_window_set_transient (GTK_WINDOW (dlg));
644
651
/* Get the image resolution and unit */
645
652
gimp_image_get_resolution (image_ID, &xres, &yres);
646
653
unit = gimp_image_get_unit (image_ID);
894
901
gtk_table_attach_defaults (GTK_TABLE (table), hcolor_button, 0, 1, 1, 2);
895
902
gtk_widget_show (hcolor_button);
897
g_signal_connect (hcolor_button, "color_changed",
904
g_signal_connect (hcolor_button, "color-changed",
898
905
G_CALLBACK (gimp_color_button_get_color),
899
906
&grid_cfg.hcolor);
900
g_signal_connect (hcolor_button, "color_changed",
907
g_signal_connect (hcolor_button, "color-changed",
901
908
G_CALLBACK (color_callback),
903
g_signal_connect_swapped (hcolor_button, "color_changed",
910
g_signal_connect_swapped (hcolor_button, "color-changed",
904
911
G_CALLBACK (gimp_preview_invalidate),
912
919
gtk_table_attach_defaults (GTK_TABLE (table), vcolor_button, 1, 2, 1, 2);
913
920
gtk_widget_show (vcolor_button);
915
g_signal_connect (vcolor_button, "color_changed",
922
g_signal_connect (vcolor_button, "color-changed",
916
923
G_CALLBACK (gimp_color_button_get_color),
917
924
&grid_cfg.vcolor);
918
g_signal_connect (vcolor_button, "color_changed",
925
g_signal_connect (vcolor_button, "color-changed",
919
926
G_CALLBACK (color_callback),
921
g_signal_connect_swapped (vcolor_button, "color_changed",
928
g_signal_connect_swapped (vcolor_button, "color-changed",
922
929
G_CALLBACK (gimp_preview_invalidate),