Provides useful tiling effects, primarily intended for use with trap shapes, but will work with anything.
class DMJ_TrapTiling(common.ulb:UserTransform) {
; Provides useful tiling effects, primarily intended for use with trap shapes, but will work with anything.
public:
import "common.ulb"
func DMJ_TrapTiling(Generic pparent)
UserTransform.UserTransform(pparent)
endfunc
complex func Iterate(complex pz)
UserTransform.Iterate(pz)
pz = (pz - @p_tilingcenter) * ((0,1) ^ (@p_tileangle / 90.0)) ; offset and rotate
if (@p_tiletype == 0) ; rectangular
if (real(@p_tilespacing) != 0)
pz = (real(pz) / real(@p_tilespacing) - round(real(pz) / real(@p_tilespacing))) * real(@p_tilespacing) + flip(imag(pz))
endif
if (imag(@p_tilespacing) != 0)
pz = flip(imag(pz) / imag(@p_tilespacing) - round(imag(pz) / imag(@p_tilespacing))) * imag(@p_tilespacing) + real(pz)
endif
else
pz = atan2(pz)*4/#pi + flip(cabs(pz)) ; convert
if (real(@p_tilespacing) != 0)
pz = (real(pz) / real(@p_tilespacing) - round(real(pz) / real(@p_tilespacing))) * real(@p_tilespacing) + flip(imag(pz))
endif
if (imag(@p_tilespacing) != 0)
pz = flip(imag(pz) / imag(@p_tilespacing) - floor(imag(pz) / imag(@p_tilespacing))) * imag(@p_tilespacing) + real(pz)
endif
if (@p_tiletype == 2) ; radial; convert back to rectangular
pz = cos(real(pz)*#pi/4)*imag(pz) + flip(sin(real(pz)*#pi/4)*imag(pz))
endif
endif
pz = (pz * ((0,1) ^ (-@p_tileangle / 90.0))) + @p_tilingcenter ; un-rotate and un-offset
return pz
endfunc
default:
title = "Trap Tiling"
int param v_dmj_traptiling
caption = "Version (DMJ_TrapTiling)"
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_traptiling < 100
endparam
int param p_tiletype
caption = "Tile Type"
default = 0
enum = "rectangular" "polar" "radial"
hint = "Selects the kind of tiling to use. 'Rectangular' provides simple grid tiling. 'Polar' will tile rectangularly, then treat the coordinates as polar coordinates. 'Radial' will tile radially around a central point."
endparam
complex param p_tilingcenter
caption = "Tiling Center"
default = (0,0)
hint = "Sets the tiling center."
endparam
complex param p_tilespacing
caption = "Tile Spacing"
default = (1,1)
hint = "Sets the tile spacing. For rectangular tiles, provides the width and height of the tiles. For polar and radial tiles, sets the angular distance and radial distance. For any of these, use a value of 0 to indicate no tiling in that direction."
endparam
float param p_tileangle
caption = "Tile Rotation"
default = 0
hint = "Sets the angle of the tiling grid, in degrees."
endparam
}