Commits

bworkman  committed 9e594d0

rename file, add documentation

  • Participants
  • Parent commits 515d12d

Comments (0)

Files changed (2)

File divide-layer.py

+from gimpfu import *
+import gtk
+import os
+import collections
+import ctypes
+
+def divide_layer(img, drawable, width, height) :
+"""****f* divide-layer/divide_layer
+*       DESCRIPTION
+*               Python-fu function, creates new layers holding copied regions from the active layer of an image
+*       ARGUMENTS
+*               img             -- python-fu image
+*               drawable        -- python-fu drawable
+*               width           -- width (in pixels) of regions to copy
+*               height          -- height (in pixels) of regions to copy
+*       SIDE EFFECTS
+*               Appends copy layers to image layer list
+*       RESULT
+*               None.
+*****"""
+        MessageBox = ctypes.windll.user32.MessageBoxA
+
+        hslices = img.width / width
+        if 0 != (img.width % width) :
+                hslices += 1
+
+        vslices = img.height / height
+        if 0 != (img.height % height) :
+                vslices += 1
+
+        layer_to_slice = img.active_layer
+
+        for i in range(vslices) :
+                for j in range(hslices) :
+                        layer = layer_to_slice.copy()
+                        layer.name = '(' + str(j) + ',' + str(i) + ')'
+                        img.add_layer(layer, len(img.layers))
+                        layer.resize(width, height, -1 * (j * width), -1 * (i * height))
+
+
+        return None
+
+"""****h* divide-layer/divide-layer
+*       DESCRIPTION
+*               Python-fu plug-in to divide a layer into smaller sections
+*       ARGUMENTS
+*               None.
+*       SIDE EFFECTS
+*               Adds to GIMP menu "Layer", submenu "Transform", item "Divide"
+*       RESULT
+*               None.
+*       NOTE
+*               Function is only available when an active image is open in GIMP.
+*               Active layer is the layer that is divided.
+*       SOURCE
+*"""
+register(
+        #name
+        "divide_layer",
+        #blurb
+        "Divide active layer into sections",
+        #help
+        "Select the layer you want to divide from an image",
+        #author
+        "Code Fox",
+        #copyright
+        "http://en.wikipedia.org/wiki/MIT_License",
+        #date
+        "March 4th, 2013",
+        #menu path
+        "<Image>/Layer/Transform/Divide",
+        #image types
+        "*",
+        #params
+        [
+            (PF_INT, "width", "px width", None),
+            (PF_INT, "height", "pc height", None),
+        ],
+        #results
+        [],
+        #function
+        divide_layer
+)
+
+main()
+"""*******"""

File layer-slice.py

-from gimpfu import *
-import gtk
-import os
-import collections
-import ctypes
-
-def slice_layer(img, drawable, width, height) :
-
-        MessageBox = ctypes.windll.user32.MessageBoxA
-
-        hslices = img.width / width
-        if 0 != (img.width % width) :
-                hslices += 1
-
-        vslices = img.height / height
-        if 0 != (img.height % height) :
-                vslices += 1
-
-        #MessageBox(None, 'vertical slices = ' + str(vslices) + '\nhorizontal slices = ' + str(hslices), 'Window title', 0)
-
-        layer_to_slice = img.active_layer
-
-        for i in range(vslices) :
-                for j in range(hslices) :
-                        #MessageBox(None, 'Slice (' + str(i) + ',' + str(j) + ')', 'Window title', 0)
-                        layer = layer_to_slice.copy()
-                        layer.name = 'slice (' + str(j) + ',' + str(i) + ')'
-                        img.add_layer(layer, len(img.layers))
-                        layer.resize(width, height, -1 * (j * width), -1 * (i * height))
-
-
-        return None
-
-register(
-        #name
-        "layer_slice",
-        #blurb
-        "<blurb>",
-        #help
-        "<help text>",
-        #author
-        "<author>",
-        #copyright
-        "<copyright>",
-        #date
-        "<date>",
-        #menu path
-        "<Image>/Layer/Slice",
-        #image types
-        "*",
-        #params
-        [
-                #(type, name, description, default [, extra])
-            #(PF_IMAGE, "image", "Input image", None),
-            #(PF_DRAWABLE, "drawable", "Input drawable", None),
-            (PF_INT, "width", "px slice width", None),
-            (PF_INT, "height", "pc slice height", None),
-        ],
-        #results
-        [],
-        #function
-        slice_layer
-)
-
-main()