#!/usr/bin/env python
# -*- coding: utf-8 -*-
from gimpfu import *

#
# create a function which sends msg to gimp's Error Console
# 

def gprint( text ):
   pdb.gimp_message(text)
   return 

# 
# definition of the script
# name must correspond to the name
# at the bottom of the registration, before menu
#

def TestLighting(inImage,inDrawable) :

    gprint("Hello from my script!")
    
    # Store the GIMP's settings so they can be restored when we're finished
    gimp.context_push()
    # Make all the operations in this filter undo in one group
    inImage.undo_group_start()
    
    gprint("just before")  
    
    #LIGHT 1
    
    pdb.plug_in_lighting(
        inImage,           # IMAGE
        inDrawable,        # DRAWABLE
        False,             # BUMP MAP
        None,              # ENVIRONMENT MAP
        True,              # ENABLE BUMPMAPPING
        False,             # DISABLE ENVMAPPING
        0,                 # LINEAR BUMPMAP
        1,                 # DIRECTIONAL LIGHT SOURCE
        (255, 255, 255),   # WHITE LIGHT SOURCE
        -1,                # LIGHT POSITION X
        -1,                # LIGHT POSITION Y
        1,                 # LIGHT POSITION Z
        -1,                # LIGHT DIRECTION X
        -1,                # LIGHT DIRECTION Y
        1,                 # LIGHT DIRECTION Z
        0.20,              # AMBIENT INTENSITY (GLOWING)
        0.50,              # DIFFUSE INTENSITY (BRIGHT)
        0.50,              # DIFFUSE REFLECTIVITY
        0.50,              # SPECULAR REFLECTIVITY (SHINY)
        27.00,             # HIGHLIGHT (POLISHED)
        True,              # ANTIALIASING
        False,             # SAME IMAGE
        False              # TRANSPARENT BACKGROUND
        )
    
    gprint("end of lighting!")
    
    inImage.undo_group_end()
    gimp.context_pop()
    
    return

# This is the plugin registration function
register(
    "TestLighting",    
    "to do a Test of Lighting",   
    "This script does nothing",
    "Diego", 
    "Diego Nassetti ", 
    "March 2013",
    "TestLighting", 
    "*", 
    [
      (PF_IMAGE, "image", "Input image", None),
      (PF_DRAWABLE, "drawable", "Input drawable", None)
      ], 
    [],
    TestLighting,
    menu="<Image>/Additional/Diego/",
    )

main()
