adding Gradiant code to determin hat dip

just some simple gradiant code that willallos me to detect when a hat
has been dipped