GIMP Script-fu

Hex Artifact Content
Login

Artifact e86d7b88e81995f9908f10bd339343ad9fd70b8d:


0000: 3b 20 54 68 69 73 20 70 72 6f 67 72 61 6d 20 69  ; This program i
0010: 73 20 66 72 65 65 20 73 6f 66 74 77 61 72 65 3b  s free software;
0020: 20 79 6f 75 20 63 61 6e 20 72 65 64 69 73 74 72   you can redistr
0030: 69 62 75 74 65 20 69 74 20 61 6e 64 2f 6f 72 20  ibute it and/or 
0040: 6d 6f 64 69 66 79 0a 3b 20 69 74 20 75 6e 64 65  modify.; it unde
0050: 72 20 74 68 65 20 74 65 72 6d 73 20 6f 66 20 74  r the terms of t
0060: 68 65 20 47 4e 55 20 47 65 6e 65 72 61 6c 20 50  he GNU General P
0070: 75 62 6c 69 63 20 4c 69 63 65 6e 73 65 20 61 73  ublic License as
0080: 20 70 75 62 6c 69 73 68 65 64 20 62 79 0a 3b 20   published by.; 
0090: 74 68 65 20 46 72 65 65 20 53 6f 66 74 77 61 72  the Free Softwar
00a0: 65 20 46 6f 75 6e 64 61 74 69 6f 6e 3b 20 65 69  e Foundation; ei
00b0: 74 68 65 72 20 76 65 72 73 69 6f 6e 20 32 20 6f  ther version 2 o
00c0: 66 20 74 68 65 20 4c 69 63 65 6e 73 65 2c 20 6f  f the License, o
00d0: 72 0a 3b 20 28 61 74 20 79 6f 75 72 20 6f 70 74  r.; (at your opt
00e0: 69 6f 6e 29 20 61 6e 79 20 6c 61 74 65 72 20 76  ion) any later v
00f0: 65 72 73 69 6f 6e 2e 0a 3b 0a 3b 20 54 68 69 73  ersion..;.; This
0100: 20 70 72 6f 67 72 61 6d 20 69 73 20 64 69 73 74   program is dist
0110: 72 69 62 75 74 65 64 20 69 6e 20 74 68 65 20 68  ributed in the h
0120: 6f 70 65 20 74 68 61 74 20 69 74 20 77 69 6c 6c  ope that it will
0130: 20 62 65 20 75 73 65 66 75 6c 2c 0a 3b 20 62 75   be useful,.; bu
0140: 74 20 57 49 54 48 4f 55 54 20 41 4e 59 20 57 41  t WITHOUT ANY WA
0150: 52 52 41 4e 54 59 3b 20 77 69 74 68 6f 75 74 20  RRANTY; without 
0160: 65 76 65 6e 20 74 68 65 20 69 6d 70 6c 69 65 64  even the implied
0170: 20 77 61 72 72 61 6e 74 79 20 6f 66 0a 3b 20 4d   warranty of.; M
0180: 45 52 43 48 41 4e 54 41 42 49 4c 49 54 59 20 6f  ERCHANTABILITY o
0190: 72 20 46 49 54 4e 45 53 53 20 46 4f 52 20 41 20  r FITNESS FOR A 
01a0: 50 41 52 54 49 43 55 4c 41 52 20 50 55 52 50 4f  PARTICULAR PURPO
01b0: 53 45 2e 20 20 53 65 65 20 74 68 65 0a 3b 20 47  SE.  See the.; G
01c0: 4e 55 20 47 65 6e 65 72 61 6c 20 50 75 62 6c 69  NU General Publi
01d0: 63 20 4c 69 63 65 6e 73 65 20 66 6f 72 20 6d 6f  c License for mo
01e0: 72 65 20 64 65 74 61 69 6c 73 2e 0a 0a 28 64 65  re details...(de
01f0: 66 69 6e 65 20 28 73 67 2d 73 65 6c 65 63 74 2d  fine (sg-select-
0200: 77 69 74 68 69 6e 2d 6c 61 79 65 72 20 69 6d 61  within-layer ima
0210: 67 65 20 64 72 61 77 61 62 6c 65 29 0a 20 20 28  ge drawable).  (
0220: 6c 65 74 2a 20 28 28 6c 61 79 65 72 20 28 63 61  let* ((layer (ca
0230: 72 20 28 67 69 6d 70 2d 69 6d 61 67 65 2d 67 65  r (gimp-image-ge
0240: 74 2d 61 63 74 69 76 65 2d 6c 61 79 65 72 20 69  t-active-layer i
0250: 6d 61 67 65 29 29 29 29 0a 20 20 20 20 28 67 69  mage)))).    (gi
0260: 6d 70 2d 69 6d 61 67 65 2d 75 6e 64 6f 2d 67 72  mp-image-undo-gr
0270: 6f 75 70 2d 73 74 61 72 74 20 69 6d 61 67 65 29  oup-start image)
0280: 0a 20 20 20 20 28 69 66 20 28 3d 20 28 63 61 72  .    (if (= (car
0290: 20 28 67 69 6d 70 2d 73 65 6c 65 63 74 69 6f 6e   (gimp-selection
02a0: 2d 62 6f 75 6e 64 73 20 69 6d 61 67 65 29 29 20  -bounds image)) 
02b0: 46 41 4c 53 45 29 0a 20 20 20 20 20 20 28 67 69  FALSE).      (gi
02c0: 6d 70 2d 73 65 6c 65 63 74 69 6f 6e 2d 61 6c 6c  mp-selection-all
02d0: 20 69 6d 61 67 65 29 20 29 0a 20 20 20 20 28 67   image) ).    (g
02e0: 69 6d 70 2d 72 65 63 74 2d 73 65 6c 65 63 74 20  imp-rect-select 
02f0: 69 6d 61 67 65 0a 20 20 20 20 20 20 20 20 20 20  image.          
0300: 20 20 20 20 20 20 20 20 20 20 20 20 28 63 61 72              (car
0310: 20 28 67 69 6d 70 2d 64 72 61 77 61 62 6c 65 2d   (gimp-drawable-
0320: 6f 66 66 73 65 74 73 20 6c 61 79 65 72 29 29 0a  offsets layer)).
0330: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0340: 20 20 20 20 20 20 28 63 61 64 72 20 28 67 69 6d        (cadr (gim
0350: 70 2d 64 72 61 77 61 62 6c 65 2d 6f 66 66 73 65  p-drawable-offse
0360: 74 73 20 6c 61 79 65 72 29 29 0a 20 20 20 20 20  ts layer)).     
0370: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0380: 20 28 63 61 72 20 28 67 69 6d 70 2d 64 72 61 77   (car (gimp-draw
0390: 61 62 6c 65 2d 77 69 64 74 68 20 6c 61 79 65 72  able-width layer
03a0: 29 29 0a 20 20 20 20 20 20 20 20 20 20 20 20 20  )).             
03b0: 20 20 20 20 20 20 20 20 20 28 63 61 72 20 28 67           (car (g
03c0: 69 6d 70 2d 64 72 61 77 61 62 6c 65 2d 68 65 69  imp-drawable-hei
03d0: 67 68 74 20 6c 61 79 65 72 29 29 0a 20 20 20 20  ght layer)).    
03e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
03f0: 20 20 43 48 41 4e 4e 45 4c 2d 4f 50 2d 49 4e 54    CHANNEL-OP-INT
0400: 45 52 53 45 43 54 20 30 20 30 20 29 0a 20 20 20  ERSECT 0 0 ).   
0410: 20 28 67 69 6d 70 2d 69 6d 61 67 65 2d 75 6e 64   (gimp-image-und
0420: 6f 2d 67 72 6f 75 70 2d 65 6e 64 20 69 6d 61 67  o-group-end imag
0430: 65 29 20 29 0a 20 20 28 67 69 6d 70 2d 64 69 73  e) ).  (gimp-dis
0440: 70 6c 61 79 73 2d 66 6c 75 73 68 29 0a 20 20 29  plays-flush).  )
0450: 0a 0a 28 73 63 72 69 70 74 2d 66 75 2d 72 65 67  ..(script-fu-reg
0460: 69 73 74 65 72 20 22 73 67 2d 73 65 6c 65 63 74  ister "sg-select
0470: 2d 77 69 74 68 69 6e 2d 6c 61 79 65 72 22 0a 20  -within-layer". 
0480: 20 22 5f 57 69 74 68 69 6e 20 4c 61 79 65 72 22   "_Within Layer"
0490: 0a 20 20 5f 22 49 6e 74 65 72 73 65 63 74 20 73  .  _"Intersect s
04a0: 65 6c 65 63 74 69 6f 6e 20 77 69 74 68 20 74 68  election with th
04b0: 65 20 62 6f 75 6e 64 61 72 69 65 73 20 6f 66 20  e boundaries of 
04c0: 74 68 65 20 61 63 74 69 76 65 20 6c 61 79 65 72  the active layer
04d0: 22 0a 20 20 22 53 61 75 6c 20 47 6f 6f 64 65 22  ".  "Saul Goode"
04e0: 0a 20 20 22 53 61 75 6c 20 47 6f 6f 64 65 22 0a  .  "Saul Goode".
04f0: 20 20 22 31 31 2f 31 36 2f 32 30 30 36 22 0a 20    "11/16/2006". 
0500: 20 22 2a 22 0a 20 20 53 46 2d 49 4d 41 47 45 20   "*".  SF-IMAGE 
0510: 20 20 20 22 49 6d 61 67 65 22 20 20 20 20 30 0a     "Image"    0.
0520: 20 20 53 46 2d 44 52 41 57 41 42 4c 45 20 22 44    SF-DRAWABLE "D
0530: 72 61 77 61 62 6c 65 22 20 30 0a 20 20 29 0a 28  rawable" 0.  ).(
0540: 73 63 72 69 70 74 2d 66 75 2d 6d 65 6e 75 2d 72  script-fu-menu-r
0550: 65 67 69 73 74 65 72 20 22 73 67 2d 73 65 6c 65  egister "sg-sele
0560: 63 74 2d 77 69 74 68 69 6e 2d 6c 61 79 65 72 22  ct-within-layer"
0570: 0a 20 20 22 3c 49 6d 61 67 65 3e 2f 53 65 6c 65  .  "<Image>/Sele
0580: 63 74 22 0a 20 20 29 0a                          ct".  ).