class TrapTransform(UserTransform) {
; Basic move/rotate/size/stretch/skew trap shape transform.
public:
func TrapTransform(Generic pparent)
UserTransform.UserTransform(pparent)
endfunc
func Init(complex pz)
UserTransform.Init(pz)
m_Rotation = (0,1) ^ (@p_traprotation / 90.0)
m_Skew = (0,1) ^ (@p_trapskew / 90.0)
m_TrapCenter = @p_trapcenter
if (@p_trapcentermoves)
m_TrapCenter = m_TrapCenter + pz
endif
endfunc
complex func Iterate(complex pz)
m_Iterations = m_Iterations + 1
; apply per-iteration steps
if (@p_trapdrift != (0,0))
m_TrapCenter = m_TrapCenter + @p_trapdrift
endif
if (@p_traprotationstep != 0.0)
m_Rotation = (0,1) ^ ((@p_traprotation + @p_traprotationstep*(m_Iterations-1)) / 90.0)
endif
if (@p_trapskewstep != 0.0)
m_Skew = (0,1) ^ ((@p_trapskew + @p_trapskewstep*(m_Iterations-1)) / 90.0)
endif
; apply offset and rotation and size
pz = (pz - m_TrapCenter) * m_Rotation * recip(@p_trapscale)
; apply aspect
if (@p_trapaspect != 1.0)
pz = real(pz) + flip(imag(pz) * @p_trapaspect)
endif
; apply skew
pz = real(pz*m_Skew) + flip(imag(pz))
return pz
endfunc
protected:
complex m_Rotation
complex m_Skew
complex m_TrapCenter
default:
title = "Trap Position"
int param v_traptransform
caption = "Version (TrapTransform)"
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_traptransform < 100
endparam
complex param p_trapcenter
caption = "Trap Center"
default = (0,0)
hint = "This is the location of the trap in the complex plane."
endparam
bool param p_trapcentermoves
caption = "Follows initial z"
default = false
hint = "If this is enabled, the trap center will follow the initial z location, offset by the Trap Center amount. The initial z location will be the same as the pixel in many circumstances, but may not be if you are using Trap Position in unusual ways."
endparam
complex param p_trapdrift
caption = "Trap Drift"
default = (0,0)
hint = "This is the amount the trap center will move with each iteration."
endparam
float param p_trapscale
caption = "Trap Scale"
default = 1.0
hint = "This can be used to resize the entire trap shape. This is different from adjusting the trap threshold because this resizes the complete trap evenly; adjusting the threshold may change the trap shape in unexpected ways (for some trap shapes). Use values smaller than 1.0 to shrink the trap shape, larger than 1.0 to enlarge it."
endparam
float param p_traprotation
caption = "Rotation"
default = 0.0
hint = "This is the angle, in degrees, that the trap should be rotated."
endparam
float param p_traprotationstep
caption = "Rotation Step"
default = 0.0
hint = "This is the angle, in degrees, that the trap will be rotated with each iteration."
endparam
float param p_trapskew
caption = "Skew"
default = 0.0
hint = "This is the angle, in degrees, to skew the vertical axis of the trap shape."
endparam
float param p_trapskewstep
caption = "Skew Step"
default = 0.0
hint = "This is the angle, in degrees, that the skew angle should be increased by with each iteration."
endparam
float param p_trapaspect
caption = "Aspect Ratio"
default = 1.0
hint = "This is how square the trap is. You can distort the trap by using a value other than 1.0."
endparam
}