!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! @ P_CORNER.GREG ICORNER DX DY
! Mask DX % by DY % of the current box near corner ICORNER
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! Work in user coordinate
greg1\set coordinate user
!
! Needed variables
define real user[4] poly[4,2] dx dy eps
!
! Compute x and y range to be masked
let dx user_xmax-user_xmin
let dy user_ymax-user_ymin
let eps 1e-2
if (&1.eq.1) then
  let user[1] user_xmin+eps*dx
  let user[2] user_ymin+eps*dy
  let user[3] user_xmin+&2*dx
  let user[4] user_ymin+&3*dy
else if (&1.eq.2) then
  let user[1] (user_xmax+user_xmin-&2*dx)/2
  let user[2] user_ymin+eps*dy
  let user[3] (user_xmax+user_xmin+&2*dx)/2
  let user[4] user_ymin+&3*dy
else if (&1.eq.3) then
  let user[1] user_xmax-eps*dx
  let user[2] user_ymin+eps*dy
  let user[3] user_xmax-&2*dx
  let user[4] user_ymin+&3*dy
else if (&1.eq.4) then
  let user[1] user_xmin+eps*dx
  let user[2] (user_ymin+user_ymax-&3*dy)/2
  let user[3] user_xmin+&2*dx
  let user[4] (user_ymin+user_ymax+&3*dy)/2
else if (&1.eq.6) then
  let user[1] user_xmax-eps*dx
  let user[2] (user_ymin+user_ymax-&3*dy)/2
  let user[3] user_xmax-&2*dx
  let user[4] (user_ymin+user_ymax+&3*dy)/2
else if (&1.eq.7) then
  let user[1] user_xmin+eps*dx
  let user[2] user_ymax-eps*dy
  let user[3] user_xmin+&2*dx
  let user[4] user_ymax-&3*dy
else if (&1.eq.8) then
  let user[1] (user_xmax+user_xmin-&2*dx)/2
  let user[2] user_ymax-eps*dy
  let user[3] (user_xmax+user_xmin+&2*dx)/2
  let user[4] user_ymax-&3*dy
else if (&1.eq.9) then
  let user[1] user_xmax-eps*dx
  let user[2] user_ymax-eps*dy
  let user[3] user_xmax-&2*dx
  let user[4] user_ymax-&3*dy
endif
!
! Define associated polygon
let poly user[1] user[3] user[3] user[1] user[2] user[2] user[4] user[4]
!
! Save current polygon if needed
if (exist(poly%nxy)) then
 define real opol[poly%nxy,2]
 let opol[1] poly%x
 let opol[2] poly%y
endif
!
! Mask region
greg2\polygon poly /variable
greg2\polygon /fill 7
!
! Restore original polygon
if exist(opol) then
   greg2\polygon opol /variable
endif
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
