class DMJ_Clipping(common.ulb:UserTransform) {
; Basic clipping framework transform.
public:
import "common.ulb"
func DMJ_Clipping(Generic pparent)
UserTransform.UserTransform(pparent)
m_ScreenRelative = new @f_screenrelative(this)
m_Handles = new @f_handles(this)
m_Handles.SetScreenRelative(m_ScreenRelative.GetScreenRelative())
m_ClipShape = new @f_clipshape(this)
m_ClipShape.SetHandles(m_Handles)
endfunc
func Init(complex pz)
UserTransform.Init(pz)
m_ScreenRelative.Init(pz)
m_Handles.Init(pz)
m_ClipShape.Init(pz)
endfunc
complex func Iterate(complex pz)
UserTransform.Iterate(pz)
bool inshape ; flag for recording whether we're inside our shape
bool inhandle ; flag for recording whether we're inside a handle
complex cz = pz ; begin with pixel value
; apply screen-relative
cz = m_ScreenRelative.Iterate(cz)
; apply offset
cz = cz - ((0,1) ^ (@p_offsetangle / 90)) * @p_offsetamount
; see if point is in clipping shape
cz = m_ClipShape.Iterate(cz)
inshape = m_ClipShape.IsSolid()
; check handles
cz = m_Handles.Iterate(cz)
inhandle = m_Handles.IsSolid()
; merge results
m_Solid = (inshape && !inhandle) || (!inshape && inhandle)
if (@p_insideoutside == 1)
m_Solid = !m_Solid
endif
return pz ; return original value unchanged
endfunc
protected:
DMJ_ScreenRelative m_ScreenRelative
Handles m_Handles
ClipShape m_ClipShape
default:
title = "Über Clipping"
int param v_dmj_clipping
caption = "Version (DMJ_Clipping)"
default = 100
hint = "This version parameter is used to detect when a change has been made to the formula that is incompatible with the previous version. When that happens, this field will reflect the old version number to alert you to the fact that an alternate rendering is being used."
visible = @v_dmj_clipping < 100
endparam
param p_insideoutside
caption = "Clipping Region"
default = 1
enum = "inside" "outside"
hint = "Determines whether points inside the clipping shape or outside the clipping shape will be solid-colored."
endparam
DMJ_ScreenRelative param f_screenrelative
caption = "Screen Relative"
selectable = false
endparam
float param p_offsetamount
caption = "Offset Amount"
default = 0.0
hint = "If you need to shift your entire clipping region without altering its shape, you can specify an amount and a direction to offset it. Keep in mind that if you have an offset enabled, it will still be in effect while you use the eyedropper or explorer tools to select points."
endparam
float param p_offsetangle
caption = "Offset Angle"
default = 0.0
visible = (@p_offsetamount != 0.0)
hint = "Indicates the angle of the offset. Note that, if your image is rotated, and you're not using screen-relative clipping, offset angles will be rotated too. Normally an angle of 0 is to the right and 90 is up, if your image is not rotated."
endparam
float param p_rotation
caption = "Rotation"
default = 0.0
hint = "Rotates the clipping shape. Note that, if you're using screen-relative coordinates and your image is not square, or if you've squashed or stretched the zoombox, the clipping shape will deform as you rotate it. Angles are in degrees, counter-clockwise."
endparam
param p_rotationtype
caption = "Rotation Center"
default = 0
enum = "object center" "screen center" "specific point"
visible = (@p_rotation != 0.0)
hint = "Specifies around which point the object should be rotated. 'Object center' will try to determine a center point for the object, but for some complex object types this may not be the point you expect. 'Screen center' will always use the screen center, but this will cause your clipping shape to change if you zoom or pan your image. 'Specific point' will let you set an exact rotation center for your shape."
endparam
complex param p_rotationcenter
caption = "Rotation Center"
default = #center
visible = (@p_rotation != 0.0 && @p_rotationtype == 2)
hint = "Sets the center of rotation for your clip shape."
endparam
heading
caption = "Handle Options"
expanded = false
endheading
Handles param f_handles
caption = "Handle Options"
selectable = false
endparam
heading
caption = "Clip Shape Options"
expanded = true
endheading
ClipShape param f_clipshape
caption = "Clipping Shape"
default = DMJ_ClipShapeRectangle
hint = "Selects the shape of the clipping region."
endparam
}