Skip to content

Instantly share code, notes, and snippets.

@Shoeboxam
Created May 13, 2017 01:14
Show Gist options
  • Save Shoeboxam/1dd9b12ff1f7f8069d99dc24277ef2ba to your computer and use it in GitHub Desktop.
Save Shoeboxam/1dd9b12ff1f7f8069d99dc24277ef2ba to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
from gimpfu import *
def solid_bezel(image, drawable, pixels, interior):
# If an interior face, light comes from bottom left
outer, inner = 16, 17
if interior:
outer, inner = 17, 16
pdb.gimp_image_undo_group_start(image)
pdb.gimp_image_select_item(image, 0, drawable)
layername = pdb.gimp_layer_get_name(drawable)
# Base textures
lower = image.new_layer(layername + " Lower")
pdb.gimp_layer_set_opacity(lower, 50)
pdb.gimp_layer_set_mode(lower, inner)
upper = image.new_layer(layername + " Upper")
pdb.gimp_layer_set_opacity(upper, 50)
pdb.gimp_layer_set_mode(upper, outer)
for i in range(1, pixels+1):
lower_temp = pdb.gimp_layer_copy(drawable, 1)
pdb.gimp_image_insert_layer(image, lower_temp, None, -1)
pdb.gimp_drawable_offset(lower_temp, 1, 0, -i, i)
upper_temp = pdb.gimp_layer_copy(drawable, 1)
pdb.gimp_image_insert_layer(image, upper_temp, None, -1)
pdb.gimp_drawable_offset(upper_temp, 1, 0, i, -i)
pdb.gimp_image_select_item(image, 0, drawable)
pdb.gimp_edit_clear(lower_temp)
pdb.gimp_edit_clear(upper_temp)
pdb.gimp_image_select_item(image, 0, lower)
pdb.gimp_edit_clear(lower_temp)
pdb.gimp_image_select_item(image, 0, upper)
pdb.gimp_edit_clear(upper_temp)
pdb.gimp_selection_none(image)
pdb.gimp_edit_copy(lower_temp)
floating = pdb.gimp_edit_paste(lower, 0)
pdb.gimp_floating_sel_anchor(floating)
pdb.gimp_edit_copy(upper_temp)
floating = pdb.gimp_edit_paste(upper, 0)
pdb.gimp_floating_sel_anchor(floating)
pdb.gimp_image_remove_layer(image, lower_temp)
pdb.gimp_image_remove_layer(image, upper_temp)
pdb.gimp_drawable_offset(lower, 1, 0, pixels, -pixels)
pdb.gimp_drawable_offset(upper, 1, 0, -pixels, pixels)
# Clean residue
pdb.gimp_image_select_item(image, 0, drawable)
pdb.gimp_selection_invert(image)
pdb.gimp_edit_clear(upper)
pdb.gimp_edit_clear(lower)
pdb.gimp_selection_none(image)
pdb.gimp_image_undo_group_end(image)
pdb.gimp_displays_flush()
register(
'solid_bezel',
'Solid bezel with 45` lighting',
'Solid bezel with 45` lighting',
'Shoeboxam',
'Shoeboxam',
'2017',
"Solid Bezel",
"*",
[
(PF_IMAGE, "image", "Input image", None),
(PF_DRAWABLE, "drawable", "Input drawable", None),
(PF_INT, "pixels", "Offset pixels", 1),
(PF_BOOL, "interior", "Interior", False)
],
[],
solid_bezel,
menu="<Image>/Filters/Custom")
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment