File: guidegrid

package info (click to toggle)
libgimp-perl 2.0.dfsg-5
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 2,112 kB
  • ctags: 462
  • sloc: perl: 10,026; sh: 207; ansic: 207; makefile: 70
file content (98 lines) | stat: -rwxr-xr-x 2,413 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/opt/bin/perl

eval 'exec /opt/bin/perl  -S $0 ${1+"$@"}'
    if 0; # not running under some shell

# <sjburges@gimp.org> (original release)
#
# 11/7/99 <brendy@swipnet.se>
# Added an option to remove existing guides
# Added progress bar.
#
# 12/7/99 <sjburges@gimp.org>
# Changed the display code in C and got rid of ugly hack in perl.
#
# 7/15/03 <sjburges@gimp.org>
# Changed spot that its registered from <Image>/Guides to <Image>/Image/Guides
# to reduce horizontal clutter on menubar

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 <sjburges\@gimp.org>",
  "1999-03-20",
  N_"<Image>/Image/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 <sjburges@gimp.org>
    #

    ##
    ## 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;

=head1 LICENSE

Copyright Seth Burgess.  
Distrubuted under the same terms as Gimp-Perl.

=cut