#!/usr/bin/perl # (original release) # # 11/7/99 # Added an option to remove existing guides # Added progress bar. # ** How can we force the display to update after adding guides? ** # # 12/7/99 # Changed the display code in C and got rid of ugly hack in perl. # use Gimp; use Gimp::Fu; use Gimp::Util; # Gimp::set_trace(TRACE_ALL); register "guide_grid", "GuideGrid - creates a grid of guides\n", "You specify the X spacing, the Y spacing, and initial offsets. It creates a grid of guides\n", "Seth Burgess", "Seth Burgess ", "1999-03-20", N_"/Guides/Guide Grid", "*", [ [PF_SPINNER, "x_spacing", "How far to space grid horizontally", 24, [1,1000,1]], [PF_SPINNER, "y_spacing", "How far to space grid vertically", 24, [1,1000,1]], [PF_SPINNER, "x_offset", "How much to initially offset it horizontally", 0, [0,1000,1]], [PF_SPINNER, "y_offset", "How much to initially offset it vertically", 0, [0,1000,1]], [PF_TOGGLE, "remove_old_guides", "Remove existing guides?", 0], ], [], ['gimp-1.1'], sub { my($img,$layer,$xspace, $yspace, $xoffset, $yoffset, $remove_old_guides) =@_; # # Remove all existing guides (this is optional) # if($remove_old_guides) { $i=$img->find_next_guide(0); while ($i != 0) { $img->delete_guide($i); $i=$img->find_next_guide(0); } } # # Add vertical guides to the image # for ($i=$xoffset; $i<$img->width; $i+=$xspace) { if ($i) { $img->add_vguide($i); } } # # Add horizontal guides to the image # for ($i=$yoffset; $i<$img->height; $i+=$yspace) { if ($i) { $img->add_hguide($i); } } # # I fixed this in Gimp C code (it wasn't flushing guides properly) # Seth Burgess # ## ## Refresh the display (probably not good, works for me!) ## ## #$img->selection_all(); #$img->selection_none(); $layer->update(0, 0, $img->height, $img->width); return(); }; exit main;