mt
Class MT_GnarlyTransform
Object
common:Generic
common:Transform
common:UserTransform
mt:MT_GnarlyTransform
class
- UserTransform:MT_GnarlyTransform
Mark Townsend, May 2008
Ultra Fractal Source
Toggle UF Source Code Display
class MT_GnarlyTransform(common.ulb:UserTransform) {
;
; Mark Townsend, May 2008
;
public:
func MT_GnarlyTransform(Generic pparent)
UserTransform.UserTransform(pparent)
endfunc
complex func Iterate(complex pz)
m_Iterations = m_Iterations + 1
complex z = pz - @offset
float x = real(z) / @scale
float y = imag(z) / @scale
float xx = 0
int i = 0
while (i < @iters)
xx = x
if @formula == 0
; Martin
x = y - sin(x)
y = @a - xx
elseif @formula == 1
; Popcorn
x = x - @h * sin(y + tan(@a * y))
y = y - @h * sin(xx + tan(@a * xx))
elseif @formula == 2
; Vine
if @flavor == 0
x = x - @h * sin(y + sin(@a * y ))
y = y + @h * sin(xx + sin(@a * xx))
elseif @flavor == 1
x = x - @h * sin(y^@b + sin(@a * y))
y = y + @h * sin(xx^@b + sin(@a * xx))
elseif @flavor == 2
x = x - @h * sin(y + sin(@a * (y + sin(@a * y))))
y = y + @h * sin(xx + sin(@a * (xx + sin(@a * xx))))
else
float newx = y
float newy = x
int j = 0
while j < @flavor
j = j + 1
newx = y + sin(@a * newx)
newy = x + sin(@a * newy)
endwhile
x = x - @h * sin(newx)
y = y + @h * sin(newy)
endif
elseif @formula == 3
; Gnarl
x = x - @h * real(@gn1(y + @gn2(@a * (y + @gn3(@b * y)))))
y = y + @h * real(@gn1(xx + @gn2(@a * (xx + @gn3(@b * xx)))))
endif
i = i + 1
endwhile
x = (real(pz) - (@scale * x + real(@offset))) * @strength
y = (imag(pz) - (@scale * y + imag(@offset))) * @strength
return pz + x + flip(y)
endfunc
default:
title = "Gnarly Transformation"
param formula
caption = "Formula"
enum = "Martin" "Popcorn" "Vine" "Gnarl"
default = 1
endparam
param flavor
caption = "Flavor"
default = 2
visible = @formula == "Vine"
endparam
param strength
caption = "Strength"
default = 1.0
endparam
param offset
caption = "Offset"
default = (0,0)
endparam
param scale
caption = "Scale"
default = 1.0
endparam
param a
caption = "Alpha"
default = 3.0
endparam
param b
caption = "Beta"
default = 2.0
endparam
param h
caption = "Step size"
default = 0.01
endparam
param iters
caption = "Iterations"
default = 20
endparam
func gn1
caption = "Gnarl function #1"
default = sin()
visible = @formula == "Gnarl"
endfunc
func gn2
caption = "Gnarl function #2"
default = tan()
visible = @formula == "Gnarl"
endfunc
func gn3
caption = "Gnarl function #3"
default = cos()
visible = @formula == "Gnarl"
endfunc
}
Methods inherited from class Object |
|
MT_GnarlyTransform
public MT_GnarlyTransform(Generic pparent)
MT_GnarlyTransform
public MT_GnarlyTransform()
Iterate
public complex Iterate(complex pz)
- Description copied from class:
Transform
- Transform a single point within a sequence
After a sequence has been set up with Init(), this function
will be called once for each value in the sequence. Note
that all values in the sequence must be processed in order
(they cannot be processed out of order). If the sequence
contains only one value, Init() will still be called and
then Iterate() will be called just once.
- Overrides:
Iterate
in class Transform
- Parameters:
pz
- the complex value to be transformed
- Returns:
- the transformed value