STARTPAGE‎ > ‎Bibliography‎ > ‎

### Source code

FRAKTAL: Pinskyfamily zc / MAPPING: AperiodicTilingII

The following code defines the geometrical parameters that creates the fundation for the Houses For the Masses project.
It’s a design solution that explaines the geometry for the frame elements, the house plans, and the city layout.
The program UltraFractal 5.04 and it's public library is used to generate this code:

```KPKinsky {
; From Luke Plant's Sierpinski
; Modified by KPK December 1999
;
; Revised version 6 August 2000

init:
complex z = pixel

loop:
IF (imag(z)>0.5)
z = 2*real(z) + flip(2*imag(z)-1)
ELSEIF (real(z)>0.5)
z = 2*real(z)-1 + flip(2*imag(z))
ELSEIF (imag(z)<0.5)
z = 2*real(z)+0.75 + flip(2+imag(z))
ELSE
z = 2*real(z) + flip(2*imag(z))
ENDIF

bailout:
(@test == 0 && |z| <= @bailout) ||                                         \
(@test == 1 && sqr(real(z)) <= @bailout) ||                                \
(@test == 2 && sqr(imag(z)) <= @bailout) ||                                \
(@test == 3 && (sqr(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (sqr(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (sqr(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (sqr(real(z) + imag(z)) <= @bailout))

default:
title = "KPKinsky I"
center = (0.4, 0.4)
magn = 1.2
maxiter = 500
param bailout
caption = "Bailout value"
default = 127
min = 1
endparam
param test
caption = "Shape Modifier"
default = 0
enum = "mod" "real" "imag" "or" "and" "manh" "manr"
endparam
}

Pinskyfamily {
; From Samuel Monnier's Julifamily
; Modified by KPK December 1999
;
; Revised version 6 August 2000

init:
complex z = pixel
zc = round(z/@sizesq)*@sizesq
z = 2*(z - zc)/@sizesq
loop:
IF (imag(z)>0.5)
z = 2*real(z) + flip(2*imag(z)-1)
ELSEIF (real(z)>0.5)
z = 2*real(z)-1 + flip(2*imag(z))
ELSE
z = 2*real(z) + flip(2*imag(z))
ENDIF

bailout:
(@test == 0 && |z| <= @bailout) ||                                         \
(@test == 1 && sqr(real(z)) <= @bailout) ||                                \
(@test == 2 && sqr(imag(z)) <= @bailout) ||                                \
(@test == 3 && (sqr(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (sqr(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (sqr(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (sqr(real(z) + imag(z)) <= @bailout))

default:
title = "Pinskyfamily"
center = (0.4, 0.4)
magn = 1.5
maxiter = 500
param power
caption = "Power"
default = (2,0)
endparam
param sizesq
caption = "Size of the tiles"
default = 0.6
endparam
param bailout
caption = "Bailout"
default = 1e20
endparam
param test
caption = "Shape Modifier"
default = 0
enum = "mod" "real" "imag" "or" "and" "manh" "manr"
endparam

}

sierpinskim-net-family {
; Written by KPK December 1999
; Derived from a formula
; written by Luke Plant with
; modifcations from Frederik Slijkerman,
; Marcelo Anelli, Kathy Roth
;
; Revised version 6 August 2000

init:
complex z = 0.2*abs(pixel^3)
zc = round(z/@sizesq)*@sizesq
z = 2*(z - zc)/@sizesq
loop:
IF (imag(z)>@corte)
z = @factor*real(z) + flip(@factor*imag(z)-1)
ELSEIF (real(z)>@corte)
z = @factor*real(z)-1 + flip(@factor*imag(z))
ELSE
z = @factor*real(z) + flip(@factor*imag(z))
z = @fn1( z )
ENDIF

bailout:
(@test == 0 && |z| <= @bailout) ||                                         \
(@test == 1 && sqr(real(z)) <= @bailout) ||                                \
(@test == 2 && sqr(imag(z)) <= @bailout) ||                                \
(@test == 3 && (sqr(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (sqr(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (sqr(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (sqr(real(z) + imag(z)) <= @bailout))

default:
title = "Sierpnetfamily"
center = (0.4, 0.4)
magn = 1.1538
maxiter = 149
param bailout
caption = "Bailout value"
default = 127
min = 1
endparam
param test
caption = "Shape Modifier"
default = 0
enum = "mod" "real" "imag" "or" "and" "manh" "manr"
endparam
param factor
caption = "Factor Transformation"
default = 2.0
endparam
param corte
caption = "Cutting edges"
default = 0.5
endparam
param power
caption = "Power"
default = (2,0)
endparam
param sizesq
caption = "Size of the tiles"
default = 0.4
endparam

func fn1
caption = "Function applied"
default = ident()
endfunc
switch:
type = "sierpinskij"
c = #pixel
factor = factor
bailout = bailout
corte = corte
fn1 = fn1
}

Papilion {
; Written by KPK December 1999
; Adapted from formulas by Samuel Monnier
; and Luke Plant
;
; Revised version 6 August 2000

init:
complex z = pixel
zc = sqr(z/@sizesq)*@sizesq
z = 2*(z - zc)/@sizesq
loop:
IF (imag(z)>0.5)
z = 2*real(z) + flip(2*imag(z)-1)
ELSEIF (real(z)>0.5)
z = 2*real(z)-1 + flip(2*imag(z))
ELSE
z = 2*real(z) + flip(2*imag(z))
ENDIF

bailout:
(@test == 0 && |z| <= @bailout) ||                                         \
(@test == 1 && sqr(real(z)) <= @bailout) ||                                \
(@test == 2 && sqr(imag(z)) <= @bailout) ||                                \
(@test == 3 && (sqr(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (sqr(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (sqr(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (sqr(real(z) + imag(z)) <= @bailout))

default:
title = "KPKinsky II"
center = (0.5, 0.1)
magn = 1.0
maxiter = 500
param power
caption = "Power"
default = (2,0)
endparam
param sizesq
caption = "Size of the tiles"
default = 0.7
endparam
param bailout
caption = "Bailout"
default = 1e20
endparam
param test
caption = "Shape Modifier"
default = 0
enum = "mod" "real" "imag" "or" "and" "manh" "manr"
endparam

}

; Written by KPK December 1999
; Adapted from formulas by Samuel Monnier
; and Luke Plant
;
; Revised version 6 August 2000

init:
complex z = pixel
zc = floor(z/@sizesq)*@sizesq
z = 2*(z - (0.25*zc))/(0.5*@sizesq)
loop:
IF (imag(z)>0.5)
z = 2*real(z) + flip(2*imag(z)-1)
ELSEIF (real(z)>0.5)
z = 2*real(z)-1 + flip(2*imag(z))
ELSE
z = 2*real(z) + flip(2*imag(z))
ENDIF

bailout:
(@test == 0 && |z| <= @bailout) ||                                         \
(@test == 1 && sqr(real(z)) <= @bailout) ||                                \
(@test == 2 && sqr(imag(z)) <= @bailout) ||                                \
(@test == 3 && (sqr(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (sqr(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (sqr(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (sqr(real(z) + imag(z)) <= @bailout))

default:
title = "KPKinsky III"
center = (0.5, 0.1)
magn = 1.5
maxiter = 500
param power
caption = "Power"
default = (2,0)
endparam
param sizesq
caption = "Size of the tiles"
default = 0.7
endparam
param bailout
caption = "Bailout"
default = 1e20
endparam
param test
caption = "Shape Modifier"
default = 0
enum = "mod" "real" "imag" "or" "and" "manh" "manr"
endparam

}

Trapez {
; Written by KPK December 1999
; Adapted from formulas by Samuel Monnier
; and Luke Plant
;
; Revised version 6 August 2000

init:
complex z = pixel
zc = sqr(z/@sizesq)*@sizesq
z = 2*(z - zc)/@sizesq
loop:
IF (imag(z)>0.5)
z = 2*real(z) + flip(2*imag(z)-1)
ELSEIF (real(z)>0.5)
z = 2*real(z)-1 + flip(2*imag(z))
ELSEIF (imag(z)<-0.1)
z = 2*imag(z)+1 + flip(2*real(z))
ELSE
z = 2*real(z) + flip(2*imag(z))
ENDIF

bailout:
(@test == 0 && |z| <= @bailout) ||                                         \
(@test == 1 && sqr(real(z)) <= @bailout) ||                                \
(@test == 2 && sqr(imag(z)) <= @bailout) ||                                \
(@test == 3 && (sqr(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (sqr(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (sqr(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (sqr(real(z) + imag(z)) <= @bailout))

default:
title = "KPKinsky IV"
center = (0.5, 0.1)
magn = 1.0
maxiter = 500
param power
caption = "Power"
default = (2,0)
endparam
param sizesq
caption = "Size of the tiles"
default = 0.7
endparam
param bailout
caption = "Bailout"
default = 1e20
endparam
param test
caption = "Shape Modifier"
default = 0
enum = "mod" "real" "imag" "or" "and" "manh" "manr"
endparam

}

; From Samuel Monnier's Julifamily
; Modified by KPK January 2000
;
; Revised version 6 August 2000

init:
complex z = pixel
zc = round(z/@sizesq)*@sizesq
z = 2*(z - zc)/@sizesq
loop:
IF (imag(z)>0.5)
z = 2*real(z) + flip(2*imag(z)-1)
ELSEIF (real(z)>0.5)
z = 2*real(z)-1 + flip(2*imag(z))
ELSEIF (imag(z)<0.5)
z = 2*imag(z)+1 + ident(2*real(z))
ELSE
z = 2*real(z) + flip(2*imag(z))
ENDIF

bailout:
(@test == 0 && |z| <= @bailout) ||                                         \
(@test == 1 && sqr(real(z)) <= @bailout) ||                                \
(@test == 2 && sqr(imag(z)) <= @bailout) ||                                \
(@test == 3 && (sqr(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (sqr(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (sqr(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (sqr(real(z) + imag(z)) <= @bailout))

default:
center = (0.4, 0.4)
magn = 1.5
maxiter = 500
param power
caption = "Power"
default = (2,0)
endparam
param sizesq
caption = "Size of the tiles"
default = 0.6
endparam
param bailout
caption = "Bailout"
default = 1e20
endparam
param test
caption = "Shape Modifier"
default = 0
enum = "mod" "real" "imag" "or" "and" "manh" "manr"
endparam

}

PinskyfamilyII {
; From Samuel Monnier's Julifamily
; Modified by KPK January 2000
;
; Revised version 6 August 2000

init:
complex z = pixel
zc = round(z/@sizesq)*@sizesq
z = 2*(z - zc)/@sizesq
loop:
IF (imag(z)>0.5)
z = 2*real(z) + flip(2*imag(z)-1)
ELSEIF (real(z)>0.5)
z = 2*real(z)-1 + flip(2*imag(z))
ELSEIF (imag(z)<0.5)
z = 2*imag(z)+1 + flip(2*real(z))
ELSE
z = 2*real(z) + flip(2*imag(z))
ENDIF

bailout:
(@test == 0 && |z| <= @bailout) ||                                         \
(@test == 1 && sqr(real(z)) <= @bailout) ||                                \
(@test == 2 && sqr(imag(z)) <= @bailout) ||                                \
(@test == 3 && (sqr(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (sqr(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (sqr(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (sqr(real(z) + imag(z)) <= @bailout))

default:
title = "Pinskyfamily II"
center = (0.4, 0.4)
magn = 1.5
maxiter = 500
param power
caption = "Power"
default = (2,0)
endparam
param sizesq
caption = "Size of the tiles"
default = 0.6
endparam
param bailout
caption = "Bailout"
default = 1e20
endparam
param test
caption = "Shape Modifier"
default = 0
enum = "mod" "real" "imag" "or" "and" "manh" "manr"
endparam

}

Funcinsky {
; Formula by KPK January 2000
; Basics from Samuel Monnier
;
; Revised version 6 August 2000

init:
complex z = pixel
zc = round(z/@sizesq)*@sizesq
z = 2*(z - zc)/@sizesq
loop:
IF (imag(z)>0.5)
z = 2*real(z) + flip(2*imag(z)-1)
ELSEIF (real(z)>0.5)
z = 2*real(z)-1 + flip(2*imag(z))
ELSEIF (real(z)<0.1)
z = 2*fn1(z)-1 + flip(2*imag(z))
ELSE
z = 2*fn2(z) + flip(2*imag(z))
ENDIF

bailout:
(@test == 0 && |z| <= @bailout) ||                                         \
(@test == 1 && sqr(real(z)) <= @bailout) ||                                \
(@test == 2 && sqr(imag(z)) <= @bailout) ||                                \
(@test == 3 && (sqr(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (sqr(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (sqr(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (sqr(real(z) + imag(z)) <= @bailout))

default:
title = "Funcinsky"
center = (0.4, 0.4)
magn = 1.5
maxiter = 500
param power
caption = "Power"
default = (2,0)
endparam
param sizesq
caption = "Size of the tiles"
default = 1
endparam
param bailout
caption = "Bailout"
default = 1e20
endparam
param test
caption = "Shape Modifier"
default = 0
enum = "mod" "real" "imag" "or" "and" "manh" "manr"
endparam
func fn1
caption = "Function 1"
default = sin()
endfunc
func fn2
caption = "Function 2"
default = abs()
endfunc
}

Dalinsky {
; Formula by KPK January 2000
; Basics from Samuel Monnier
;
; Revised version 6 August 2000

init:
complex z = pixel
zc = atan(z/@sizesq)*@sizesq
z = 2*(z - zc)/@sizesq
loop:
IF (imag(z)>0.5)
z = 2*real(z) + flip(2*imag(z)-1)
ELSEIF (real(z)>0.5)
z = 2*real(z)-1 + flip(2*imag(z))
ELSEIF (real(z)<0.1)
z = 2*fn1(z)-1 + flip(2*imag(z))
ELSE
z = 2*fn2(z) + flip(2*imag(z))
ENDIF

bailout:
(@test == 0 && |z| <= @bailout) ||                                         \
(@test == 1 && sqr(real(z)) <= @bailout) ||                                \
(@test == 2 && sqr(imag(z)) <= @bailout) ||                                \
(@test == 3 && (sqr(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (sqr(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (sqr(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (sqr(real(z) + imag(z)) <= @bailout))

default:
title = "Dalinsky"
center = (0.4, 0.1)
magn = 1.5
maxiter = 500

param power
caption = "Power"
default = (2,0)
endparam

param sizesq
caption = "Magnification"
default = 0.5
endparam

param bailout
caption = "Bailout"
default = 1e20
endparam

param test
caption = "Shape Modifier"
default = 0
enum = "mod" "real" "imag" "or" "and" "manh" "manr"
endparam

func fn1
caption = "Function 1"
default = ident()
endfunc

func fn2
caption = "Function 2"
default = flip()
endfunc
}

KPKinskyDM3 {
; Written by KPK January 2000
; Basics by Samuel Monnier
; With a part of Dennis Magar's DM3
;
; Revised version 6 August 2000

init:
complex z = pixel
zc = sqr(z/@sizesq)*@sizesq
z = 2*(z - zc)/@sizesq
loop:
IF (imag(z)>0.5)
z = 2*real(z) + flip(2*imag(z)-1)
ELSEIF (real(z)>0.5)
z = 2*real(z)-1 + flip(2*imag(z))
ELSEIF (real(z)>0.1)
z = p1*fn1(sin(1/(z+p1)))
ELSEIF (imag(z)<-0.1)
z = 2*imag(z)+1 + flip(2*real(z))
ELSE
z = 2*real(z) + flip(2*imag(z))
ENDIF

bailout:
(@test == 0 && |z| <= @bailout) ||                                         \
(@test == 1 && sqr(real(z)) <= @bailout) ||                                \
(@test == 2 && sqr(imag(z)) <= @bailout) ||                                \
(@test == 3 && (sqr(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (sqr(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (sqr(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (sqr(real(z) + imag(z)) <= @bailout))

default:
title = "KPKinsky DM3"
center = (0.5, 0.1)
magn = 1.0
maxiter = 500
param power
caption = "Power"
default = (2,0)
endparam
param p1
default=(1,0)
endparam
param sizesq
caption = "Magnification"
default = 0.7
endparam
param bailout
caption = "Bailout"
default = 1e20
endparam
param test
caption = "Shape Modifier"
default = 0
enum = "mod" "real" "imag" "or" "and" "manh" "manr"
endparam
func fn1
caption = "Function 1"
default = acos()
endfunc
}

KPKmultinsky {
;
; Written by KPK January 2000.
;
; Basics by Samuel Monnier.
; The formula contains a part
; of Dennis Magars dm11a formula.
; Thanks, Dennis,
; for this piece of maths.
;
; Revised version 6 August 2000

init:
complex z = pixel
zc = sqr(z/@sizesq)*@sizesq
z = 2*(z - zc)/@sizesq
loop:

IF (imag(z)>0.5)
z = 2*real(z) + fn3(2*imag(z)-1)
ELSEIF (real(z)>0.5)
z = 2*real(z)-1 + fn4(2*imag(z))
ELSEIF (real(z)<0.5)
z=fn1(p1)*fn2(z+p1)-0.1
ELSEIF (imag(z)<-0.1)
z = 2*imag(z)+1 + flip(2*real(z))
ELSE
z = 2*real(z) + flip(2*imag(z))
ENDIF

bailout:
(@test == 0 && |z| <= @bailout) ||                                         \
(@test == 1 && sqr(real(z)) <= @bailout) ||                                \
(@test == 2 && sqr(imag(z)) <= @bailout) ||                                \
(@test == 3 && (sqr(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (sqr(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (sqr(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (sqr(real(z) + imag(z)) <= @bailout))

default:
title = "KPKmultinsky"
center = (0.5, 0.1)
magn = 1.0
maxiter = 500
param power
caption = "Power"
default = (2,0)
endparam
param sizesq
caption = "Magnification"
default = 2
endparam
param bailout
caption = "Bailout"
default = 1e20
endparam
param test
caption = "Shape Modifier"
default = 0
enum = "mod" "real" "imag" "or" "and" "manh" "manr"
endparam
param p1
default=(-0.2,0)
endparam
func fn1
default=cotanh()
endfunc
func fn2
default=sqr()
endfunc
func fn3
default=flip()
endfunc
func fn4
default=flip()
endfunc
}

Pinskyfamilyp {
; From Samuel Monnier's Julifamily
; Modified by KPK January 2000
; Corrected Pinskyfamily formula
; Power param now enabled
;
; Revised version 6 August 2000

init:
complex z = pixel
zc = round(z/@sizesq)*@sizesq
z = 2*(z - zc)/@power
loop:
IF (imag(z)>0.5)
z = 2*real(z) + flip(2*imag(z)-1)
ELSEIF (real(z)>0.5)
z = 2*real(z)-1 + flip(2*imag(z))
ELSE
z = 2*real(z) + flip(2*imag(z))
ENDIF

bailout:
(@test == 0 && |z| <= @bailout) ||                                         \
(@test == 1 && sqr(real(z)) <= @bailout) ||                                \
(@test == 2 && sqr(imag(z)) <= @bailout) ||                                \
(@test == 3 && (sqr(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (sqr(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (sqr(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (sqr(real(z) + imag(z)) <= @bailout))

default:
title = "Pinskyfamily P"
center = (0.4, 0.4)
magn = 1.5
maxiter = 500
param power
caption = "Power"
default = (2,0)
endparam
param sizesq
caption = "Size of the tiles"
default = 0.6
endparam
param bailout
caption = "Bailout"
default = 1e20
endparam
param test
caption = "Shape Modifier"
default = 0
enum = "mod" "real" "imag" "or" "and" "manh" "manr"
endparam

}

sierpinskim-net-familyp {
; Written by KPK January 2000
; Derived from a formula
; written by Luke Plant with
; modifcations from Frederik Slijkerman,
; Marcelo Anelli, Kathy Roth
; Corrected sierpinskim-net-family formula
; Power param now enabled
;
; Revised version 6 August 2000

init:
complex z = 0.2*abs(pixel^3)
zc = round(z/@sizesq)*@sizesq
z = 2*(z - zc)/@power
loop:
IF (imag(z)>@corte)
z = @factor*real(z) + flip(@factor*imag(z)-1)
ELSEIF (real(z)>@corte)
z = @factor*real(z)-1 + flip(@factor*imag(z))
ELSE
z = @factor*real(z) + flip(@factor*imag(z))
z = @fn1( z )
ENDIF

bailout:
(@test == 0 && |z| <= @bailout) ||                                         \
(@test == 1 && sqr(real(z)) <= @bailout) ||                                \
(@test == 2 && sqr(imag(z)) <= @bailout) ||                                \
(@test == 3 && (sqr(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (sqr(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (sqr(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (sqr(real(z) + imag(z)) <= @bailout))

default:
title = "Sierpnetfamily P"
center = (0.4, 0.4)
magn = 1.1538
maxiter = 149
param bailout
caption = "Bailout value"
default = 127
min = 1
endparam
param test
caption = "Shape Modifier"
default = 0
enum = "mod" "real" "imag" "or" "and" "manh" "manr"
endparam
param factor
caption = "Factor Transformation"
default = 2.0
endparam
param corte
caption = "Cutting edges"
default = 0.5
endparam
param power
caption = "Power"
default = (2,0)
endparam
param sizesq
caption = "Size of the tiles"
default = 0.4
endparam

func fn1
caption = "Function applied"
default = ident()
endfunc
switch:
type = "sierpinskij"
c = #pixel
factor = factor
bailout = bailout
corte = corte
fn1 = fn1
}

KPKinskyiip {
; Written by KPK January 2000
; Adapted from formulas by Samuel Monnier
; and Luke Plant
; Corrected KPKinsky II formula
; Power param now enabled
;
; Revised version 6 August 2000

init:
complex z = pixel
zc = sqr(z/@sizesq)*@sizesq
z = 2*(z - zc)/@power
loop:
IF (imag(z)>0.5)
z = 2*real(z) + flip(2*imag(z)-1)
ELSEIF (real(z)>0.5)
z = 2*real(z)-1 + flip(2*imag(z))
ELSE
z = 2*real(z) + flip(2*imag(z))
ENDIF

bailout:
(@test == 0 && |z| <= @bailout) ||                                         \
(@test == 1 && sqr(real(z)) <= @bailout) ||                                \
(@test == 2 && sqr(imag(z)) <= @bailout) ||                                \
(@test == 3 && (sqr(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (sqr(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (sqr(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (sqr(real(z) + imag(z)) <= @bailout))

default:
title = "KPKinsky II P"
center = (0.5, 0.1)
magn = 1.0
maxiter = 500
param power
caption = "Power"
default = (2,0)
endparam
param sizesq
caption = "Size of the tiles"
default = 0.7
endparam
param bailout
caption = "Bailout"
default = 1e20
endparam
param test
caption = "Shape Modifier"
default = 0
enum = "mod" "real" "imag" "or" "and" "manh" "manr"
endparam

}

KPKinskyiiip {
; Written by KPK January 2000
; Adapted from formulas by Samuel Monnier
; and Luke Plant
; Corrected KPKinsky III formula
; Power param now enabled
;
; Revised version 6 August 2000

init:
complex z = pixel
zc = floor(z/@power)*@sizesq
z = 2*(z - (0.25*zc))/(0.5*@sizesq)
loop:
IF (imag(z)>0.5)
z = 2*real(z) + flip(2*imag(z)-1)
ELSEIF (real(z)>0.5)
z = 2*real(z)-1 + flip(2*imag(z))
ELSE
z = 2*real(z) + flip(2*imag(z))
ENDIF

bailout:
(@test == 0 && |z| <= @bailout) ||                                         \
(@test == 1 && sqr(real(z)) <= @bailout) ||                                \
(@test == 2 && sqr(imag(z)) <= @bailout) ||                                \
(@test == 3 && (sqr(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (sqr(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (sqr(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (sqr(real(z) + imag(z)) <= @bailout))

default:
title = "KPKinsky III P"
center = (0.5, 0.1)
magn = 1.5
maxiter = 500
param power
caption = "Power"
default = (2,0)
endparam
param sizesq
caption = "Size of the tiles"
default = 0.7
endparam
param bailout
caption = "Bailout"
default = 1e20
endparam
param test
caption = "Shape Modifier"
default = 0
enum = "mod" "real" "imag" "or" "and" "manh" "manr"
endparam

}

KPKinskyivp {
; Written by KPK January 2000
; Adapted from formulas by Samuel Monnier
; and Luke Plant
; Corrected KPKinsky IV formula
;
; Revised version 6 August 2000

init:
complex z = pixel
zc = sqr(z/@sizesq)*@sizesq
z = 2*(z - zc)/@power
loop:
IF (imag(z)>0.5)
z = 2*real(z) + flip(2*imag(z)-1)
ELSEIF (real(z)>0.5)
z = 2*real(z)-1 + flip(2*imag(z))
ELSEIF (imag(z)<-0.1)
z = 2*imag(z)+1 + flip(2*real(z))
ELSE
z = 2*real(z) + flip(2*imag(z))
ENDIF

bailout:
(@test == 0 && |z| <= @bailout) ||                                         \
(@test == 1 && sqr(real(z)) <= @bailout) ||                                \
(@test == 2 && sqr(imag(z)) <= @bailout) ||                                \
(@test == 3 && (sqr(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (sqr(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (sqr(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (sqr(real(z) + imag(z)) <= @bailout))

default:
title = "KPKinsky IV P"
center = (0.5, 0.1)
magn = 1.0
maxiter = 500
param power
caption = "Power"
default = (2,0)
endparam
param sizesq
caption = "Size of the tiles"
default = 0.7
endparam
param bailout
caption = "Bailout"
default = 1e20
endparam
param test
caption = "Shape Modifier"
default = 0
enum = "mod" "real" "imag" "or" "and" "manh" "manr"
endparam

}

; From Samuel Monnier's Julifamily
; Modified by KPK January 2000
; Power param now enabled
;
; Revised version 6 August 2000

init:
complex z = pixel
zc = round(z/@sizesq)*@sizesq
z = 2*(z - zc)/@power
loop:
IF (imag(z)>0.5)
z = 2*real(z) + flip(2*imag(z)-1)
ELSEIF (real(z)>0.5)
z = 2*real(z)-1 + flip(2*imag(z))
ELSEIF (imag(z)<0.5)
z = 2*imag(z)+1 + ident(2*real(z))
ELSE
z = 2*real(z) + flip(2*imag(z))
ENDIF

bailout:
(@test == 0 && |z| <= @bailout) ||                                         \
(@test == 1 && sqr(real(z)) <= @bailout) ||                                \
(@test == 2 && sqr(imag(z)) <= @bailout) ||                                \
(@test == 3 && (sqr(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (sqr(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (sqr(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (sqr(real(z) + imag(z)) <= @bailout))

default:
center = (0.4, 0.4)
magn = 1.5
maxiter = 500
param power
caption = "Power"
default = (2,0)
endparam
param sizesq
caption = "Size of the tiles"
default = 0.6
endparam
param bailout
caption = "Bailout"
default = 1e20
endparam
param test
caption = "Shape Modifier"
default = 0
enum = "mod" "real" "imag" "or" "and" "manh" "manr"
endparam

}

PinskyfamilyIIp {
; From Samuel Monnier's Julifamily
; Modified by KPK January 2000
; Corrected Pinskyfamily II formula
; Power param now enabled
;
; Revised version 6 August 2000

init:
complex z = pixel
zc = round(z/@sizesq)*@sizesq
z = 2*(z - zc)/@power
loop:
IF (imag(z)>0.5)
z = 2*real(z) + flip(2*imag(z)-1)
ELSEIF (real(z)>0.5)
z = 2*real(z)-1 + flip(2*imag(z))
ELSEIF (imag(z)<0.5)
z = 2*imag(z)+1 + flip(2*real(z))
ELSE
z = 2*real(z) + flip(2*imag(z))
ENDIF

bailout:
(@test == 0 && |z| <= @bailout) ||                                         \
(@test == 1 && sqr(real(z)) <= @bailout) ||                                \
(@test == 2 && sqr(imag(z)) <= @bailout) ||                                \
(@test == 3 && (sqr(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (sqr(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (sqr(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (sqr(real(z) + imag(z)) <= @bailout))

default:
title = "Pinskyfamily II P"
center = (0.4, 0.4)
magn = 1.5
maxiter = 500
param power
caption = "Power"
default = (2,0)
endparam
param sizesq
caption = "Size of the tiles"
default = 0.6
endparam
param bailout
caption = "Bailout"
default = 1e20
endparam
param test
caption = "Shape Modifier"
default = 0
enum = "mod" "real" "imag" "or" "and" "manh" "manr"
endparam

}

Funcinskyp {
; Formula by KPK January 2000
; Basics from Samuel Monnier
; Corrected Funcinsky formula
; Power param now enabled
;
; Revised version 6 August 2000

init:
complex z = pixel
zc = round(z/@sizesq)*@sizesq
z = 2*(z - zc)/@power
loop:
IF (imag(z)>0.5)
z = 2*real(z) + flip(2*imag(z)-1)
ELSEIF (real(z)>0.5)
z = 2*real(z)-1 + flip(2*imag(z))
ELSEIF (real(z)<0.1)
z = 2*fn1(z)-1 + flip(2*imag(z))
ELSE
z = 2*fn2(z) + flip(2*imag(z))
ENDIF

bailout:
(@test == 0 && |z| <= @bailout) ||                                         \
(@test == 1 && sqr(real(z)) <= @bailout) ||                                \
(@test == 2 && sqr(imag(z)) <= @bailout) ||                                \
(@test == 3 && (sqr(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (sqr(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (sqr(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (sqr(real(z) + imag(z)) <= @bailout))

default:
title = "Funcinsky P"
center = (0.4, 0.4)
magn = 1.5
maxiter = 500
param power
caption = "Power"
default = (2,0)
endparam
param sizesq
caption = "Magnification"
default = 1
endparam
param bailout
caption = "Bailout"
default = 1e20
endparam
param test
caption = "Shape Modifier"
default = 0
enum = "mod" "real" "imag" "or" "and" "manh" "manr"
endparam
func fn1
caption = "Function 1"
default = sin()
endfunc
func fn2
caption = "Function 2"
default = abs()
endfunc
}

Dalinskyp {
; Formula by KPK January 2000
; Basics from Samuel Monnier
; Corrected Dalinsky formula
; Power param now enabled
;
; Revised version 6 August 2000

init:
complex z = pixel
zc = atan(z/@sizesq)*@sizesq
z = 2*(z - zc)/@power
loop:
IF (imag(z)>0.5)
z = 2*real(z) + flip(2*imag(z)-1)
ELSEIF (real(z)>0.5)
z = 2*real(z)-1 + flip(2*imag(z))
ELSEIF (real(z)<0.1)
z = 2*fn1(z)-1 + flip(2*imag(z))
ELSE
z = 2*fn2(z) + flip(2*imag(z))
ENDIF

bailout:
(@test == 0 && |z| <= @bailout) ||                                         \
(@test == 1 && sqr(real(z)) <= @bailout) ||                                \
(@test == 2 && sqr(imag(z)) <= @bailout) ||                                \
(@test == 3 && (sqr(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (sqr(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (sqr(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (sqr(real(z) + imag(z)) <= @bailout))

default:
title = "Dalinsky P"
center = (0.4, 0.1)
magn = 1.5
maxiter = 500
param power
caption = "Power"
default = (2,0)
endparam
param sizesq
caption = "Magnification"
default = 0.5
endparam
param bailout
caption = "Bailout"
default = 1e20
endparam
param test
caption = "Shape Modifier"
default = 0
enum = "mod" "real" "imag" "or" "and" "manh" "manr"
endparam

func fn1
caption = "Function 1"
default = ident()
endfunc
func fn2
caption = "Function 2"
default = flip()
endfunc
}

KPKinskyDM3p {
; Written by KPK January 2000
; Basics by Samuel Monnier
; With a part of Dennis Magar's DM3
; Corrected KPKinsky DM3 formula
; Power param now enabled
;
; Revised version 6 August 2000

init:
complex z = pixel
zc = sqr(z/@sizesq)*@sizesq
z = 2*(z - zc)/@power
loop:
IF (imag(z)>0.5)
z = 2*real(z) + flip(2*imag(z)-1)
ELSEIF (real(z)>0.5)
z = 2*real(z)-1 + flip(2*imag(z))
ELSEIF (real(z)>0.1)
z = p1*fn1(sin(1/(z+p1)))
ELSEIF (imag(z)<-0.1)
z = 2*imag(z)+1 + flip(2*real(z))
ELSE
z = 2*real(z) + flip(2*imag(z))
ENDIF

bailout:
(@test == 0 && |z| <= @bailout) ||                                         \
(@test == 1 && sqr(real(z)) <= @bailout) ||                                \
(@test == 2 && sqr(imag(z)) <= @bailout) ||                                \
(@test == 3 && (sqr(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (sqr(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (sqr(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (sqr(real(z) + imag(z)) <= @bailout))

default:
title = "KPKinsky DM3 P"
center = (0.5, 0.1)
magn = 1.0
maxiter = 500
param power
caption = "Power"
default = (2,0)
endparam
param p1
default=(1,0)
endparam
param sizesq
caption = "Magnification"
default = 0.7
endparam
param bailout
caption = "Bailout"
default = 1e20
endparam
param test
caption = "Shape Modifier"
default = 0
enum = "mod" "real" "imag" "or" "and" "manh" "manr"
endparam
func fn1
caption = "Function 1"
default = acos()
endfunc
}

KPKmultinskyp {
;
; Written by KPK January 2000.
;
; Basics by Samuel Monnier.
; The formula contains a part
; of Dennis Magars dm11a formula.
; Thanks, Dennis,
; for this piece of maths.
; Corrected KPKmultinsky formula.
; Power param now enabled.
;
; Revised version 6 August 2000

init:
complex z = pixel
zc = sqr(z/@sizesq)*@sizesq
z = 2*(z - zc)/@power
loop:

IF (imag(z)>0.5)
z = 2*real(z) + fn3(2*imag(z)-1)
ELSEIF (real(z)>0.5)
z = 2*real(z)-1 + fn4(2*imag(z))
ELSEIF (real(z)<0.5)
z=fn1(p1)*fn2(z+p1)-0.1
ELSEIF (imag(z)<-0.1)
z = 2*imag(z)+1 + flip(2*real(z))
ELSE
z = 2*real(z) + flip(2*imag(z))
ENDIF

bailout:
(@test == 0 && |z| <= @bailout) ||                                         \
(@test == 1 && sqr(real(z)) <= @bailout) ||                                \
(@test == 2 && sqr(imag(z)) <= @bailout) ||                                \
(@test == 3 && (sqr(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (sqr(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (sqr(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (sqr(real(z) + imag(z)) <= @bailout))

default:
title = "KPKmultinsky P"
center = (0.5, 0.1)
magn = 1.0
maxiter = 500
param power
caption = "Power"
default = (2,0)
endparam
param sizesq
caption = "Magnification"
default = 2
endparam
param bailout
caption = "Bailout"
default = 1e20
endparam
param test
caption = "Shape Modifier"
default = 0
enum = "mod" "real" "imag" "or" "and" "manh" "manr"
endparam
param p1
default=(-0.2,0)
endparam
func fn1
default=cotanh()
endfunc
func fn2
default=sqr()
endfunc
func fn3
default=flip()
endfunc
func fn4
default=flip()
endfunc
}

sierpinskim-net {
; Written by KPK January, 2000
; After a formula by Luke Plant
;
; Revised version 6 August 2000

init:
complex z = 0.2*abs(pixel^@spokes)

loop:
IF (imag(z)>@corte)
z = @factor*real(z) + flip(@factor*imag(z)-1)
ELSEIF (real(z)>@corte)
z = @factor*real(z)-1 + flip(@factor*imag(z))
ELSE
z = @factor*real(z) + flip(@factor*imag(z))
z = @fn1( z )
ENDIF

bailout:
(@test == 0 && |z| <= @bailout) ||                                         \
(@test == 1 && sqr(real(z)) <= @bailout) ||                                \
(@test == 2 && sqr(imag(z)) <= @bailout) ||                                \
(@test == 3 && (sqr(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (sqr(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (sqr(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (sqr(real(z) + imag(z)) <= @bailout))

default:
title = "Sierpinsky Net I"
center = (0.4, 0.4)
magn = 1.1538
maxiter = 149
param bailout
caption = "Bailout value"
default = 127
min = 1
endparam
param test
caption = "Shape Modifier"
default = 0
enum = "mod" "real" "imag" "or" "and" "manh" "manr"
endparam
param factor
caption = "Factor Transformation"
default = 2.0
endparam
param spokes
caption = "Increases No. of Spokes"
default = 3
endparam
param corte
caption = "Cutting edges"
default = 0.5
endparam
func fn1
caption = "Function applied"
default = ident()
endfunc
switch:
type = "sierpinskij"
c = #pixel
factor = factor
bailout = bailout
corte = corte
fn1 = fn1
}

donquixote {
; Written by KPK January, 2000
;
; Revised version 6 August 2000

init:
complex z = 0.2*fn1(pixel^@spokes)

loop:
IF (imag(z)>@corte)
z = @factor*real(z) + flip(@factor*imag(z)-1)
ELSEIF (real(z)>@corte)
z = @factor*real(z)-1 + flip(@factor*imag(z))
ELSE
z = @factor*real(z) + flip(@factor*imag(z))
z = @fn2( z )
ENDIF

bailout:
(@test == 0 && |z| <= @bailout) ||                                         \
(@test == 1 && sqr(real(z)) <= @bailout) ||                                \
(@test == 2 && sqr(imag(z)) <= @bailout) ||                                \
(@test == 3 && (sqr(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (sqr(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (sqr(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (sqr(real(z) + imag(z)) <= @bailout))

default:
title = "Don Quixote"
center = (0.2, 0.4)
magn = 1.112
maxiter = 149
param bailout
caption = "Bailout value"
default = 127
min = 1
endparam
param test
caption = "Shape Modifier"
default = 0
enum = "mod" "real" "imag" "or" "and" "manh" "manr"
endparam
param factor
caption = "Factor Transformation"
default = 2.0
endparam
param spokes
caption = "Number of Spokes"
default = 4
endparam
param corte
caption = "Cutting edges"
default = 0.5
endparam
func fn2
caption = "Function 2"
default = ident()
endfunc
func fn1
caption = "Function 1"
default = sqrt()
hint = "Shape of the wings"
endfunc
}

donquixotenos {
; Written by KPK January, 2000
;
; Revised version 6 August 2000

init:
complex z = 0.3*fn1(pixel^@spokes)

loop:
IF (imag(z)>@corte)
z = @factor*real(z) + flip(@factor*imag(z)-1)
ELSEIF (imag(z)>@corte)
z = @factor*real(z)-1 + flip(@factor*imag(z))
ELSE
z = @factor*real(z) + flip(@factor*imag(z))
z = @fn2( z )
ENDIF

bailout:
(@test == 0 && |z| <= @bailout) ||                                         \
(@test == 1 && sqr(real(z)) <= @bailout) ||                                \
(@test == 2 && sqr(imag(z)) <= @bailout) ||                                \
(@test == 3 && (sqr(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (sqr(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (sqr(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (sqr(real(z) + imag(z)) <= @bailout))

default:
title = "Don Quixote NoS"
center = (0.2, 0.4)
magn = 1.112
maxiter = 149
param bailout
caption = "Bailout value"
default = 127
min = 1
endparam
param test
caption = "Shape Modifier"
default = 0
enum = "mod" "real" "imag" "or" "and" "manh" "manr"
endparam
param factor
caption = "Factor Transformation"
default = 2.0
endparam
param spokes
caption = "Spokes Variation"
default = 4
endparam
param corte
caption = "Cutting edges"
default = 0.5
endparam
func fn1
caption = "Function 1"
default = acosh()
endfunc
func fn2
caption = "Function 2"
default = ident()
endfunc
}

sierpinskim-mill {
; Written by KPK January, 2000
; After a formula by Luke Plant
;
; Revised version 6 August 2000

init:
complex z = 0.3*exp(pixel^@spokes)

loop:
IF (imag(z)>@corte)
z = @factor*real(z) + flip(@factor*imag(z)-1)
ELSEIF (real(z)>@corte)
z = @factor*real(z)-1 + flip(@factor*imag(z))
ELSE
z = @factor*real(z) + flip(@factor*imag(z))
z = @fn1( z )
ENDIF

bailout:
(@test == 0 && |z| <= @bailout) ||                                         \
(@test == 1 && sqr(real(z)) <= @bailout) ||                                \
(@test == 2 && sqr(imag(z)) <= @bailout) ||                                \
(@test == 3 && (sqr(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (sqr(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (sqr(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (sqr(real(z) + imag(z)) <= @bailout))

default:
title = "Sierpinsky Windmill I"
center = (0.4, 0.4)
magn = 1.1538
maxiter = 149
param bailout
caption = "Bailout value"
default = 127
min = 1
endparam
param test
caption = "Shape Modifier"
default = 0
enum = "mod" "real" "imag" "or" "and" "manh" "manr"
endparam
param factor
caption = "Factor Transformation"
default = 2.0
endparam
param spokes
caption = "Number of Spokes"
default = 5
endparam
param corte
caption = "Cutting edges"
default = 0.5
endparam
func fn1
caption = "Function applied"
default = ident()
endfunc
switch:
type = "sierpinskij"
c = #pixel
factor = factor
bailout = bailout
corte = corte
fn1 = fn1
}

donquixoteld {
; Written by KPK January, 2000
; With a tiny part of the
; Joukowskij Function by
; Andreas Lober
;
; To get a radial shape
; of the image enable the
;
; For a Mandelbrot, set fn3
; to sin
;
; Revised version 6 August 2000

init:
complex z = 0.2*fn1(pixel^@spokes)

loop:
IF (imag(z)>@corte)
z = @factor*real(z) + flip(@factor*imag(z)-1)
ELSEIF (real(z)>@corte)
z = @factor*real(z)-1 + flip(@factor*imag(z))
ELSE
z = @factor*real(z) + flip(@factor*imag(z))
z = @fn2( z )
ENDIF

IF (@pure)
z = fn3(z^@exponent)-1
ELSE
z = fn3(z^@exponent) + #pixel
ENDIF

bailout:
(@test == 0 && |z| <= @bailout) ||                                         \
(@test == 1 && sqr(real(z)) <= @bailout) ||                                \
(@test == 2 && sqr(imag(z)) <= @bailout) ||                                \
(@test == 3 && (sqr(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (sqr(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (sqr(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (sqr(real(z) + imag(z)) <= @bailout))

default:
title = "Don Quixote LD"
center = (0.2, 0.2)
magn = 1.112
maxiter = 149
param bailout
caption = "Bailout value"
default = 127
min = 1
endparam
param test
caption = "Shape Modifier"
default = 0
enum = "mod" "real" "imag" "or" "and" "manh" "manr"
endparam
param factor
caption = "Factor Transformation"
default = 2.0
endparam
param spokes
caption = "Number of Spokes"
default = 4
endparam
param exponent
caption = "Lober Distortion"
default = 2.0
endparam
param pure
default =FALSE
hint = "Enable for Radial Shape"
endparam
param corte
caption = "Cutting edges"
default = 0.5
endparam
func fn1
caption = "Function 1"
default = sqrt()
endfunc
func fn2
caption = "Function 2"
default = ident()
hint = "Shape of the wings"
endfunc
func fn3
caption = "Function 3"
default = sqrt()
endfunc
}

KPKinskyfederal {
; Written by KPK January 2000
;
; Revised version 6 August 2000

init:
complex z = pixel
complex p = @parameter
zc = fn3(z/@sizesq)*@sizesq
z = 2*(z - zc)/@power
loop:
IF (imag(z)>0.5)
z = 2*real(z) + flip(2*imag(z)-1)
ELSEIF (real(z)>0.5)
z = 2*real(z)-1 + flip(2*imag(z))
ELSEIF (real(z)>0.1)
z = p1*fn1(sin(1/(z+p1)))
ELSEIF (imag(z)<-0.1)
z = 2*imag(z)+1 + flip(2*real(z))
ELSE
z = fn2(((z^2+p+1)/(3*z+p-1))^2) + #pixel/0.3
ENDIF

bailout:
(@test == 0 && |z| <= @bailout) ||                                         \
(@test == 1 && sqr(real(z)) <= @bailout) ||                                \
(@test == 2 && sqr(imag(z)) <= @bailout) ||                                \
(@test == 3 && (sqr(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (sqr(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (sqr(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (sqr(real(z) + imag(z)) <= @bailout))

default:
title = "KPKinsky Federal"
center = (0.5, 0.1)
magn = 0.6
maxiter = 500
param power
caption = "Power"
default = (2,0)
endparam
param p1
default=(1,0)
endparam
param parameter
caption = "Federal Parameter"
default = (1.7,1.7)
endparam
param sizesq
caption = "Magnification"
default = 0.7
endparam
param bailout
caption = "Bailout"
default = 1e20
endparam
param test
caption = "Shape Modifier"
default = 0
enum = "mod" "real" "imag" "or" "and" "manh" "manr"
endparam
func fn1
caption = "Function 1"
default = acos()
endfunc
func fn2
caption = "Function 2"
default = exp()
endfunc
func fn3
caption = "Function 3"
default = tan()
endfunc
}

KPKinskyrune {
; Written by KPK January, 2000
;
; Revision January 28, 2000
;
; Set param Separation
; Factor to 0 and Spokes to
; 4 for a windmill effect
;
; Param Structure added January 27, 2000
;
; Revised version 6 August 2000

init:
complex z = pixel^@spokes
zc = fn1(z/@sizesq)*@sizesq
z = 2*(z - zc)+@devide/@power
loop:
IF (imag(z)>0.5)
z = 2*real(z) + flip(2*imag(z)-1)
ELSEIF (real(z)>0.5)
z = 2*real(z)-1 + flip(2*imag(z))
ELSEIF (imag(z)<-0.1)
z = 2*imag(z)+1 + flip(2*real(z))
ELSEIF (real(z)>0.1)
z = fn2(imag(z^@structure1)) * fn3(fn4(z^@structure2))
ELSE
z = 2*real(z) + flip(2*imag(z))
ENDIF

bailout:
(@test == 0 && |z| <= @bailout) ||                                         \
(@test == 1 && sqr(real(z)) <= @bailout) ||                                \
(@test == 2 && sqr(imag(z)) <= @bailout) ||                                \
(@test == 3 && (sqr(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (sqr(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (sqr(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (sqr(real(z) + imag(z)) <= @bailout))

default:
title = "KPKinsky Rune"
center = (0.4, 0.2)
magn = 1.0
maxiter = 500
periodicity = 0
param devide
caption = "Separation Factor"
default = 1
endparam
param power
caption = "Power"
default = (2,4)
endparam
param spokes
caption = "Spokes"
default = 4
endparam
param sizesq
caption = "Magnification"
default = 0.7
endparam
param bailout
caption = "Bailout"
default = 1e20
endparam
param test
caption = "Shape Modifier"
default = 0
enum = "mod" "real" "imag" "or" "and" "manh" "manr"
endparam
param structure1
caption = "Structure 1"
default = 2
endparam
param structure2
caption = "Structure 2"
default = 2
endparam
func fn1
caption = "Function 1"
default = sqr()
endfunc
func fn2
caption = "Function 2"
default = sin()
endfunc
func fn3
caption = "Function 3"
default = cos()
endfunc
func fn4
caption = "Function 4"
default = sin()
endfunc

}

KPKinskyar {
; Written by KPK January, 2000
;
; Version January, 28
;
; Parameter Wizzle Shape: use
; negative values for inverse
; effect
;
; Revised version 6 August 2000

init:
complex z = 0.3*fn1(pixel^@wizzle)
zc = fn2(z/@wizzle)*@sizesq
z = 2*(z - zc)+@devide/@power

loop:
IF (imag(z)>0.5)
z = 2*real(z) + flip(2*imag(z)-1)
ELSEIF (real(z)>0.5)
z = 2*real(z)-1 + flip(2*imag(z))
ELSEIF (imag(z)<-0.1)
z = 2*imag(z)+1 + flip(2*real(z))
ELSEIF (real(z)>0.1)
z = fn3(imag(z^@structure1)) * fn4(sin(z^@structure2))
ELSE
z = 2*real(z) + flip(2*imag(z))
ENDIF

bailout:
(@test == 0 && |z| <= @bailout) ||                                         \
(@test == 1 && sqr(real(z)) <= @bailout) ||                                \
(@test == 2 && sqr(imag(z)) <= @bailout) ||                                \
(@test == 3 && (sqr(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (sqr(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (sqr(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (sqr(real(z) + imag(z)) <= @bailout))

default:
center = (0.4, 0.2)
magn = 1.0
maxiter = 500
periodicity = 0
param devide
caption = "Separation Factor"
default = 1
endparam
param power
caption = "Power"
default = (0,4)
endparam
param wizzle
caption = "Wizzle Shape"
default = 4
endparam
param sizesq
caption = "Magnification"
default = 0.7
endparam
param bailout
caption = "Bailout"
default = 1e20
endparam
param test
caption = "Shape Modifier"
default = 0
enum = "mod" "real" "imag" "or" "and" "manh" "manr"
endparam
param structure1
caption = "Structure 1"
default = 2
endparam
param structure2
caption = "Structure 2"
default = 2
endparam
func fn1
caption = "Function 1"
default = abs()
endfunc
func fn2
caption = "Function 2"
default = sqr()
endfunc
func fn3
caption = "Function 3"
default = sin()
endfunc
func fn4
caption = "Function 4"
default = cos()
endfunc
}

; Written by KPK January, 2000
;
; Revised version 6 August 2000

init:
complex z = 0.3*fn1(pixel^@spokes)
zc = fn2(z/@spokes)*@mag
z = 2*(z - zc)+@devide/@power

loop:
IF (imag(z)>0.5)
z = 2*real(z) + fn3(2*imag(z)-1)
ELSEIF (real(z)>0.5)
z = 2*real(z)-1 + fn4(2*imag(z))
ELSEIF (imag(z)<-0.1)
z = 2*imag(z)+1 + flip(2*real(z))
ELSEIF (real(z)>0.1)
z = sin(imag(z^zc)) * cos(sin(z^z))
ELSE
z = 2*real(z) + flip(2*imag(z))
ENDIF

z = fn1(z^@structure1) + flip(imag(z))-1
ELSE
z = sin(z^@spokes)
ENDIF

bailout:
(@test == 0 && |z| <= @bailout) ||                                         \
(@test == 1 && sqr(real(z)) <= @bailout) ||                                \
(@test == 2 && sqr(imag(z)) <= @bailout) ||                                \
(@test == 3 && (sqr(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (sqr(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (sqr(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (sqr(real(z) + imag(z)) <= @bailout))

default:
center = (0.4, 0.2)
magn = 1.0
maxiter = 500
periodicity = 0
param devide
caption = "Separation Factor"
default = 1
endparam
param power
caption = "Power"
default = (0,4)
endparam
param spokes
caption = "No. of Spokes x 2"
default = 2
endparam
default = true
hint = "Enable for Radial Shape"
endparam
param mag
caption = "Magnification"
default = 0.7
endparam
param bailout
caption = "Bailout"
default = 1e20
endparam
param test
caption = "Shape Modifier"
default = 0
enum = "mod" "real" "imag" "or" "and" "manh" "manr"
endparam
param structure1
caption = "Structure 1"
default = 2
endparam
func fn1
caption = "Function 1"
default = abs()
endfunc
func fn2
caption = "Function 2"
default = sqr()
endfunc
func fn3
caption = "Function 3"
default = flip()
endfunc
func fn4
caption = "Function 4"
default = flip()
endfunc
}

KPKinskylr {
; Written by KPK January, 2000
;
; Version January, 31
;
; Tweaked lattice factor integrated
; with kind permission of
; Andreas Lober
;
; To get a Sierpinsky like
; structure set param Lober Type
; to none
;
; You can choose positive or negative
; values for real or imaginary part
; of the Lober Factor
;
; Revised version 6 August 2000

init:
complex z = 0.3*fn1(pixel^@spokes)
zc = fn2(z/@spokes)*@sizesq
z = 2*(z - zc)+@devide/@power

loop:
IF (imag(z)>0.5)
z = 2*real(z) + flip(2*imag(z)-1)
ELSEIF (real(z)>0.5)
z = 2*real(z)-1 + flip(2*imag(z))
ELSEIF (imag(z)<-0.1)
z = 2*imag(z)+1 + flip(2*real(z))
ELSEIF (real(z)>0.1)
z = fn3(imag(z^@structure1)) * fn4(sin(z^@structure2))
ELSE
z = 2*real(z) + flip(2*imag(z))
ENDIF

if     (@lober == 1)
z = round(@lob1*z) - @lob2*z
elseif (@lober == 2)
z = trunc(@lob1*z) - @lob2*z
elseif (@lober == 3)
z = floor(@lob1*z) - @lob2*z
elseif (@lober == 4)
z = ceil(@lob1*z)  - @lob2*z
elseif (@lober == 5)
z = abs(@lob1*z)   - @lob2*z^2
elseif (@lober == 6)
z = round(@lob1*z) - @lob2*sqrt(real(z)*imag(z))
elseif (@lober == 7)
z = trunc(@lob1*z) - @lob2*sqrt(real(z)*imag(z))
elseif (@lober == 8)
z = floor(@lob1*z) - @lob2*sqrt(real(z)*imag(z))
elseif (@lober == 9)
z = ceil(@lob1*z)  - @lob2*sqr(real(z)*imag(z))
elseif (@lober == 10)
z = abs(@lob1*z)   - @lob2*sqr(real(z)*imag(z))
elseif (@lober == 11)
z = round ((round(@lob1*z) - @lob1*z)^2) - @lob2*z^2
endif

bailout:
(@test == 0 && |z| <= @bailout) ||                                         \
(@test == 1 && sqr(real(z)) <= @bailout) ||                                \
(@test == 2 && sqr(imag(z)) <= @bailout) ||                                \
(@test == 3 && (sqr(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (sqr(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (sqr(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (sqr(real(z) + imag(z)) <= @bailout))

default:
title = "KPKinsky Lober Rune"
center = (0.4, 0.2)
magn = 1.0
maxiter = 500
periodicity = 0

param devide
caption = "Separation Factor"
default = 0
endparam

param power
caption = "Power"
default = (0,4)
endparam

param spokes
caption = "Spokes x 2"
default = 4
endparam

param sizesq
caption = "Magnification"
default = 0.7
endparam

param bailout
caption = "Bailout"
default = 1e20
endparam

param test
caption = "Shape Modifier"
default = 0
enum = "mod" "real" "imag" "or" "and" "manh" "manr"
endparam

param structure1
caption = "Structure 1"
default = 2
endparam

param structure2
caption = "Structure 2"
default = 2
endparam

param lober
caption = "Lober Type"
enum = "None" "round" "trunc" "floor" "ceil" "abs"
default = 2
endparam

param lob1
caption = "Lober Factor 1"
default = (4.0,1.0)
endparam

param lob2
caption = "Lober Factor 2"
default = (1.0,0.0)
endparam

func fn1
caption = "Function 1"
default = abs()
endfunc

func fn2
caption = "Function 2"
default = sqr()
endfunc

func fn3
caption = "Function 3"
default = sin()
endfunc

func fn4
caption = "Function 4"
default = cos()
endfunc
}

KPKandinsky {
;
; Written by KPK February, 2000
;
; For Mikko
;
; Revision February, 7
;
; Special loop sequence after
; an idea of Andreas Lober
;
; To get Sierpinsky triangle like
; structures set param Kandinsky Type
; to none and Sierp Factor to 1
;
; Choose positive or negative
; values for real and/or imaginary part
; of the Kandinsky Factor
;
; For a radial shape set Kandinsky
; Type to none and Function 1 to abs
;
; NOTE: The six additional functions only
; work together with their identical named
; Kandinsky Type parameter counterparts.
; Be aware of the correct spelling of the
; parameter and function names otherwise the
; combination will show no effect!
;
; Revised version 6 August 2000

init:
complex z = 0.3*fn1(pixel^@spokes)
zc = fn2(z/@spokes)*@sizesq
z = 2*(z - zc)+@devide/@power

loop:
IF (imag(z)>0.5)
z = 2*z - 1i
ELSEIF (real(z)>0.5)
z = 2*z - 1
ELSEIF (real(z)>0.1)
z = fn3(imag(z^@structure1)) * fn4(sin(z^@structure2))
ELSE
z = (2*z)*@rot
ENDIF

IF  (@kan == 1)
z = round(@kan1*z) - @kan2*z
ELSEIF (@kan == 2)
z = trunc(@kan1*z) - @kan2*z
ELSEIF (@kan == 3)
z = floor(@kan1*z) - @kan2*z
ELSEIF (@kan == 4)
z = ceil(@kan1*z)  - @kan2*z
ELSEIF (@kan == 5)
z = abs(@kan1*z)   - @kan2*z^2
ELSEIF (@kan == 6)
ELSEIF (@kan == 7)
ELSEIF (@kan == 8)
ELSEIF (@kan == 9)
ELSEIF (@kan == 10)
ELSEIF (@kan == 11)
z = round ((@adFunc6(@kan1*z) - @kan1*z)^3) - @kan2*z^3
ENDIF

bailout:
(@test == 0 && |z| <= @bailout) ||                                         \
(@test == 1 && sqr(real(z)) <= @bailout) ||                                \
(@test == 2 && sqr(imag(z)) <= @bailout) ||                                \
(@test == 3 && (sqr(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (sqr(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (sqr(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (sqr(real(z) + imag(z)) <= @bailout))

default:
title = "KPKandinsky"
center = (0.4, 0.2)
magn = 1.0
maxiter = 500
periodicity = 0

param devide
caption = "Separation Factor"
default = 0
endparam

param rot
caption = "Sierp Factor"
default = 4.0
endparam

param power
caption = "Power"
default = (0,4)
endparam

param spokes
caption = "Spokes (x 2)"
default = 2
endparam

param sizesq
caption = "Magnification"
default = 0.7
endparam

param bailout
caption = "Bailout"
default = 1e20
endparam

param test
caption = "Shape Modifier"
default = 0
enum = "mod" "real" "imag" "or" "and" "manh" "manr"
endparam

param structure1
caption = "Structure 1"
default = 1.0
endparam

param structure2
caption = "Structure 2"
default = 2.0
endparam

param kan
caption = "Kandinsky Type"
enum = "None" "round" "trunc" "floor" "ceil" "abs" \
"a-round" "a-trunc" "a-floor" "a-ceil" "a-abs" "b-round"
default = 1
endparam

param kan1
caption = "Kandinsky Fact. a"
default = (1.0,1.0)
endparam

param kan2
caption = "Kandinsky Fact. b"
default = (1.0,0.0)
endparam

func fn1
caption = "Function 1"
default = sqrt()
hint = "For radial shape choose abs"
endfunc

func fn2
caption = "Function 2"
default = ident()
endfunc

func fn3
caption = "Function 3"
default = tan()
endfunc

func fn4
caption = "Function 4"
default = cos()
endfunc

caption = "For Type a-round"
default = sqrt()
endfunc

caption = "For Type a-trunc"
default = sqrt()
endfunc

caption = "For Type a-floor"
default = sqrt()
endfunc

caption = "For Type a-ceil"
default = sqr()
endfunc

caption = "For Type a-abs"
default = sqr()
endfunc

caption = "For Type b-round"
default = round()
endfunc

}

KPKmondrinsky {
;
; Written by KPK February, 2000
;
; For Richard
;
; Version February, 10
;
; an idea of Andreas Lober
;
; Choose positive or negative
; values for real and/or imaginary part
; of the Mondrian Factor
;
; For a radial shape set Mondrian
; Type to none and Function 1 to abs
;
; Sierpinsky is somewhere deep inside ;-)
;
; Revised version 6 August 2000

init:
complex z = 0.4*fn1(pixel^@spokes)
zc = fn2(z/@spokes)*@sizesq
z = 2*(z - zc)+@devide/@power

loop:
IF imag(z)>0.5
z = 2*z - 1i

z = 2*z - 1i

ELSEIF real(z)>0.5
z = (2*z - 1)*(pi^@sizesq)

ELSEIF real(z)>0.1
z = fn3(imag(z^@structure1)) * fn4(sin(z^@structure2))

ELSEIF imag(z) > @devide/@power
z = fn2(imag(z))^(pi/@spokes)

ELSE
z = (2*z)*@rot

ENDIF

IF (@mon == 1)
z = round(@fn1(@mon1)) + @fn2(@mon2)\
+ @fn3(@mon3) + @fn4(#pixel) - @mon2*z

ELSEIF (@mon == 2)
z = trunc(@fn1(@mon1)) + @fn2(@mon2)\
+ @fn3(@mon3) - @fn4(#pixel) - @mon2*z

ELSEIF (@mon == 2)
z = floor(@fn1(@mon1)) + @fn2(@mon2)\
- @fn3(@mon3) + @fn4(#pixel) - @mon2*z

ELSEIF (@mon == 4)
z = ceil( @fn1(@mon1)) + @fn2(@mon2) - @fn3(@mon3)\

ELSEIF (@mon == 5)
z = abs(@fn1(@mon1)) - @fn2(@mon2) + @fn3(@mon3) \

ELSEIF (@mon == 6)
z = round(@fn1(@mon1)) - @fn2(@mon2) + @fn3(@mon3) \

ELSEIF (@mon == 7)
z = trunc(@fn1(@mon1)) + @fn2(@mon2) + @fn3(@mon3) \

ELSEIF (@mon == 8)
z = floor(@fn1(@mon1)) - @fn2(@mon2) + @fn3(@mon3) \

ELSEIF (@mon == 9)
z = ceil( @fn1(@mon1)) * @fn2(@mon2) * @fn3(@mon3)\
* @fn4(#pixel) - ((@adFunc1(@mon1*z) - @mon1*z)^3) - @mon2*z^3

ENDIF

bailout:
(@test == 0 && |z| <= @bailout) ||                                         \
(@test == 1 && sqr(real(z)) <= @bailout) ||                                \
(@test == 2 && sqr(imag(z)) <= @bailout) ||                                \
(@test == 3 && (sqr(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (sqr(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (sqr(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (sqr(real(z) + imag(z)) <= @bailout))

default:
title = "KPK Mondrinsky"
center = (0.4, 0.2)
magn = 1.0
maxiter = 500
periodicity = 0

param devide
caption = "Separation Factor"
default = 0
endparam

param rot
caption = "Inside Factor"
default = 1.0
endparam

param power
caption = "Power"
default = (0,4)
endparam

param spokes
caption = "Spokes (x 2)"
default = 2
endparam

param sizesq
caption = "Magnification"
default = 0.7
endparam

param bailout
caption = "Bailout"
default = 1e20
endparam

param test
caption = "Shape Modifier"
default = 0
enum = "mod" "real" "imag" "or" "and" "manh" "manr"
endparam

param structure1
caption = "Structure 1"
default = 1.0
endparam

param structure2
caption = "Structure 2"
default = 2.0
endparam

param mon
caption = "Mondrian Type"
enum = "None" "round" "trunc" "floor" "ceil" "abs" \
"a-round" "a-trunc" "a-floor" "a-ceil"
default = 0
endparam

param mon1
caption = "Mondrian Fact. a"
default = (1.0,1.0)
endparam

param mon2
caption = "Mondrian Fact. b"
default = (1.0,0.0)
endparam

param mon3
caption = "Mondrian Fact. c"
default = (0.0,0.0)
endparam

caption = "Global Function 1"
default = acosh()
endfunc

func fn1
caption = "Function 1"
default = sqrt()
hint = "For radial shape choose abs"
endfunc

func fn2
caption = "Function 2"
default = ident()
endfunc

func fn3
caption = "Function 3"
default = tan()
endfunc

func fn4
caption = "Function 4"
default = cos()
endfunc

caption = "For Mondrian Types"
default = sqrt()
hint = "Works together with Mondrian Type parameters \
ceil, abs, a-trunc, a-round, a-floor, a-ceil"
endfunc

}

KPKarnevalinsky {
; Written by KPK February, 2000
;
; Version February, 23
;
; Tweaked lattice factor and
; some changed "Hevia" entries
; integrated with kind permission
; of Andreas Lober
;
;
; You can choose what you want
; to get what you want
;
; ;-) :-))) 8-) \$-/\
;
; Revised version 6 August 2000

init:

complex z = 0.3*fn1(pixel^@spokes)
zc = fn2(z/@spokes)*@sizesq
z = 2*(z - zc)+@devide/@power

x = 0
y = 0

xf = 0
yf = 0

xc = 0
yc = 0

loop:

IF (imag(z)>0.5)
z = 2*real(z) + @fn5(2*imag(z)-1)

ELSEIF (real(z)>0.5)
z = 2*real(z)-1 + @fn5(2*imag(z))

ELSEIF (imag(z)<-0.1)
z = 2*imag(z)+1 + @fn5(2*real(z))

ELSEIF (real(z)>0.1)
z = fn3(imag(z^@structure1)) * fn4(sin(z^@structure2))

ELSE
z = 2*real(z) + flip(2*imag(z))

ENDIF

IF     (@helau == 1)
z = round(@erf1*z) - @erf2*z

ELSEIF (@helau == 2)
z = trunc(@erf1*z) - @erf2*z

ELSEIF (@helau == 3)
z = floor(@erf1*z) - @erf2*z

ELSEIF (@helau == 4)
z = ceil(@erf1*z)  - @erf2*z

ELSEIF (@helau == 5)
z = abs(@erf1*z)   - @erf2*z^2

ENDIF

x = real(z)
y = imag(z)

IF   (@helau == 0)

xf = @erf*round(x)
yf = @erf*round(y)

xc = xf+@erf
yc = yf+@erf

ELSEIF (@helau == 1)

xf = floor(@erf*x)/@erf
yf = floor(@erf*y)/@erf

xc = ceil(@erf*x)/@erf
yc = ceil(@erf*y)/@erf

ELSEIF (@helau == 2)

xf = @erf^x
yf = @erf^y

xc = xf*@erf
yc = yf*@erf

ELSEIF (@helau == 3)

xf = floor(@erf^x)*@erf
yf = floor(@erf^y)*@erf

xc = ceil(@erf*x)/@erf
yc = ceil(@erf*y)/@erf

ELSEIF (@helau == 4)

xf = floor(@erf*x)*@erf
yf = floor(@erf*y)*@erf

xc = ceil(@erf^x)^@erf
yc = ceil(@erf^y)^@erf

ELSEIF (@helau == 5)

xf = fn1(@erf*x)*@erf
yf = fn1(@erf*y)*@erf

xc = fn2(@erf^x)^@erf
yc = fn2(@erf^y)^@erf

ELSEIF (@helau == 6)

xf = fn1(@erf*x)*@erf
yf = fn2(@erf*y)*@erf

xc = fn1(@erf^x)^@erf
yc = fn2(@erf^y)^@erf

ENDIF

a = xf + 1i*yc
b = xc + 1i*yc
c = xf + 1i*yf
d = xc + 1i*yf

IF (@alaaf == 1)
z = a*x + b*y + 1i*(c*x+d*y)

ELSEIF (@alaaf == 2)
z = a*z + b

ELSEIF (@alaaf == 3)
z = a*z + b*z

ELSEIF (@alaaf == 4)
z = c*z + d*z

ELSEIF (@alaaf == 5)
z = a*z + (b-c)^z - b

ELSEIF (@alaaf == 6)
z = a*x + (b+c)*x*y + d*y

ELSEIF (@alaaf == 7)
z = a*y + b*x*y + 1i*(c*x*y + d*y^2)

ENDIF

bailout:
(@test == 0 && |z| <= @bailout) ||                                         \
(@test == 1 && sqr(real(z)) <= @bailout) ||                                \
(@test == 2 && sqr(imag(z)) <= @bailout) ||                                \
(@test == 3 && (sqr(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (sqr(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (sqr(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (sqr(real(z) + imag(z)) <= @bailout))

default:
title = "KPKarnevalinsky"
center = (0.4, 0.2)
magn = 1.0
maxiter = 500
periodicity = 0

param alaaf
caption = "Some Math"
enum    = "None" "Linear?" "Try out" "Oops 1" "Oops 2" \
"A Product" "A Something" "An Always"
default = 0
endparam

param erf
caption = "Der Erfinder"
default = 1.0
endparam

param devide
caption = "Close"
default = 0
endparam

param power
caption = "Gas"
default = (0,4)
endparam

param spokes
caption = "Choosy"
default = 1
endparam

param sizesq
caption = "Magnification"
default = 0.7
endparam

param bailout
caption = "Bailout"
default = 1e20
endparam

param test
caption = "Shape Modifier"
default = 0
enum = "mod" "real" "imag" "or" "and" "manh" "manr"
endparam

param structure1
caption = "Structure 1"
default = 2
endparam

param structure2
caption = "Structure 2"
default = 2
endparam

param helau
caption = "Fun Type"
enum = "None" "King" "Lord" "Sweetie" "Uggllyy" \
"Jester" "Clown"
default = 0
hint = "With Jester and Clown you can use \
functions 1 and 2 for further changes"
endparam

param erf1
caption = "Wisdom Factor"
default = (4.0,1.0)
endparam

param erf2
caption = "Eternal Factor"
default = (1.0,0.0)
endparam

func fn1
caption = "Function 1"
default = abs()
endfunc

func fn2
caption = "Function 2"
default = sqr()
endfunc

func fn3
caption = "Function 3"
default = sin()
endfunc

func fn4
caption = "Function 4"
default = cos()
endfunc

func fn5
caption = "Function 5"
default = flip()
endfunc
}

KPKy {
;
; Written by KPK February, 2000
;
; For Andreas
;
; Revision August, 6
;
; Special loop sequence after
; an idea of Andreas Lober
;
; Spot effect after an
; loop sequence by Andras Szolek

init:

complex z = pixel
z = fn1(2*z)

IF @spot == true
sp = 2

ELSE
sp = 1

ENDIF

loop:

IF (@loop == 0)

IF (imag(z)>0.5)
z = z - (0,1)

ELSEIF (real(z)>0.5)
z = (z - (1,0))*sp

ENDIF

IF (imag(z)>0.5)
z = (2*real(z) + fn2(2*imag(z)-1))*sp

ELSEIF (real(z)>0.5)
z = 2*real(z)-1 + fn2(2*imag(z))

ELSEIF (imag(z)<0.5)
z = 2*real(z)+0.75 + fn2(2+imag(z))

ELSE
z = 2*real(z) + fn2(2*imag(z))

ENDIF

IF     (@KPKy == 1)
z = round(@KPKy1*z) - @KPKy2*z

ELSEIF (@KPKy == 2)
z = fn3(@KPKy1*z) - @KPKy2*z

ELSEIF (@KPKy == 3)
z = fn4(@KPKy1*z) - @KPKy2*z

ELSEIF (@KPKy == 4)
z = ceil(@KPKy1*z)  - @KPKy2*z^z

ELSEIF (@KPKy == 5)
z = abs(@KPKy1*z)   - @KPKy2*z^2

ELSEIF (@KPKy == 6)
z = fn3(@KPKy1*z) - @KPKy2*sqrt(real(z)*imag(z))

ELSEIF (@KPKy == 7)
z = fn4(@KPKy1*z) - @KPKy2*sqrt(real(z)*imag(z))

ELSEIF (@KPKy == 8)
z = floor(@KPKy1*z) - @KPKy2*fn3(real(z)*imag(z))

ELSEIF (@KPKy == 9)
z = fn4(@KPKy1*z)  - @KPKy2*sqr(real(z)*imag(z))

ELSEIF (@KPKy == 10)
z = abs(@KPKy1*z)   - @KPKy2*sqr(real(z)*imag(z))

ELSEIF (@KPKy == 11)
z = round ((round(@KPKy1*z) - @KPKy1*z)^2) - @KPKy2*z^2

ENDIF

ELSEIF (@loop == 1)

IF (imag(z)>1.0)
z = (fn2(z^@KPKy2) * (@KPKy1*(fn3(@KPKy1/2 \
*(fn2(z/@KPKy2)) / (z/fn2(z/@KPKy1))))))*fn1((sp^z)/sp^sp)

ELSEIF (imag(z)>0.5)
z = z - (0,1)*sp/2

ELSEIF (real(z)>0.5)
z = (z - (1,0))

ENDIF

IF (imag(z)>0.5)
z = (2*real(z) + fn2(2*imag(z)-1))

ELSEIF (real(z)>0.5)
z = 2*real(z)-1 + fn2(2*imag(z))

ELSEIF (imag(z)<0.5)
z = 2*real(z)+0.75 + fn2(2+imag(z))

ELSE
z = 2*real(z) + fn2(2*imag(z))

ENDIF

IF     (@KPKy == 1)
z = round(@KPKy1*z) - @KPKy2*z

ELSEIF (@KPKy == 2)
z = fn3(@KPKy1*z) - @KPKy2*z

ELSEIF (@KPKy == 3)
z = fn4(@KPKy1*z) - @KPKy2*z

ELSEIF (@KPKy == 4)
z = ceil(@KPKy1*z)  - @KPKy2*z^z

ELSEIF (@KPKy == 5)
z = abs(@KPKy1*z)   - @KPKy2*z^2

ELSEIF (@KPKy == 6)
z = fn3(@KPKy1*z) - @KPKy2*sqrt(real(z)*imag(z))

ELSEIF (@KPKy == 7)
z = fn4(@KPKy1*z) - @KPKy2*sqrt(real(z)*imag(z))

ELSEIF (@KPKy == 8)
z = floor(@KPKy1*z) - @KPKy2*fn3(real(z)*imag(z))

ELSEIF (@KPKy == 9)
z = fn4(@KPKy1*z)  - @KPKy2*sqr(real(z)*imag(z))

ELSEIF (@KPKy == 10)
z = abs(@KPKy1*z)   - @KPKy2*sqr(real(z)*imag(z))

ELSEIF (@KPKy == 11)
z = round ((round(@KPKy1*z) - @KPKy1*z)^2) - @KPKy2*z^2

ENDIF

ENDIF

bailout:
(@test == 0 && |z| <= @bailout) ||                                         \
(@test == 1 && sqr(real(z)) <= @bailout) ||                                \
(@test == 2 && sqr(imag(z)) <= @bailout) ||                                \
(@test == 3 && (sqr(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (sqr(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (sqr(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (sqr(real(z) + imag(z)) <= @bailout))

default:
title = "KPK Y"
magn = 1.0
maxiter = 500
periodicity = 0
center = (0.4, 0.4)

param loop
caption = "Overall loop"
enum = "KPKy" "KPKq"
default = 0
endparam

param bailout
caption = "Bailout value"
default = 127
min = 1
endparam

param test
caption = "Shape Modifier"
default = 0
enum = "mod" "real" "imag" "or" "and" "manh" "manr"
endparam

param spot
caption = "Spot Change"
default = false
endparam

param KPKy
caption = "KPKy Type"
enum = "None" "round" "trunc" "floor" "ceil" "abs" \
"KPKy-round" "KPKy-trunc" "KPKy-floor" "KPKy-ceil" \
"KPKy-abs"
default = 0
endparam

param KPKy1
caption = "KPKy Factor 1"
default = (4.0,1.0)
endparam

param KPKy2
caption = "KPKy Factor 2"
default = (1.0,0.0)
endparam

func fn1
caption = "Function 1"
default = abs()
endfunc

func fn2
caption = "Function 2"
default = flip()
endfunc

func fn3
default = ident()
endfunc

func fn4
default = conj()
endfunc

}

KPKinskycoruna {
;
; Written by KPK February, 2000
;
; Revision August 6, 2000
;
; Spot effect after an
; loop sequence by Andras Szolek

init:

complex z = pixel^@spokes
zc = fn1(z/@sizesq)*@sizesq
z = 2*(z - zc)+@devide/@power

x = real(z)+ 2*(z - zc)
y = imag(z)-(x - zc)

a = fn1(real(z) + flip(2*imag(z)))
b = fn1(2*imag(z)+1 + flip(2*real(z)))

c = a*b
d = b^a

IF @spot1 == true
sp = 2

ELSE
sp = 1

ENDIF

loop:

IF (imag(z)>0.5)
z = 2*real(z) + flip(2*imag(z)-1)*sp

ELSEIF (real(z)>0.5)
z = 2*real(z)-1 + flip(2*imag(z))*sp^sp

ELSEIF (real(z)>0.1)
z = x-2*(y) + ident(2*imag(z)-0.5)

ELSEIF (real(z)>0.5)
z = (2*x*y)^(fn2(2*imag(z)))

ELSEIF (imag(z)<-0.1)
z = 2*imag(z)+1 + fn2(2*real(z))

ELSEIF (real(z)>0.1)
z = fn1(imag(z^@structure1)) * fn1(fn1(z^@structure2))

ELSEIF (real(z)>0.1)
z = (c - d) * (a^b) + flip(0.75^imag(z))

ELSE
z = 2*real(z) + flip(2*imag(z))

ENDIF

bailout:
(@test == 0 && |z| <= @bailout) ||                                         \
(@test == 1 && sqr(real(z)) <= @bailout) ||                                \
(@test == 2 && sqr(imag(z)) <= @bailout) ||                                \
(@test == 3 && (sqr(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (sqr(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (sqr(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (sqr(real(z) + imag(z)) <= @bailout))

default:
title = "KPKinsky Coruna"
center = (0.4, 0.2)
magn = 1.0
maxiter = 500
periodicity = 0

param devide
caption = "Separation Factor"
default = 1
endparam

param power
caption = "Power"
default = (2.0,4.0)
endparam

param spot1
caption = "Spot Change 1"
default = false
endparam

param spokes
caption = "Spokes"
default = 2
endparam

param sizesq
caption = "Magnification"
default = 0.7
endparam

param bailout
caption = "Bailout"
default = 1e20
endparam

param test
caption = "Shape Modifier"
default = 0
enum = "mod" "real" "imag" "or" "and" "manh" "manr"
endparam

param structure1
caption = "Structure 1"
default = 2
endparam

param structure2
caption = "Structure 2"
default = 2
endparam

func fn1
caption = "Function 1"
default = sqrt()
endfunc

func fn2
caption = "Function 2"
default = flip()
endfunc

}

KPKartdeco {
;
; Written by KPK March, 2000
;
; Version August 6, 2000
;
; With ideas from
; Andreas Lober, Samuel Monnier
; and Andras Szolek

init:

complex z = pixel
z = fn1(2*z)/pi*@magn
z = 2*(2*z/pi)+@devide/@power
zc = sqr(z/2)*0.7

float k = @deco*pi*0.05
float s = trunc(k)

IF @spot == true
sp = 2

ELSE
sp = 1

ENDIF

IF @orient1 == true

or1 = (z - (1,0))*sp

ELSE

or1 = (z/zc)*sp

ENDIF

IF @orient2 == true

or2 = (z - (1,0))

ELSE

or2 = fn1(z^zc)*sp + zc

ENDIF

IF @orient3 == true

or3 = 1

ELSE

or3 = (2*real(z) + flip(2*imag(z)))

ENDIF

loop:

IF (@loop == 0)

IF (imag(z)>0.5)
z = z - (0,1)

ELSEIF (real(z)>0.5)
z = or1

ENDIF

IF (imag(z)>0.5)
z = (2*real(z) + fn2(2*imag(z)-1))*sp

ELSEIF (real(z)>0.5)
z = 2*real(z)-1 + fn2(2*imag(z))

ELSEIF (imag(z)<0.5)
z = 2*real(z)+0.75 + fn2(2+imag(z))

ELSE
z = 2*real(z) + fn2(2*imag(z))

ENDIF

IF     (@DecoFct == 1)
z = round(@DecoFct1*z) - @DecoFct2*z

ELSEIF (@DecoFct == 2)
z = fn3(@DecoFct1*z) - @DecoFct2*z

ELSEIF (@DecoFct == 3)
z = fn4(@DecoFct1*z) - @DecoFct2*z

ELSEIF (@DecoFct == 4)
z = ceil(@DecoFct1*z)  - @DecoFct2*z^z

ELSEIF (@DecoFct == 5)
z = abs(@DecoFct1*z)   - @DecoFct2*z^2

ELSEIF (@DecoFct == 6)
z = fn3(@DecoFct1*z) - @DecoFct2*sqrt(real(z)*imag(z))

ELSEIF (@DecoFct == 7)
z = fn4(@DecoFct1*z) - @DecoFct2*sqrt(real(z)*imag(z))

ELSEIF (@DecoFct == 8)
z = floor(@DecoFct1*z) - @DecoFct2*fn3(real(z)*imag(z))

ELSEIF (@DecoFct == 9)
z = fn4(@DecoFct1*z)  - @DecoFct2*sqr(real(z)*imag(z))

ELSEIF (@DecoFct == 10)
z = abs(@DecoFct1*z)   - @DecoFct2*sqr(real(z)*imag(z))

ELSEIF (@DecoFct == 11)
z = round ((round(@DecoFct1*z) - @DecoFct1*z)^2) - @DecoFct2*z^2

ENDIF

ELSEIF (@loop == 1)

IF (imag(z)>1.0)
z = (fn2(z^@DecoFct2) * (@DecoFct1*(fn3(@DecoFct1/2 \
*(fn2(z/@DecoFct2)) / (z/fn2(z/@DecoFct1))))))*fn1((sp^z)/sp^sp)

ELSEIF (imag(z)>0.5)
z = z - (0,1)*sp/2

ELSEIF (real(z)>0.5)
z = or2

ENDIF

IF (imag(z)>0.5)
z = (2*real(z) + flip(2*imag(z)-1))

ELSEIF (real(z)>0.5)
z = 2*real(z)-1 + flip(2*imag(z))

ELSEIF (imag(z)<0.5)
z = 2*real(z)+0.75 + flip(2+imag(z))

ELSE
z = 2*real(z) + flip(2*imag(z))

ENDIF

IF     (@DecoFct == 1)
z = round(@DecoFct1*z) - @DecoFct2*z

ELSEIF (@DecoFct == 2)
z = fn3(@DecoFct1*z) - @DecoFct2*z

ELSEIF (@DecoFct == 3)
z = fn4(@DecoFct1*z) - @DecoFct2*z

ELSEIF (@DecoFct == 4)
z = ceil(@DecoFct1*z)  - @DecoFct2*z^z

ELSEIF (@DecoFct == 5)
z = abs(@DecoFct1*z)   - @DecoFct2*z^2

ELSEIF (@DecoFct == 6)
z = fn3(@DecoFct1*z) - @DecoFct2*sqrt(real(z)*imag(z))

ELSEIF (@DecoFct == 7)
z = fn4(@DecoFct1*z) - @DecoFct2*sqrt(real(z)*imag(z))

ELSEIF (@DecoFct == 8)
z = floor(@DecoFct1*z) - @DecoFct2*fn3(real(z)*imag(z))

ELSEIF (@DecoFct == 9)
z = fn4(@DecoFct1*z)  - @DecoFct2*sqr(real(z)*imag(z))

ELSEIF (@DecoFct == 10)
z = abs(@DecoFct1*z)   - @DecoFct2*sqr(real(z)*imag(z))

ELSEIF (@DecoFct == 11)
z = round ((round(@DecoFct1*z) - @DecoFct1*z)^2) - @DecoFct2*z^2

ENDIF

ELSEIF (@loop == 2)

IF (imag(z)>0.5)
z = 2*real(z) + fn2(2*imag(z)-1)*sp

ELSEIF (real(z)>0.5)
z = 2*real(z)-1 + flip(2*imag(z))*or3

ELSE
z = 2*real(z) + flip(2*imag(z))
z = ident(z)

ENDIF

IF (@DecoFct == 1)
z = round(@fn1(@DecoFct1)) + @fn2(@DecoFct2)\
+ @fn3(@DecoFct1) + @fn4(#pixel) - @DecoFct2*z

ELSEIF (@DecoFct == 2)
z = trunc(@fn1(@DecoFct1)) + @fn2(@DecoFct2)\
+ @fn3(@DecoFct1) - @fn4(#pixel) - @DecoFct2*z

ELSEIF (@DecoFct == 2)
z = floor(@fn1(@DecoFct1)) + @fn2(@DecoFct2)\
- @fn3(@DecoFct1) + @fn4(#pixel) - @DecoFct2*z

ELSEIF (@DecoFct == 4)
z = ceil( @fn1(@DecoFct1)) + @fn2(@DecoFct2) - @fn3(@DecoFct1)\

ELSEIF (@DecoFct == 5)
z = abs(@fn1(@DecoFct1)) - @fn2(@DecoFct2) + @fn3(@DecoFct1) \

ELSEIF (@DecoFct == 6)
z = round(@fn1(@DecoFct1)) - @fn2(@DecoFct2) + @fn3(@DecoFct1) \

ELSEIF (@DecoFct == 7)
z = trunc(@fn1(@DecoFct1)) + @fn2(@DecoFct2) + @fn3(@DecoFct1) \

ELSEIF (@DecoFct == 8)
z = floor(@fn1(@DecoFct1)) - @fn2(@DecoFct2) + @fn3(@DecoFct1) \

ELSEIF (@DecoFct == 9)
z = ceil( @fn1(@DecoFct1)) * @fn2(@DecoFct2) * @fn3(@DecoFct1)\
* @fn4(z/zc) + ((@adFunc1(@DecoFct1*z) - @DecoFct1*z)^3) - @DecoFct2*z^3

ELSEIF (@DecoFct == 10)
z = abs(@DecoFct1*z)   - @DecoFct2*sqr(real(z)*imag(z))

ELSEIF (@DecoFct == 11)
z = round ((round(@DecoFct1*z) - @DecoFct1*z)^2) - @DecoFct2*z^2

ENDIF

IF (imag(z)>0.5)
z = 2*real(z) + flip(2*imag(z)-1)*sp

ELSEIF (real(z)>0.5)
z = 2*real(z)-1 + flip(2*imag(z))

ELSEIF (imag(z)<-0.1)
z = 2*imag(z)+1 + flip(2*real(z))

ELSE
z = 2*real(z) + flip(2*imag(z))

ENDIF

ENDIF

IF @fract == true
fr = z + @intens

ELSE
fr = z - @intens

ENDIF

z = fr
x = real(z)
y = imag(z)

IF s*x + s < y
z = (2*z + 2 + 1i*s)*sp

ELSEIF s*x - s < y
z = 2*z - 2 - 1i*s

ELSEIF y < 0
z = 2*z + 1i*s

ELSEIF x < y - s*x
z = 2*z + 2 - 1i*s

ENDIF

bailout:
(@test == 0 && |z| <= @bailout) ||                                         \
(@test == 1 && sqr(real(z)) <= @bailout) ||                                \
(@test == 2 && sqr(imag(z)) <= @bailout) ||                                \
(@test == 3 && (sqr(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (sqr(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (sqr(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (sqr(real(z) + imag(z)) <= @bailout))

default:
title = "KPK Art Deco"
magn = 1.0
maxiter = 500
periodicity = 0
center = (0.4, 0.4)

param loop
caption = "Overall loop"
enum = "Art Deco" "Stretch" "Sir P."
default = 0
endparam

param bailout
caption = "Bailout value"
default = 2500
min = 127
endparam

param test
caption = "Shape Modifier"
default = 0
enum = "mod" "real" "imag" "or" "and" "manh" "manr"
endparam

param devide
caption = "Separation Factor"
default = 4
endparam

param power
caption = "Power"
default = (0,4)
endparam

param deco
caption = "Art Deco"
default = 11
endparam

param magn
caption = "Magnification"
default = (5.0,0.0)
endparam

param intens
caption = "Intensity"
default = (-1,0)
endparam

param fract
caption = "Fraction Change"
default = true
endparam

param spot
caption = "Spot Change"
default = false
endparam

param orient1
caption = "Deco Change"
default = true
endparam

param orient2
caption = "Stretch Change"
default = true
endparam

param orient3
caption = "Sir P. Change"
default = true
endparam

param DecoFct
caption = "Deco Type"
enum = "None" "round" "trunc" "floor" "ceil" "abs" \
"DecoFct-round" "DecoFct-trunc" "DecoFct-floor" "DecoFct-ceil" \
"DecoFct-abs"
default = 0
endparam

param DecoFct1
caption = "Deco Factor 1"
default = (4.0,1.0)
endparam

param DecoFct2
caption = "Deco Factor 2"
default = (1.0,0.0)
endparam

func fn1
caption = "Function 1"
default = abs()
endfunc

func fn2
caption = "Function 2"
default = flip()
endfunc

func fn3
default = ident()
endfunc

func fn4
default = conj()
endfunc

caption = "Sir P. Funct."
default = sqrt()
hint = "For use with Overall loop Sir P. only"
endfunc

}

Pinskyfamilyzcn {
; From Samuel Monnier's Julifamily
;
; Modified by KPK, December 1999
;
; Enhanced by Samuel Monnier, March 2000
;
; Revised August 6, 2000
;
init:
complex z = pixel
int i = 0
z = z - @tilem
z = z*exp(1i*pi/180*@rottile)
zc = round(z/@sizesq)*@sizesq
z = z*exp(-1i*pi/180*@rottile)
zc = zc*exp(-1i*pi/180*@rottile)
z = z + @tilem
zc = zc + @tilem
z = 2*(z - zc)/@sizesq + @center
z = z/@magn
z = z*exp(1i*pi/180*@rot)

loop:
i = i + 1

if (imag(z)>0.5)
z = 2*z - 1i
elseif (real(z)>0.5)
z = 2*z - 1
else
z = 2*z
endif

if @mode == 0
z = z*zc
elseif @mode == 1
z = z/zc
elseif @mode == 2
z = z+zc
elseif @mode == 3
z = z^zc
endif

bailout:
(@test == 0 && |z| <= @bailout) ||                                         \
(@test == 1 && sqr(real(z)) <= @bailout) ||                                \
(@test == 2 && sqr(imag(z)) <= @bailout) ||                                \
(@test == 3 && (sqr(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (sqr(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (sqr(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (sqr(real(z) + imag(z)) <= @bailout))

default:
title = "Pinskyfamily zc new"
magn = 1.5
maxiter = 500

param mode
caption = "Mode"
default = 0
enum = "Product" "Quotient" "Sum" "Power"
endparam

param center
caption = "Center"
default = (.2,.2)
endparam

param magn
caption = "Magnification"
default = 1.0
endparam

param rot
caption = "Rotation"
default = 0.0
endparam

param tilem
caption = "Tiling translation"
default = (0,0)
endparam

param sizesq
caption = "Size of the tiles"
default = 0.6
endparam

param rottile
caption = "Rotation of the Tiling"
default = 0.0
endparam

param bailout
caption = "Bailout"
default = 1e20
endparam

param test
caption = "Shape Modifier"
default = 0
enum = "mod" "real" "imag" "or" "and" "manh" "manr"
endparam
}

kpkskcd {
; Tweaked formula by KPK March 2000
;
; Derived from Samuel Monnier's
; Squarry Koch Curve formula
;
; Spot effect after an idea of Andras Szolek
;
init:

i = 0
z = #pixel

zc = sqr(z/2)*0.7

bool bail = true

x = real(z)
y = imag(z)

tes = fn1(z)

IF @spot == true
sp = 2

ELSE
sp = 1

ENDIF

IF @spot2 == true
sp2 = abs(tes)

ELSE
sp2 = sqrt(tes)

ENDIF

loop:

i = i + 1

bool bail = true

IF i == 2
z = 1/fn2(@r)*real(z) + 1i*fn2(@r)*imag(z)

IF @mode == 0

IF |x| < 1 && |y| < 1
bail = true

ENDIF

IF sp2 < pi/4
z = z*fn3(1i*pi/2)*sp

ELSEIF (tes < -pi/4) && (tes > -3*pi/4)
z = z*fn3(1i*pi)

ELSEIF abs(tes) > 3*pi/4
z = z*fn3(1i*3*pi/2)

ENDIF

z = z - 1i

ELSEIF @mode == 1

z = 1/sqrt(2)*z*exp(1i*pi/4)
x = real(z)
y = imag(z)

IF |x| > 1 || |y| > 1
bail = true

ENDIF

tes = fn1(z)

IF sp2 < pi/4
z = z*fn3(1i*pi/2)*sp

ELSEIF (tes < -pi/4) && (tes > -3*pi/4)
z = z*fn3(1i*pi)

ELSEIF abs(tes) > 3*pi/4
z = z*fn3(1i*3*pi/2)

ENDIF

z = -z + 1i

ENDIF

ELSEIF i > 2

z = z + zc

z = 1/sqrt(@r)*real(z) + 1i*sqrt(@r)*imag(z)

x = real(z)
y = imag(z)

IF abs(x) < 1/@s && abs(y - 1/@s) < 1/@s
bail = true

ENDIF

IF x < -1/@s && y < -x - 1/@s
z = 2*@s/(@s-1)*z + (@s+1)/(@s-1)

ELSEIF x > 1/@s && y < x - 1/@s
z = 2*@s/(@s-1)*z - (@s+1)/(@s-1)

ELSEIF x <= -1/@s && y > -x - 1/@s
z = z + 1/@s
z = z*fn3(-1i*pi/2)
z = @s*z - 1

ELSEIF x >= 1/@s && y > x - 1/@s
z = z - 1/@s
z = z*fn3(1i*pi/2)
z = @s*z + 1

ELSEIF abs(x) < 1/@s
z = @s*z - 2*1i

ENDIF

ENDIF

IF i >= 2
z = z - zc

ENDIF

bailout:

|z| < @bailout && bail == true

default:

title = "KPK SKCD"
method = multipass
periodicity = 0

param bailout
caption = "Bailout"
default = 1000
endparam

param r
caption = "Smoothness"
default = 1.0
min = 1.0
endparam

param mode
caption = "Variation"
default = 0
enum = "Arranged" "Distorted"
endparam

param spot
caption = "Spot Change"
default = false
endparam

param spot2
caption = "Distortion Change"
default = true
endparam

param s
caption = "Magnification step"
default = 4.0
endparam

func fn1
caption = "Function 1"
default = atanh()
endfunc

func fn2
caption = "Function 2"
default = sqrt()
endfunc

func fn3
caption = "Function 3"
default = exp()
endfunc
}

kpkhippie {
; Written by KPK March 2000
;
; With parts of Samuel Monnier's
; Squarry Koch Curve formula
;
; Spot effects after an idea of Andras Szolek
;
;
; Version March, 14
;
init:

i = 0
z = #pixel
z = z*exp(1i*pi/180*@rot)

zc = fn1(z/2)*0.7

bool bail = true

x = real(z)
y = imag(z)

tes = fn1(z)

zz = x + fn1(y)

n = fn4(@power1^i)*zc

IF @spot == true
sp = 2

ELSE
sp = 1

ENDIF

IF @spot2 == true
sp2 = abs(tes)

ELSE
sp2 = sqrt(tes)

ENDIF

IF @spot3 == true
sp3 = 1/fn2(@r)*real(z) + 1i*fn2(@r)*imag(z)+n

ELSE
sp3 = 1/fn2(@r)*imag(z)/(2i*fn2(@r)*real(z)*n)+n

ENDIF

IF @spot4 == true
sp4 = 1/sqrt(2)*z*exp(1i*pi/4)

ELSE
sp4 = 1/fn2(@r)*imag(z)*(2i*fn2(@r)*real(z)*n)+n

ENDIF

IF @spot5 == true
sp5 =  zc

ELSE
sp5 = (@s*z - 2*1i)

ENDIF

loop:

i = i + 1

n = fn4(@power1^i)*zc

bool bail = true

IF i == 2
z = sp3

IF @mode == 0

IF |x| < 1 && |y| < 1
bail = true

ENDIF

IF sp2 < pi/4
z = z*fn3(1i*pi/2)*sp

ELSEIF (tes < -pi/4) && (tes > -3*pi/4)
z = z*fn3(1i*pi)

ELSEIF abs(tes) > 3*pi/4
z = z*fn3(1i*3*pi/2)

ENDIF

z = z - 1i

ELSEIF @mode == 1

z = sp4
x = real(z)
y = imag(z)

IF |x| > 1 || |y| > 1
bail = true

ENDIF

tes = fn1(z)

IF sp2 < pi/4
z = z*fn3(1i*pi/2)*sp

ELSEIF (tes < -pi/4) && (tes > -3*pi/4)
z = z*fn3(1i*pi)

ELSEIF abs(tes) > 3*pi/4
z = z*fn3(1i*3*pi/2)

ENDIF

z = -z + 1i

ELSEIF @mode == 2

n = 2^i
zi = fn2(z*n)/n
z = n*(z - zi)
z = (1/@r^0.5*real(z) + @r^0.5*imag(z)*1i)/@s
z = fn3(zz)*fn3(1i*i*@rot/180*pi)

IF |x| < 1 && |y| < 1
bail = true

ENDIF

IF sp2 < pi/4
z = z*fn1(1i*pi/2)*sp

ELSEIF (tes < -pi/4) && (tes > -3*pi/4)
z = z*fn3(1i*pi)

ELSEIF abs(tes) > 3*pi/4
z = z*fn4(1i*3*pi/2)

ENDIF

z = fn3(z)

ELSEIF @mode == 3

complex z = 0.2*fn1(pixel^@s)

IF (imag(z)>0.5)
z = 2*real(z) + fn2(2*imag(z)-1)

ELSEIF (real(z)>0.5)
z = 2*real(z)-1 + fn3(2*imag(z))

ELSE
z = 2*real(z) + flip(2*imag(z))
z = fn4(z)

ENDIF

ENDIF

ELSEIF i > 2

z = z + zc

z = 1/fn2(@r)*real(z) + 1i*fn2(@r)*imag(z)

x = real(z)
y = imag(z)

IF abs(x) < 1/@s && abs(y - 1/@s) < 1/@s
bail = true

ENDIF

IF x < -1/@s && y < -x - 1/@s
z = 2*@s/(@s-1)*z + (@s+1)/(@s-1)

ELSEIF x > 1/@s && y < x - 1/@s
z = 2*@s/(@s-1)*z - (@s+1)/(@s-1)

ELSEIF x <= -1/@s && y > -x - 1/@s
z = z + 1/@s
z = z*fn3(-1i*pi/2)
z = @s*z - 1

ELSEIF x >= 1/@s && y > x - 1/@s
z = z - 1/@s
z = z*fn3(1i*pi/2)
z = @s*z + 1

ELSEIF abs(x) < 1/@s
z = @s*z - 2*1i

ENDIF

ENDIF

IF i >= 2
z = z - sp5

ENDIF

bailout:

|z| < @bailout && bail == true

default:

title = "KPK Hippie"
method = multipass
periodicity = 0

param bailout
caption = "Bailout"
default = 1000
endparam

param r
caption = "Smoothness"
default = 1.0
min = 1.0
endparam

param mode
caption = "Variation"
default = 0
enum = "Arranged" "Mixed" "Xtreme" "Sir P."
endparam

param spot
caption = "Spot Change"
default = false
endparam

param spot2
caption = "Distortion Change"
default = true
endparam

param spot3
caption = "Multiply Change"
default = true
endparam

param spot4
caption = "z Change"
default = true
endparam

param spot5
caption = "Last Change"
default = true
endparam

param s
caption = "Step Size"
default = 2.0
endparam

param rot
caption = "Rotation"
default = 0.0
endparam

param power1
caption = "Distortion"
default = 2.0
endparam

func fn1
caption = "Function 1"
default = cos()
endfunc

func fn2
caption = "Function 2"
default = sqrt()
endfunc

func fn3
caption = "Function 3"
default = cos()
endfunc

func fn4
caption = "Function 4"
default = abs()
endfunc
}

kpkehe {
; Written by KPK March 2000
;
; With modified parts of Samuel Monnier's
; Squarry Koch Curve formula and Daniel
; Kuzmenka's ideas from Pinskyfamilyzc+
;
; Spot effect after an idea of Andras Szolek
;
;
; Version March, 23
;
init:

i = 0
z = #pixel
z = z*exp(1i*pi/180*@rot)

zc = sqr(z/2)*0.7

bool bail  = true

x = real(z)
y = imag(z)

tes = fn1(z)

zz = x + fn1(y)

n = fn4(@power1^i)*zc

z = z/@size

IF @spot == true
sp = 2

ELSE
sp = 1

ENDIF

IF @spot2 == true
sp2 = abs(tes)

ELSE
sp2 = sqrt(tes)

ENDIF

IF @spot3 == true
sp3 = 1/fn2(@r)*real(z) + 1i*fn2(@r)*imag(z)+n

ELSE
sp3 = 1/fn2(@r)*imag(z) + 2i*fn2(@r)*real(z)*n

ENDIF

IF @spot4 == true
sp4 = 1/sqrt(2)*z*exp(1i*pi/4)

ELSE
sp4 = 1/fn2(@r)*imag(z)*(2i*fn2(@r)*real(z)*n)+n

ENDIF

IF @spot5 == true
sp5 =  zc

ELSE
sp5 = (@s*z - 2*1i)

ENDIF

IF @spot6 == true
sp6 =  zc

ELSE
sp6 = (@s*z - 2*1i)

ENDIF

IF @spot7 == true
sp7 =  zc

ELSE
sp7 = (@s/z + 2*1i)

ENDIF

IF @spot8 == true
sp8 =  zc

ELSE
sp8 = (@s*z^z / 2*1i)

ENDIF

IF @spot9 == true
sp9 =  zc

ELSE
sp9 = (@s/z^z / 2*1i)

ENDIF

loop:

i = i + 1

n = fn4(@power1^i)*zc

bool bail = true

IF i == 2
z = sp3

IF @mode == 0

IF |x| < 1 && |y| < 1
bail = true

ENDIF

IF sp2 < pi/4
z = z*fn3(1i*pi/2)*sp

ELSEIF (tes < -pi/4) && (tes > -3*pi/4)
z = z*fn3(1i*pi)

ELSEIF sp2 > 3*pi/4
z = z*fn3(1i*3*pi/2)

ENDIF
z = z/1i

ELSEIF @mode == 1

z = sp4
x = real(z)
y = imag(z)

IF |x| > 1 || |y| > 1
bail = true

ENDIF

tes = fn2(z)

IF sp2 < pi/4
z = z*fn3(1i*pi/2)*sp

ELSEIF (tes < -pi/4) && (tes > -3*pi/4)
z = z*fn3(1i*pi)

ELSEIF abs(tes) > 3*pi/4
z = z*fn3(1i*3*pi/2)

ENDIF
z = -z -1i

ELSEIF @mode == 2

n = (2^i)*z
zi = fn3(z*n)/2*n
z = n*(z / zi)
z = (1/@r^0.5*real(z) + @r^0.5*imag(z)*1i)/@s
z = fn4(zz)*fn3(1i*i*@rot/180*pi/.25)

IF |x| < 1 && |y| < 1
bail = true

ENDIF

IF sp2 < pi/4
z = z*fn1(1i*pi/4)*sp

ELSEIF (tes < -pi/4) && (tes > -3*pi/4)
z = z*fn3(1i*pi/2)

ELSEIF abs(tes) > 3*pi/4
z = z*fn4(1i*3*pi/2)

ENDIF
z = fn3(z)

ELSEIF @mode == 3

complex z = 0.2*fn1(pixel^@s)/zz

IF (imag(z)>0.5)
z = 2*real(z) + fn2(2*imag(z)*2)

ELSEIF (real(z)>0.5)
z = 2*real(z)/0.51 + fn3(2*imag(z))

ELSE
z = 2*real(z) + flip(2*imag(z))
z = fn4(z)

ENDIF

ENDIF

ELSEIF i > 2

z = z + zc

z = 1/sqrt(@r)*real(z) + 1i*sqrt(@r)*imag(z)

x = real(z)
y = imag(z)

IF abs(x) < 1/@s && abs(y - 1/@s) < 1/@s
bail = true

ENDIF

IF x < -1/@s && y < -x - 1/@s
z = 2*@s/(@s-1)*z + (@s+1)/(@s-1)

ELSEIF x > 1/@s && y < x - 1/@s
z = 2*@s/(@s-1)*z - (@s+1)/(@s-1)

ELSEIF x <= -1/@s && y > -x - 1/@s
z = z + 1/@s
z = z*fn3(-1i*pi/2)
z = @s*z - 1

ELSEIF x >= 1/@s && y > x - 1/@s
z = z - 1/@s
z = z*fn3(1i*pi/2)
z = @s*z + 1

ELSEIF abs(x) < 1/@s
z = @s*z - 2*1i

ENDIF

ENDIF

IF i <= 0.9
z = z - sp5

ELSEIF (imag(z)>0.5)
z = @ehe1*z - 1i

ELSEIF (real(z)>0.5)
z = @ehe2*z - 1

ELSE

IF @mode2 == 0
z = @fn5((@ehe3*z))

ELSEIF @mode2 == 1
z = @fn5(@ehe3*z + i)

ELSEIF @mode2 == 2
z = @fn5(@ehe3*z - i)

ELSEIF @mode2 == 3
z = @fn5(@ehe3*z + zc)

ELSEIF @mode2 == 4
z = @fn5(@ehe3*z - zc)

ELSEIF @mode2 == 5
z = @fn5(@ehe3*z + z)

ELSEIF @mode2 == 6
z = @fn5(@ehe3*z - z)

ENDIF

ENDIF

IF @mode1 == 0
z = z*sp6

ELSEIF @mode1 == 1
z = z/sp7

ELSEIF @mode1 == 2
z = z+sp8

ELSEIF @mode1 == 3
z = z^sp9

ENDIF

IF i > 2

z = z + @offset

z = 1/sqrt(@r)*real(z) + 1i*sqrt(@r)*imag(z)

x = real(z)
y = imag(z)

IF abs(x) < 1/@s && abs(y - 1/@s) < 1/@s
bail = true

ENDIF

IF x < -1/@s && y < -x - 1/@s
z = 2*@s/(@s-1)*z + (@s+1)/(@s-1)

ELSEIF x > 1/@s && y < x - 1/@s
z = 2*@s/(@s-1)*z - (@s+1)/(@s-1)

ELSEIF x <= -1/@s && y > -x - 1/@s
z = z + 1/@s
z = z*exp(-1i*pi/2)
z = @s*z - 1

ELSEIF x >= 1/@s && y > x - 1/@s
z = z - 1/@s
z = z*exp(1i*pi/2)
z = @s*z + 1

ELSEIF abs(x) < 1/@s
z = @s*z - 2*1i

ENDIF

ENDIF

bailout:

|z| < @bailout && bail == true

default:

title = "KPK EHE"
method = multipass
periodicity = 0

param bailout
caption = "Bailout"
default = 1000
endparam

param size
caption = "Fractalisation"
default = 1.0
hint = "You can also choose \
negative values"
endparam

param r
caption = "Stretcher"
default = 1.0
min = 1.0
endparam

param mode
caption = "Variation"
default = 0
enum = "Arranged" "Changed" "Flipped" "Fuzzed"
endparam

param spot
caption = "Spot Change"
default = false
endparam

param spot2
caption = "Circles?"
default = true
endparam

param spot3
caption = "Multiply Change"
default = true
endparam

param spot4
caption = "z Change"
default = true
endparam

param spot5
caption = "De-Pinskyfier"
default = true
endparam

param mode1
caption = "Mode"
default = 2
enum = "Product" "Quotient" "Sum" "Power"
endparam

param spot6
caption = "Product Spot"
hint = "Works together with the \
parameter Mode counterpart"
default = false
endparam

param spot7
caption = "Quotient Spot"
hint = "Works together with the \
parameter Mode counterpart"
default = true
endparam

param spot8
caption = "Sum Spot"
hint = "Works together with the \
parameter Mode counterpart"
default = true
endparam

param spot9
caption = "Power Spot"
hint = "Works together with the \
parameter Mode counterpart"
default = false
endparam

param offset
caption = "Offset"
default = (0,-1)
endparam

param s
caption = "Step Size"
default = 4.0
endparam

param rot
caption = "Rotation"
default = 0.0
endparam

param power1
caption = "Tiny Effects"
hint = "Surprisingly sometimes \
something happens"
default = 0.0
endparam

param ehe1
caption = "Modifier 1"
default = 2.0
endparam

param ehe2
caption = "Modifier 2"
default = 2.0
endparam

param ehe3
caption = "Modifier 3"
default = 2.0
endparam

param mode2
caption = "Deep Impact"
default = 0
enum = "None" "Errare" "Humanum" "Est" \
"What's" "Going" "On?"
endparam

func fn1
caption = "Function 1"
default = atanh()
endfunc

func fn2
caption = "Function 2"
default = sqrt()
endfunc

func fn3
caption = "Function 3"
default = exp()
endfunc

func fn4
caption = "Function 4"
default = abs()
endfunc

func fn5
caption = "Dan's Function"
default = ident()
endfunc

}

kpktts {
; Written by KPK April 2000
;
; With tweaked parts of Samuel Monnier's
; Squarry Koch Curve formula
;
; Spot effect after an idea of Andras Szolek
;
init:

i = 0
z = #pixel

z = z*exp(1i*pi/180*@rot)
zc = sqr(z/2)*0.7

z = 0.2*fn1(pixel^@spokes)

bool bail = true

x = real(z)
y = imag(z)

tes = fn1(z)

zz = x + fn1(y)

n = fn4(@power1^i)*zc

z = z/@size

IF @spot == true
sp = 2

ELSE
sp = 1

ENDIF

IF @spot2 == true
sp2 = abs(tes)

ELSE
sp2 = sqrt(tes)

ENDIF

IF @spot3 == true
sp3 = 1/fn2(@r)*real(z) + 1i*fn2(@r)*imag(z)+n

ELSE
sp3 = 1/fn2(@r)*imag(z) + 2i*fn2(@r)*real(z)*n

ENDIF

IF @spot4 == true
sp4 = 1/sqrt(2)*z*exp(1i*pi/4)

ELSE
sp4 = 1/fn2(@r)*imag(z)*(2i*fn2(@r)*real(z)*n)+n

ENDIF

IF @spot5 == true
sp5 = @offset

ELSE
sp5 = @offset/zc

ENDIF

IF @spot6 == true
sp6 = zc

ELSE
sp6 = (zc-zz)

ENDIF

IF @spot7 == true
sp7 = 1/@s

ELSE
sp7 = (-1/@s)

ENDIF

loop:

i = i + 1

n = fn4(@power1^i)*zc

bool bail = true

IF i == 2
z = sp3

IF @mode == 0

IF |x| < 1 && |y| < 1
bail = true

ENDIF

IF sp2 < pi/4
z = z*fn3(1i*pi/2)*sp

ELSEIF (tes < -pi/4) && (tes > -3*pi/4)
z = z*fn3(1i*pi)

ELSEIF abs(tes) > 3*pi/4
z = z*fn3(1i*3*pi/2)

ENDIF

z = z - 1i

ELSEIF @mode == 1

z = sp4
x = real(z)
y = imag(z)

IF |x| > 1 || |y| > 1
bail = true

ENDIF

tes = fn1(z)

IF sp2 < pi/4
z = z*fn3(1i*pi/2)*sp

ELSEIF (tes < -pi/4) && (tes > -3*pi/4)
z = z*fn3(1i*pi)

ELSEIF abs(tes) > 3*pi/4
z = z*fn3(1i*3*pi/2)

ENDIF

z = -z + 1i

ELSEIF @mode == 2

n = (2^i)*z
zi = fn3(z*n)/2*n
z = n*(z / zi)
z = (1/@r^0.5*real(z) + @r^0.5*imag(z)*1i)/@s
z = fn4(zz)*fn3(1i*i*@rot/180*pi/.25)

IF |x| < 1 && |y| < 1
bail = true

ENDIF

IF sp2 < pi/4
z = z*fn1(1i*pi/4)*sp

ELSEIF (tes < -pi/4) && (tes > -3*pi/4)
z = z*fn3(1i*pi/2)

ELSEIF abs(tes) > 3*pi/4
z = z*fn4(1i*3*pi/2)

ENDIF
z = fn3(z)

ELSEIF @mode == 3

complex z = 0.2*fn1(pixel^@s)^zz

IF (imag(z)>0.5)
z = 2*real(z) + fn2(2*imag(z)*2)

ELSEIF (real(z)>0.5)
z = 2*real(z)/0.51 + fn3(2*imag(z))

ELSE
z = 2*real(z) + flip(2*imag(z))
z = fn4(z)

ENDIF

ENDIF

ELSEIF i > 2

z = z + sp6

z = 1/fn1(@r)*real(z) - 1i/fn1(@r)*imag(z)

x = real(z)
y = imag(z)

IF abs(x) < 1/@s && abs(y - 1/@s) < 1/@s
bail = true

ENDIF

IF x < -1/@s && y < -x - 1/@s
z = 2*@s/(@s-1)*z + (@s+1)/(@s-1)

ELSEIF x > 1/@s && y < x + sp7
z = 2*@s/(@s-1)*z - (@s+1)/(@s-1)

ELSEIF x <= -1/@s && y > -x + sp7
z = z + 1/@s
z = z*fn3(-1i*pi/2)
z = @s*z - 1

ELSEIF x >= 1/@s && y > x - 1/@s
z = z - 1/@s
z = z*fn3(1i*pi/2)
z = @s*z + 1

ELSEIF abs(x) < 1/@s
z = @s*z - 2*1i

ENDIF

ENDIF

IF i >= 2

z = (z-zc) +sp5

ENDIF

bailout:

|z| < @bailout && bail == true

default:

title = "KPK TTS"
method = multipass
periodicity = 0

param bailout
caption = "Bailout"
default = 10000
endparam

param r
caption = "Stretcher"
default = 1.0
min = -1.0
endparam

param size
caption = "Fractalisation"
default = 1.0
hint = "You can also choose \
negative values"
endparam

param mode
caption = "Variation"
default = 1
enum = "Arranged" "Changed" "Flipped" "Fuzzed" "none"
endparam

param spot
caption = "Spot Change"
default = true
endparam

param spot2
caption = "Circles"
default = false
endparam

param spot3
caption = "Multiply Change"
default = false
endparam

param spot4
caption = "z Change"
default = true
endparam

param spot5
caption = "Last  Change"
default = false
endparam

param spot6
caption = "Loop  Change 1"
default = true
endparam

param spot7
caption = "Loop  Change 2"
default = true
endparam

param spokes
caption = "Bending"
default = 1.0
endparam

param offset
caption = "Offset"
default = (0,0)
endparam

param rot
caption = "Rotation"
default = 0.0
endparam

param power1
caption = "Tiny Effects"
hint = "Surprisingly sometimes \
something happens"
default = 0.0
endparam

param s
caption = "Design Step"
default = 2.0
endparam

func fn1
caption = "Function 1"
default = abs()
endfunc

func fn2
caption = "Function 2"
default = ident()
endfunc

func fn3
caption = "Function 3"
default = conj()
endfunc

func fn4
caption = "Function 4"
default = atan()
endfunc
}

Pinskyfamilyzc {
; From Samuel Monnier's Julifamily
;
; Modified by KPK, December 1999
;
; Enhanced by Samuel Monnier, March 2000
;
; Revision August 6, 2000
;
init:
complex z = pixel
int i = 0
z = z - @tilem
z = z*exp(1i*pi/180*@rottile)
zc = round(z/@sizesq)*@sizesq
z = z*exp(-1i*pi/180*@rottile)
zc = zc*exp(-1i*pi/180*@rottile)
z = z - @tilem
zc = zc - @tilem
z = 2*(z - zc)/@sizesq + @center
z = z/@magn
z = z*exp(1i*pi/180*@rot)

loop:
i = i + 1

if (imag(z)>0.5)
z = 2*z - 1i
elseif (real(z)>0.5)
z = 2*z - 1
else
z = 2*z
endif

if @mode == 0
z = z*zc
elseif @mode == 1
z = z/zc
elseif @mode == 2
z = z+zc
elseif @mode == 3
z = z^zc
endif

bailout:
(@test == 0 && |z| <= @bailout) ||                                         \
(@test == 1 && sqr(real(z)) <= @bailout) ||                                \
(@test == 2 && sqr(imag(z)) <= @bailout) ||                                \
(@test == 3 && (sqr(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (sqr(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (sqr(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (sqr(real(z) + imag(z)) <= @bailout))

default:
title = "Pinskyfamily zc"
magn = 1.5
maxiter = 500

param mode
caption = "Mode"
default = 0
enum = "Product" "Quotient" "Sum" "Power"
endparam

param center
caption = "Center"
default = (.2,.2)
endparam

param magn
caption = "Magnification"
default = 1.0
endparam

param rot
caption = "Rotation"
default = 0.0
endparam

param tilem
caption = "Tiling translation"
default = (0,0)
endparam

param sizesq
caption = "Size of the tiles"
default = 0.6
endparam

param rottile
caption = "Rotation of the Tiling"
default = 0.0
endparam

param bailout
caption = "Bailout"
default = 1e20
endparam

param test
caption = "Shape Modifier"
default = 0
enum = "mod" "real" "imag" "or" "and" "manh" "manr"
endparam
}

kpksts {
; Written by KPK May 2000
;
;Basic code from Samuel Monnier's
;Trapinsky and Squarry Koch Curve used
;
; Spot effect after an idea of Andras Szolek
;
init:

i = 0
z = #pixel
x = fn1(real(z))
y = fn2(imag(z))

zc = fn1(z/2)*0.7

zz = x + flip(y)

complex z = 0.2*fn1(pixel^@spokes)

float arg = atan2(z)

tes = fn1(z)

bool bail = false
bool bail2 = false
bool nobail = true

IF @spot == true
sp = 2

ELSE
sp = 1

ENDIF

IF @spot2 == true
sp2 = 1i

ELSE
sp2 = 1i/zc

ENDIF

IF @spot3 == true
sp3 = abs(tes)

ELSE
sp3 = sqrt(tes)

ENDIF

IF @spot4 == true
sp4 = z

ELSE
sp4 = z/zc

ENDIF

IF @spot5 == true
sp5 = @offset

ELSE
sp5 = @offset/zc

ENDIF

IF @spot6 == true
sp6 = zc

ELSE
sp6 = (zc-zz)

ENDIF

IF @spot7 == true
sp7 = 1/@s

ELSE
sp7 = (-1/@s)

ENDIF

loop:

z = fn3(zz)*exp(1i*i*@rotst/180*pi)

n = @disto^i
zi = @g3(z*n)/n
z = n*(z-zi)

i = i + 1

z = (1/@r^0.5*real(z) + @r^0.5*imag(z)*1i)/@size
z = z*exp(-1i*@rot/180*pi)

IF @mode == 0

IF @invert
z = 1/z
ENDIF

x = real(z)
y = imag(z)

bool nobail = true

IF @shape == 0
IF @inside == 0
IF !(|z| > 1)
nobail = false
ENDIF
ELSEIF @inside == 1
IF !(|z| < 1)
nobail = false
ENDIF
ENDIF
ENDIF

IF @shape == 1
IF @inside == 1
IF !(@g0(real(z)) > 1 || @g0(imag(z)) > 1)
nobail = false
ENDIF
ELSEIF @inside == 0
IF !(@g0(real(z)) < 1 || @g0(imag(z)) < 1)
nobail = false
ENDIF
ENDIF
ENDIF

IF @shape == 2
IF @inside == 1
IF !(@g0a(real(z))^@n + @g0a(imag(z))^@n > 1)
nobail = false
ENDIF
ELSEIF @inside == 0
IF !(@g0a(real(z))^@n + @g0a(imag(z))^@n < 1)
nobail = false
ENDIF
ENDIF
ENDIF

IF @shape == 3
IF @inside == 1
IF !(|y - x^2| > @thresh)
nobail = false
ENDIF
ELSEIF @inside == 0
IF !(|y - x^2| < @thresh)
nobail = false
ENDIF
ENDIF
ENDIF

IF @shape == 4
IF @inside == 1
IF !(|y - 1/x| > @thresh)
nobail = false
ENDIF
ELSEIF @inside == 0
IF !(|y - 1/x| < @thresh)
nobail = false
ENDIF
ENDIF
ENDIF

IF @shape == 5
pin = atan2(z)
IF pin < 0
pin = pin + 2*pi
ENDIF
IF @inside == 1
IF !(|sqrt(cabs(z))/abs(sin(pin*@n/2))| > @thresh)
nobail = false
ENDIF
ELSEIF @inside == 0
IF !(|sqrt(cabs(z))/abs(sin(pin*@n/2))| < @thresh)
nobail = false
ENDIF
ENDIF
ENDIF

IF @shape == 6
IF @inside == 1
IF !(|y^2 - x^3| > @thresh)
nobail = false
ENDIF
ELSEIF @inside == 0
IF !(|y^2 - x^3| < @thresh)
nobail = false
ENDIF
ENDIF
ENDIF

IF @shape == 7
IF @inside == 1
IF !(|y - @n*x| > @thresh)
nobail = false
ENDIF
ELSEIF @inside == 0
IF !(|y - @n*x| < @thresh)
nobail = false
ENDIF
ENDIF
ENDIF

IF @shape == 8
IF @inside == 1
IF !(|(y + @n*x)*(y + 1/@n*x)| > @thresh)
nobail = false
ENDIF
ELSEIF @inside == 0
IF !(|(y + @n*x)*(y + 1/@n*x)| < @thresh)
nobail = false
ENDIF
ENDIF
ENDIF

IF @shape == 9
IF @inside == 1
IF !(x^2 * (@n + x)/(@n - x) - y^2 > @thresh)
nobail = false
ENDIF
ELSEIF @inside == 0
IF !(x^2 * (@n + x)/(@n - x) - y^2 < @thresh)
nobail = false
ENDIF
ENDIF
ENDIF

IF @shape == 10
IF @inside == 1
IF !(|(x^2 + y^2)^2 - @n^2*(x^2 - y^2)| > @thresh)
nobail = false
ENDIF
ELSEIF @inside == 0
IF !(|(x^2 + y^2)^2 - @n^2*(x^2 - y^2)| < @thresh)
nobail = false
ENDIF
ENDIF
ENDIF

IF @shape == 11
IF @inside == 1
IF !(|y - (1/(1 + x^2))| > @thresh)
nobail = false
ENDIF
ELSEIF @inside == 0
IF !(|y - (1/(1 + x^2))| < @thresh)
nobail = false
ENDIF
ENDIF
ENDIF

IF @shape == 12
IF @inside == 1
IF !(|@g2(y) - @g1(x)| > @thresh)
nobail = false
ENDIF
ELSEIF @inside == 0
IF !(|@g2(y) - @g1(x)| < @thresh)
nobail = false
ENDIF
ENDIF
ENDIF

IF @shape == 13
IF @inside == 1
IF !(abs(real(z)) > 1 && abs(imag(z)) > 1)
nobail = false
ENDIF
ELSEIF @inside == 0
IF !(abs(real(z)) < 1 && abs(imag(z)) < 1)
nobail = false
ENDIF
ENDIF
ENDIF

ELSEIF @mode == 1

bool bail = false

IF i < 2
z = 1/fn4(@ra)*real(z) + 1i*fn4(@ra)*imag(z)

IF @modi == 0

IF |x| < 1 && |y| < 1
bail = true
ENDIF

IF abs(arg) < pi/4
z = z*exp(1i*pi/2)
ELSEIF (arg < -pi/4) && (arg > -3*pi/4)
z = z*exp(1i*pi)
ELSEIF abs(arg) > 3*pi/4
z = z*exp(1i*3*pi/2)
ENDIF
z = z - sp2

ELSEIF @modi == 1

z = 1/fn4(2)*z*exp(1i*pi/4)
x = real(z)
y = imag(z)

IF |x| > 1 || |y| > 1
bail = true
ENDIF

arg = atan2(z)

IF abs(arg) < pi/4
z = z*exp(1i*pi/2)
ELSEIF (arg < -pi/4) && (arg > -3*pi/4)
z = z*exp(1i*pi)
ELSEIF abs(arg) > 3*pi/4
z = z*exp(1i*3*pi/2)
ENDIF
z = -z + sp2

ENDIF

ELSEIF i > 2

z = z + sp6

z = 1/fn1(@ra)*real(z) - 1i*fn1(@ra)*imag(z)

bool bail2 = false

x = real(z)
y = imag(z)

IF abs(x) < 1/@s && abs(y - 1/@s) < 1/@s
bail2 = true

ENDIF

IF x < -1/@s && y < -x - 1/@s
z = 2*@s/(@s-1)*z + (@s+1)/(@s-1)

ELSEIF x > 1/@s && y < x + sp7
z = 2*@s/(@s-1)*z - (@s+1)/(@s-1)

ELSEIF x <= -1/@s && y > -x + sp7
z = z + 1/@s
z = z*fn3(-1i*pi/2)
z = @s*z - 1

ELSEIF x >= 1/@s && y > x - 1/@s
z = z - 1/@s
z = z*fn3(1i*pi/2)
z = @s*z + 1

ELSEIF abs(x) < 1/@s
z = @s*z - 2*1i
ENDIF

ENDIF

ELSEIF @mode == 2

z = 1/@g2a(2)*z*@g2b(1i*pi/4)
x = real(z)
y = imag(z)

IF |x| > 1 || |y| > 1
bail = true

ENDIF

tes = fn1(z)

IF sp3 < pi/4
z = z*fn3(1i*pi/2)*sp

ELSEIF (tes < -pi/4) && (tes > -3*pi/4)
z = z*fn3(1i*pi)

ELSEIF abs(tes) > 3*pi/4
z = z*fn3(1i*3*pi/2)

ENDIF

z = -z + 1i

IF (imag(z)>@sir1)
z = @sir2*real(z) + flip(@sir2*imag(z)-1)

ELSEIF (real(z)>@sir1)
z = @sir2*real(z)-1 + flip(@sir2*imag(z))

ELSE
z = @sir2*real(z) + flip(@sir2*imag(z))
z = fn2( sp4 )

ENDIF

ENDIF

IF i >= 2

z = (z - zc) + sp5

ENDIF

bailout:
|z| < @bailout  && nobail == true && bail == false && bail2 == false

default:
title = "KPK STS"
method = multipass
periodicity = 0

param bailout
caption = "Bailout"
default = 1000
endparam

param mode
caption = "Variation"
default = 1
enum = "Trappy" "Squarry" "Sierpy"
hint = "Play with Overall Funct. 4"
endparam

param shape
caption = "Trappy Shape"
default = 1
enum = "Circles" "Squares"  \
"Astroïd" "Parabola" \
"Hyperbola" "Pinch" "SC Parabola" "Line" \
"Cross" "Strophoïd" "Lemniscate" \
"Agnesi's Curve" "Graph" "Cross 2"
endparam

param modi
caption = "Squarry Modi"
default = 1
enum = "Outside" "Inside"
endparam

param s
caption = "Steppy"
default = 4.0
endparam

param offset
caption = "Offset"
default = (0,-1)
endparam

param sir1
caption = "Sierpy Noise"
default = 1
endparam

param sir2
caption = "Sierpy Transform"
default = 2.0
endparam

param ra
caption = "Squarry Twist"
default = (1,0)
endparam

param spokes
caption = "Sir P. Param"
default = 5
endparam

param size
caption = "Texture Factor"
default = 1.0
endparam

param rot
caption = "Shape Rotation"
default = 0.0
endparam

param r
caption = "Ratio Width/Height"
default = 1.0
endparam

param n
caption = "Trappy Param"
default = 0.5
endparam

param thresh
caption = "Trappy Threshold"
default = 0.2
endparam

param rotst
caption = "Rotation step"
default = 0.0
endparam

param inside
caption = "Trappy Modi"
default = 1
enum = "Outside" "Inside"
endparam

param disto
caption = "Shape Change"
default = 2.0
endparam

param invert
caption = "Invert z"
default = true
endparam

param spot
caption = "Spot Change"
default = false
endparam

param spot2
caption = "Spotty"
default = true
endparam

param spot3
caption = "Changy"
default = true
endparam

param spot4
caption = "Inverty"
default = true
endparam

param spot5
caption = "Last  Change"
default = false
endparam

param spot6
caption = "Loop  Change 1"
default = true
endparam

param spot7
caption = "Loop  Change 2"
default = true
endparam

func g0
caption = "Trappy Fct. Square"
default = sqrt()
endfunc

func g0a
caption = "Trappy Fct. Astro"
default = abs()
endfunc

func g1
caption = "Trappy Funct. 1"
default = sin()
endfunc

func g2
caption = "Trappy Funct. 2"
default = ident()
endfunc

func g2a
caption = "Sierpy Funct. 1"
default = sqrt()
endfunc

func g2b
caption = "Sierpy Funct. 2"
default = exp()
endfunc

func fn1
caption = "Overall Funct. 1"
default = abs()
endfunc

func fn2
caption = "Overall Funct. 2"
default = ident()
endfunc

func fn3
caption = "Overall Funct. 3"
default = ident()
endfunc

func g3
caption = "Overall Funct. 4"
default = sqrt()
endfunc

func fn4
caption = "Squarry Function"
default = sqrt()
endfunc
}

kpkststt {
; Written by KPK May 2000
;
; Basic code from Samuel Monnier's
; Trapinsky and Squarry Koch Curve used
;
; Spot effect after an idea of Andras Szolek
;
init:

complex z = pixel
int  i = 0

z = z*exp(1i*pi/180*@rottile)
zc = round(z/@sizesq)*@sizesq
z = z*exp(-1i*pi/180*@rottile)
zc = zc*exp(-1i*pi/180*@rottile)
z = 2*(z - zc)/@sizesq + @center
z = z/@magn
z = z*exp(1i*pi/180*@rot2)

x = fn1(real(z))
y = fn2(imag(z))

zc = fn1(z/2)*0.7

zz = x + flip(y)

complex z = 0.2*fn1(pixel^@spokes)

float arg = atan2(z)

tes = fn1(z)

bool bail = false
bool bail2 = false
bool nobail = true

IF @spot == true
sp = 2

ELSE
sp = 1

ENDIF

IF @spot2 == true
sp2 = 1i

ELSE
sp2 = 1i/zc

ENDIF

IF @spot3 == true
sp3 = abs(tes)

ELSE
sp3 = sqrt(tes)

ENDIF

IF @spot4 == true
sp4 = z

ELSE
sp4 = z/zc

ENDIF

IF @spot5 == true
sp5 = @offset

ELSE
sp5 = @offset/zc

ENDIF

IF @spot6 == true
sp6 = zc

ELSE
sp6 = (zc-zz)

ENDIF

IF @spot7 == true
sp7 = 1/@s

ELSE
sp7 = (-1/@s)

ENDIF

loop:

z = fn3(zz)*exp(1i*i*@rotst/180*pi)

n = @disto^i
zi = @g3(z*n)/n
z = n*(z-zi)

i = i + 1

z = (1/@r^0.5*real(z) + @r^0.5*imag(z)*1i)/@size
z = z*exp(-1i*@rot/180*pi)

IF (imag(z)>0.5)
z = 2*z - 1i

ELSEIF (real(z)>0.5)
z = 2*z - 1

ELSE
z = 2*z

ENDIF

IF @modo == 0
z = z*zc

ELSEIF @modo == 1
z = z/zc

ELSEIF @modo == 2
z = z+zc

ELSEIF @modo == 3
z = z^zc

ENDIF

IF @mode == 0

IF @invert
z = 1/z
ENDIF

x = real(z)
y = imag(z)

bool nobail = true

IF @shape == 0
IF @inside == 0
IF !(|z| > 1)
nobail = false
ENDIF
ELSEIF @inside == 1
IF !(|z| < 1)
nobail = false
ENDIF
ENDIF
ENDIF

IF @shape == 1
IF @inside == 1
IF !(@g0(real(z)) > 1 || @g0(imag(z)) > 1)
nobail = false
ENDIF
ELSEIF @inside == 0
IF !(@g0(real(z)) < 1 || @g0(imag(z)) < 1)
nobail = false
ENDIF
ENDIF
ENDIF

IF @shape == 2
IF @inside == 1
IF !(@g0a(real(z))^@n + @g0a(imag(z))^@n > 1)
nobail = false
ENDIF
ELSEIF @inside == 0
IF !(@g0a(real(z))^@n + @g0a(imag(z))^@n < 1)
nobail = false
ENDIF
ENDIF
ENDIF

IF @shape == 3
IF @inside == 1
IF !(|y - x^2| > @thresh)
nobail = false
ENDIF
ELSEIF @inside == 0
IF !(|y - x^2| < @thresh)
nobail = false
ENDIF
ENDIF
ENDIF

IF @shape == 4
IF @inside == 1
IF !(|y - 1/x| > @thresh)
nobail = false
ENDIF
ELSEIF @inside == 0
IF !(|y - 1/x| < @thresh)
nobail = false
ENDIF
ENDIF
ENDIF

IF @shape == 5
pin = atan2(z)
IF pin < 0
pin = pin + 2*pi
ENDIF
IF @inside == 1
IF !(|sqrt(cabs(z))/abs(sin(pin*@n/2))| > @thresh)
nobail = false
ENDIF
ELSEIF @inside == 0
IF !(|sqrt(cabs(z))/abs(sin(pin*@n/2))| < @thresh)
nobail = false
ENDIF
ENDIF
ENDIF

IF @shape == 6
IF @inside == 1
IF !(|y^2 - x^3| > @thresh)
nobail = false
ENDIF
ELSEIF @inside == 0
IF !(|y^2 - x^3| < @thresh)
nobail = false
ENDIF
ENDIF
ENDIF

IF @shape == 7
IF @inside == 1
IF !(|y - @n*x| > @thresh)
nobail = false
ENDIF
ELSEIF @inside == 0
IF !(|y - @n*x| < @thresh)
nobail = false
ENDIF
ENDIF
ENDIF

IF @shape == 8
IF @inside == 1
IF !(|(y + @n*x)*(y + 1/@n*x)| > @thresh)
nobail = false
ENDIF
ELSEIF @inside == 0
IF !(|(y + @n*x)*(y + 1/@n*x)| < @thresh)
nobail = false
ENDIF
ENDIF
ENDIF

IF @shape == 9
IF @inside == 1
IF !(x^2 * (@n + x)/(@n - x) - y^2 > @thresh)
nobail = false
ENDIF
ELSEIF @inside == 0
IF !(x^2 * (@n + x)/(@n - x) - y^2 < @thresh)
nobail = false
ENDIF
ENDIF
ENDIF

IF @shape == 10
IF @inside == 1
IF !(|(x^2 + y^2)^2 - @n^2*(x^2 - y^2)| > @thresh)
nobail = false
ENDIF
ELSEIF @inside == 0
IF !(|(x^2 + y^2)^2 - @n^2*(x^2 - y^2)| < @thresh)
nobail = false
ENDIF
ENDIF
ENDIF

IF @shape == 11
IF @inside == 1
IF !(|y - (1/(1 + x^2))| > @thresh)
nobail = false
ENDIF
ELSEIF @inside == 0
IF !(|y - (1/(1 + x^2))| < @thresh)
nobail = false
ENDIF
ENDIF
ENDIF

IF @shape == 12
IF @inside == 1
IF !(|@g2(y) - @g1(x)| > @thresh)
nobail = false
ENDIF
ELSEIF @inside == 0
IF !(|@g2(y) - @g1(x)| < @thresh)
nobail = false
ENDIF
ENDIF
ENDIF

IF @shape == 13
IF @inside == 1
IF !(abs(real(z)) > 1 && abs(imag(z)) > 1)
nobail = false
ENDIF
ELSEIF @inside == 0
IF !(abs(real(z)) < 1 && abs(imag(z)) < 1)
nobail = false
ENDIF
ENDIF
ENDIF

ELSEIF @mode == 1

bool bail = false

IF i < 2
z = 1/fn4(@ra)*real(z) + 1i*fn4(@ra)*imag(z)

IF @modi == 0

IF |x| < 1 && |y| < 1
bail = true

ENDIF

IF abs(arg) < pi/4
z = z*exp(1i*pi/2)

ELSEIF (arg < -pi/4) && (arg > -3*pi/4)
z = z*exp(1i*pi)

ELSEIF abs(arg) > 3*pi/4
z = z*exp(1i*3*pi/2)

ENDIF
z = z - sp2

ELSEIF @modi == 1

z = 1/fn4(2)*z*exp(1i*pi/4)
x = real(z)
y = imag(z)

IF |x| > 1 || |y| > 1
bail = true
ENDIF

arg = atan2(z)

IF abs(arg) < pi/4
z = z*exp(1i*pi/2)

ELSEIF (arg < -pi/4) && (arg > -3*pi/4)
z = z*exp(1i*pi)

ELSEIF abs(arg) > 3*pi/4
z = z*exp(1i*3*pi/2)

ENDIF
z = -z + sp2

ENDIF

ELSEIF i > 2

z = z + sp6

z = 1/fn1(@ra)*real(z) - 1i*fn1(@ra)*imag(z)

bool bail2 = false

x = real(z)
y = imag(z)

IF abs(x) < 1/@s && abs(y - 1/@s) < 1/@s
bail2 = true

ENDIF

IF x < -1/@s && y < -x - 1/@s
z = 2*@s/(@s-1)*z + (@s+1)/(@s-1)

ELSEIF x > 1/@s && y < x + sp7
z = 2*@s/(@s-1)*z - (@s+1)/(@s-1)

ELSEIF x <= -1/@s && y > -x + sp7
z = z + 1/@s
z = z*fn3(-1i*pi/2)
z = @s*z - 1

ELSEIF x >= 1/@s && y > x - 1/@s
z = z - 1/@s
z = z*fn3(1i*pi/2)
z = @s*z + 1

ELSEIF abs(x) < 1/@s
z = @s*z - 2*1i

ENDIF

ENDIF

ELSEIF @mode == 2

z = 1/@g2a(2)*z*@g2b(1i*pi/4)
x = real(z)
y = imag(z)

IF |x| > 1 || |y| > 1
bail = true

ENDIF

tes = fn1(z)

IF sp3 < pi/4
z = z*fn3(1i*pi/2)*sp

ELSEIF (tes < -pi/4) && (tes > -3*pi/4)
z = z*fn3(1i*pi)

ELSEIF abs(tes) > 3*pi/4
z = z*fn3(1i*3*pi/2)

ENDIF

z = -z + 1i

IF (imag(z)>@sir1)
z = @sir2*real(z) + flip(@sir2*imag(z)-1)

ELSEIF (real(z)>@sir1)
z = @sir2*real(z)-1 + flip(@sir2*imag(z))

ELSE
z = @sir2*real(z) + flip(@sir2*imag(z))
z = fn2( sp4 )

ENDIF

ENDIF

IF i >= 2

z = (z - zc) + sp5

ENDIF

bailout:
|z| < @bailout  && nobail == true && bail == false && bail2 == false

default:
title = "KPK STS TT"
method = multipass
periodicity = 0

param bailout
caption = "Bailout"
default = 1000
endparam

param mode
caption = "Variation"
default = 2
enum = "Trappy" "Squarry" "Sierpy"
hint = "Play with Overall Funct. 4"
endparam

param modo
caption = "Taste"
default = 2
enum = "Product" "Quotient" "Sum" "Power"
endparam

param shape
caption = "Trappy Shape"
default = 1
enum = "Circles" "Squares"  \
"Astroïd" "Parabola" \
"Hyperbola" "Pinch" "SC Parabola" "Line" \
"Cross" "Strophoïd" "Lemniscate" \
"Agnesi's Curve" "Graph" "Cross 2"
endparam

param modi
caption = "Squarry Modi"
default = 1
enum = "Outside" "Inside"
endparam

param s
caption = "Steppy"
default = 4.0
endparam

param offset
caption = "Offset"
default = (0.0,0.0)
endparam

param sir1
caption = "Sierpy Noise"
default = 0.5
endparam

param sir2
caption = "Sierpy Transform"
default = 2.0
endparam

param ra
caption = "Squarry Twist"
default = (1,0)
endparam

param spokes
caption = "Sir P. Param"
default = 5
endparam

param size
caption = "Texture Factor"
default = 1.0
endparam

param rot
caption = "Shape Rotation"
default = 0.0
endparam

param r
caption = "Ratio Width/Height"
default = 1.0
endparam

param n
caption = "Trappy Param"
default = 0.5
endparam

param thresh
caption = "Trappy Threshold"
default = 0.2
endparam

param center
caption = "Center"
default = (.2,.2)
endparam

param magn
caption = "Magnification"
default = 1.0
endparam

param rot2
caption = "Rotation"
default = 0.0
endparam

param sizesq
caption = "Size of the tiles"
default = 10
endparam

param rottile
caption = "Rotation of the Tiling"
default = 0.0
endparam

param rotst
caption = "Rotation step"
default = 45.0
endparam

param inside
caption = "Trappy Modi"
default = 1
enum = "Outside" "Inside"
endparam

param disto
caption = "Shape Change"
default = 2.0
endparam

param invert
caption = "Invert z"
default = true
endparam

param spot
caption = "Spot Change"
default = false
endparam

param spot2
caption = "Spotty"
default = true
endparam

param spot3
caption = "Changy"
default = true
endparam

param spot4
caption = "Inverty"
default = true
endparam

param spot5
caption = "Last  Change"
default = false
endparam

param spot6
caption = "Loop  Change 1"
default = true
endparam

param spot7
caption = "Loop  Change 2"
default = true
endparam

func g0
caption = "Trappy Fct. Square"
default = sqrt()
endfunc

func g0a
caption = "Trappy Fct. Astro"
default = abs()
endfunc

func g1
caption = "Trappy Funct. 1"
default = sin()
endfunc

func g2
caption = "Trappy Funct. 2"
default = ident()
endfunc

func g2a
caption = "Sierpy Funct. 1"
default = sqrt()
endfunc

func g2b
caption = "Sierpy Funct. 2"
default = exp()
endfunc

func fn1
caption = "Overall Funct. 1"
default = abs()
endfunc

func fn2
caption = "Overall Funct. 2"
default = ident()
endfunc

func fn3
caption = "Overall Funct. 3"
default = ident()
endfunc

func g3
caption = "Overall Funct. 4"
default = abs()
endfunc

func fn4
caption = "Squarry Function"
default = sqrt()
endfunc
}

kpkangle3 {
; Written by KPK May, 2000
;
; Basics by Samuel Monnier
;
; Additional ideas by Andreas Lober
;
; Revised version 6 August 2000
init:

complex z = 0.2*fn1(pixel^@spokes)

zc = fn1(z/2)*p1

float arg = 0

loop:

IF @mode == 0

arg = atan2(z)

IF (@g1(arg)<pi/4)
z = @factor*real(z) + fn3(@factor*imag(z)-1)
z = z*fn4(1i*pi/2)

ELSEIF (imag(z) > @corte)
z = @factor*real(z) - fn3(@factor*imag(z)-1)
z = z*fn4(1i*3*pi/2)

ELSEIF (arg < -pi/4) && (arg > -3*pi/4)
z = z*fn4(1i*pi)

ELSEIF (@g1(arg)>3*pi/4)
z = @factor*real(z)-1 + fn3(@factor*imag(z))

ELSEIF (real(z) > @corte)
z = @factor*real(z) + fn3(@factor*imag(z)-1)

ELSE
z = @factor*real(z) + fn3(@factor*imag(z))
z = @fn2( z )

ENDIF

IF @modo == 0
z = z-zc

ELSEIF @modo == 1
z = z/zc

ELSEIF @modo == 2
z = z+zc

ELSEIF @modo == 3
z = (z+zc)^pi

ENDIF

ELSEIF @mode == 1

arg = atan2(z)

IF (@g1(arg)<pi/4)
z = @factor*real(z) + fn3(@factor*imag(z)-1)
z = z*fn4(1i*pi/2)

ELSEIF (arg < -pi/4) && (arg > -3*pi/4)
z = z*fn4(1i*pi)

ELSEIF (@g1(arg)>3*pi/4)
z = z*fn4(3*1i*pi/2)
z = @factor*real(z)-1 + fn3(@factor*imag(z))

ELSE
z = @factor*real(z) + fn3(@factor*imag(z))
z = @fn2( z )

ENDIF

IF @modo == 0
z = z-zc

ELSEIF @modo == 1
z = z/zc

ELSEIF @modo == 2
z = z+zc

ELSEIF @modo == 3
z = (z+zc)^pi

ENDIF

z =-z+1i

ENDIF

bailout:
(@test == 0 && |z| <= @bailout) ||                                         \
(@test == 1 && sqr(real(z)) <= @bailout) ||                                \
(@test == 2 && sqr(imag(z)) <= @bailout) ||                                \
(@test == 3 && (sqr(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (sqr(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (sqr(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (sqr(real(z) + imag(z)) <= @bailout))

default:
title = "KPK Angel 3"
center = (0.2, 0.2)
magn = 1.0
periodicity = 0

param bailout
caption = "Bailout value"
default = 127
min = 1
endparam

param test
caption = "Shape Modifier"
default = 0
enum = "mod" "real" "imag" "or" "and" "manh" "manr"
endparam

param mode
caption = "Variation"
default = 0
enum = "Earl P." "Sir P."
endparam

param p1
caption = "Shape Change"
default = (0.7,0.0)
endparam

param modo
caption = "Taste"
default = 2
enum = "Difference" "Quotient" "Sum" "Power"
endparam

param factor
caption = "Transform Factor"
default = 2.0
endparam

param spokes
caption = "Number of Spokes"
default = 4
endparam

param corte
caption = "Structure Width"
default = 0.5
endparam

func g1
caption = "Inner Secret"
default = sqr()
endfunc

func fn1
caption = "Function 1"
default = sqrt()
hint = "Shape of the Wings"
endfunc

func fn2
caption = "Function 2"
default = ident()
endfunc

func fn3
caption = "Function 3"
default = flip()
endfunc

func fn4
caption = "Function 4"
default = exp()
endfunc
}

KPKlsk {
;
; Written by KPK May, 2000
;
; With ideas from Andreas Lober,
; and Samuel Monnier
;
; Revised version 6 August 2000
init:

complex z = pixel^@spokes

int i = 0

int iter = 0

z = z - @tilem
z = z*exp(1i*pi/180*@rot)

z = z*exp(-1i*pi/180*@rottile)
z = fn1(z/@sizesq)*@sizesq

IF @spot == true
sp = 2

ELSE
sp = 2^z

ENDIF

loop:

iter = iter + 1
i = i + 1

IF @mode == 0

IF (imag(z)>0.5)
z = 2*z - 1i

ELSEIF (real(z)>0.5)
z = 2*z -1

ELSE

IF (imag(z) > @corte/iter)
z = 2*(z - iter*1i/(1+iter))

ELSEIF (real(z) > @corte/iter)
z = 2*(z - iter/(1+iter))

ELSE

IF (@taste == 0)
z = z^iter + #pixel

ELSEIF (@taste == 1)
z = #pixel^iter + z

ELSEIF (@taste == 2)
z = #pixel^iter + (z - iter*1i/(1+iter))

ENDIF

z = @last(z)*sp

ENDIF
ENDIF

ELSEIF @mode == 1

IF (imag(z) > @corte/iter)
z = 2*(z - iter*1i/(1+iter))

ELSEIF (real(z) > @corte/iter)
z = 2*(z - iter/(1+iter))

ELSE

IF (@taste == 0)
z = z^iter + #pixel

ELSEIF (@taste == 1)
z = #pixel^iter + z

ELSEIF (@taste == 2)
z = #pixel^iter + (z - iter*1i/(1+iter))

ENDIF

z = @last(z)*sp

ENDIF
ENDIF

bailout:
(@test == 0 && |z| <= @bailout) ||                                         \
(@test == 1 && sqr(real(z)) <= @bailout) ||                                \
(@test == 2 && sqr(imag(z)) <= @bailout) ||                                \
(@test == 3 && (sqr(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (sqr(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (sqr(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (sqr(real(z) + imag(z)) <= @bailout))

default:
title = "KPK LSK"
magn = 1.0
periodicity = 0

param bailout
caption = "Bailout"
default = 1e20
endparam

param test
caption = "Shape Modifier"
default = 0
enum = "mod" "real" "imag" "or" "and" "manh" "manr"
endparam

param mode
caption = "Variation"
default = 0
enum = "Saerdna" "Retep"
endparam

param taste
caption = "Taste"
enum = "Rebol" "Kibuk" "Reinnom"
default = 0
endparam

param corte
caption = "Cutting edges"
default = 0.5
endparam

param spokes
caption = "Construction"
default = 1.0
endparam

param spot
caption = "Spot Change"
default = true
endparam

param rot
caption = "Rotation/Distortion"
default = 0.0
endparam

param tilem
caption = "Translation"
default = (0,0)
endparam

param rottile
caption = "Tile Rotation"
default = 0.0
endparam

param sizesq
caption = "Size of the Tiles"
default = 1e-9
endparam

func fn1
caption = "First Function"
default = round()
endfunc

func last
caption = "Last  Function"
default = abs()
endfunc
}

kpkmini {
; Written by KPK May,  2000
;
; Derived from the KPK TTS formula
; including parts of Samuel Monnier's
; Squarry Koch Curve formula
;
init:

i = 0
z = #pixel

z = z*exp(1i*pi/180*@rot)
zc = sqr(z/4)*0.7

z = 0.2*fn1(pixel^@spokes)

bool bail = true

x = real(z)
y = imag(z)

tes = fn1(z)

zz = x + fn1(y)

n = fn4(@power1^i)/zc

z = z/@size

IF @spot == true
sp = 2

ELSE
sp = 1

ENDIF

IF @spot2 == true
sp2 = abs(tes)

ELSE
sp2 = sqrt(tes)

ENDIF

IF @spot3 == true
sp3 = 1/fn2(@r)*real(z) + 1i*fn2(@r)*imag(z)+n

ELSE
sp3 = 1/fn2(@r)*imag(z) + 2i*fn2(@r)*real(z)*n

ENDIF

IF @spot4 == true
sp4 = 1/sqrt(2)*z*exp(1i*pi/4)

ELSE
sp4 = 1/fn2(@r)*imag(z)*(2i*fn2(@r)*real(z)*n)+n

ENDIF

IF @spot5 == true
sp5 = @offset

ELSE
sp5 = @offset/zc

ENDIF

IF @spot6 == true
sp6 = zc

ELSE
sp6 = (zc-zz)

ENDIF

loop:

i = i + 1

n = fn4(@power1^i)*zc

bool bail = true

IF i == 2

z = sp3
z = sp4
x = real(z)
y = imag(z)

IF |x| > 1 || |y| > 1
bail = true

ENDIF

tes = fn1(z)

IF sp2 < pi/4
z = z*fn3(1i*pi/2)*sp

ELSEIF (tes < -pi/4) && (tes > -3*pi/4)
z = z*fn3(1i*pi)

ELSEIF abs(tes) > 3*pi/4
z = z*fn3(1i*3*pi/2)

ENDIF

z = -z + 1i

ENDIF

IF i > 2

z = z + sp6

z = 1/fn1(@r)*real(z) + 1i/fn1(@r)*imag(z)

x = real(z)
y = imag(z)

IF abs(x) < 1/@s && abs(y - 1/@s) < 1/@s
bail = true

ENDIF

IF x < -1/@s && y < -x - 1/@s
z = 2*@s/(@s-1)*z + (@s+1)/(@s-1)

ELSEIF x > 1/@s && y < x + 1/@s
z = 2*@s/(@s-1)*z - (@s+1)/(@s-1)

ELSEIF x <= -1/@s && y > x + 1/@s
z = z + 1/@s
z = z*fn3(-1i*pi/2)
z = @s*z - 1

ELSEIF x >= 1/@s && y > x - 1/@s
z = z - 1/@s
z = z*fn3(1i*pi/2)
z = @s*z + 1

ELSEIF abs(x) < 1/@s
z = @s*z - 2*1i

ENDIF

ENDIF

IF i >= 2

z = (z-zc)-sp5

ENDIF

bailout:

|z| < @bailout && bail == true

default:

title = "KPK  mini"
method = multipass
periodicity = 0

param bailout
caption = "Bailout"
default = 10000
endparam

param r
caption = "Stretcher"
default = 1.0
min = -1.0
endparam

param size
caption = "Fractalisation"
default = 1.0
hint = "You can also choose \
negative values"
endparam

param spot
caption = "Spot Change"
default = true
endparam

param spot2
caption = "Circles"
default = true
endparam

param spot3
caption = "Multiply Change"
default = false
endparam

param spot4
caption = "z Change"
default = true
endparam

param spot5
caption = "Last  Change"
default = true
endparam

param spot6
caption = "Loop  Change 1"
default = true
endparam

param spokes
caption = "Bending"
default = 1.0
endparam

param offset
caption = "Offset"
default = (0.0,0.0)
endparam

param rot
caption = "Rotation"
default = 0.0
endparam

param power1
caption = "Tiny Effects"
default = 0.0
endparam

param s
caption = "Design Step"
default = 3.0
endparam

func fn1
caption = "Function 1"
default = abs()
endfunc

func fn2
caption = "Function 2"
default = recip()
endfunc

func fn3
caption = "Function 3"
default = cos()
endfunc

func fn4
caption = "Function 4"
default = trunc()
endfunc
}

donquixoteangle2 {
; Written by KPK May, 2000
;
; Basics by Samuel Monnier
;
; Additional ideas by Andreas Lober
;
; Revised version 6 August 2000

init:

complex z = 0.2*fn1(pixel^@spokes)
zc = fn1(z/2)*p1
float arg = 0

loop:

arg = atan2(z)

IF (abs(arg)<pi/4)
z = @factor*real(z) + fn3(@factor*imag(z)-1)
z=z*fn4(1i*pi/2)

ELSEIF (arg < -pi/4) && (arg > -3*pi/4)
z = z*fn4(1i*pi)

ELSEIF (abs(arg)>3*pi/4)
z=z*fn4(3*1i*pi/2)
z = @factor*real(z)-1 + fn3(@factor*imag(z))

ELSE
z = @factor*real(z) + fn3(@factor*imag(z))
z = @fn2( z )

ENDIF

IF @modo == 0
z = z-zc

ELSEIF @modo == 1
z = z/zc

ELSEIF @modo == 2
z = z+zc

ELSEIF @modo == 3
z = (z+zc)^pi

ENDIF

z =-z+1i

bailout:
(@test == 0 && |z| <= @bailout) ||                                         \
(@test == 1 && sqr(real(z)) <= @bailout) ||                                \
(@test == 2 && sqr(imag(z)) <= @bailout) ||                                \
(@test == 3 && (sqr(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (sqr(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (sqr(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (sqr(real(z) + imag(z)) <= @bailout))

default:
title = "Don Quixote Angel 2"
center = (0.2, 0.4)
magn = 1.112
periodicity = 0

param bailout
caption = "Bailout value"
default = 127
min = 1
endparam

param test
caption = "Shape Modifier"
default = 0
enum = "mod" "real" "imag" "or" "and" "manh" "manr"
endparam

param modo
caption = "Taste"
default = 2
enum = "Difference" "Quotient" "Sum" "Power"
endparam

param factor
caption = "Factor Transformation"
default = 2.0
endparam

param spokes
caption = "Number of Spokes"
default = 4
endparam

param p1
caption = "Shape"
default = 0.7
endparam

func fn1
caption = "Function 1"
default = sqrt()
hint = "Shape of the wings"
endfunc

func fn2
caption = "Function 2"
default = ident()
endfunc

func fn3
caption = "Function 3"
default = flip()
endfunc

func fn4
caption = "Function 4"
default = exp()
endfunc
}

kpkcircletiletransform {
; Written by KPK June,  2000
;
; Derived from the KPK mini formula
;
; Implemented to the formula are the
; possibilities of the Magic Glass
; transformation. You can add a glass
; tile effect and a glass hemisphere
; effect to the image.
;
init:

i = 0
z = #pixel

z = z*exp(1i*pi/180*@rot)
zc = sqr(z/4)*0.7

z = 0.2*fn1(pixel^@spokes)

float x1 = imag(#pixel)
float y1 = real(#pixel)
x1 = x1 + x1 % @a
y1 = y1 + y1 % @a
z = x1 + flip(y1)
complex z2 = #pixel-@Center
float beta = 0
float theta1 = 0
float x2 = 0
float x1 = cabs(z2)/@width

IF x1 > 1
z = z

ELSE
theta1 = acos(x1)
y1 = sin(theta1)
beta = asin(x1/@n)
x2 = -y1/real(tan(theta1+beta))+ x1
z = z2/x1 * x2 + @Center

ENDIF

bool bail = true

x = real(z)
y = imag(z)

tes = fn1(z)

zz = x + fn1(y)

n = fn4(@power1^i)/zc

z = z/@size

IF @spot == true
sp = 2

ELSE
sp = 1

ENDIF

IF @spot2 == true
sp2 = abs(tes)

ELSE
sp2 = sqrt(tes)

ENDIF

IF @spot3 == true
sp3 = 1/fn2(@r)*real(z) + 1i*fn2(@r)*imag(z)+n

ELSE
sp3 = 1/fn2(@r)*imag(z) + 2i*fn2(@r)*real(z)*n

ENDIF

IF @spot4 == true
sp4 = 1/sqrt(2)*z*exp(1i*pi/4)

ELSE
sp4 = 1/fn2(@r)*imag(z)*(2i*fn2(@r)*real(z)*n)+n

ENDIF

IF @spot5 == true
sp5 = @offset

ELSE
sp5 = @offset/zc

ENDIF

IF @spot6 == true
sp6 = zc

ELSE
sp6 = (zc-zz)

ENDIF

loop:

i = i + 1

n = fn4(@power1^i)*zc

bool bail = true

IF i == 2

z = sp3
z = sp4
x = real(z)
y = imag(z)

IF |x| > 1 || |y| > 1
bail = true

ENDIF

tes = fn1(z)

IF sp2 < pi/4
z = z*fn3(1i*pi/2)*sp

ELSEIF (tes < -pi/4) && (tes > -3*pi/4)
z = z*fn3(1i*pi)

ELSEIF abs(tes) > 3*pi/4
z = z*fn3(1i*3*pi/2)

ENDIF

z = -z + 1i

ENDIF

IF i > 2

z = z + sp6

z = 1/fn1(@r)*real(z) + 1i/fn1(@r)*imag(z)

x = real(z)
y = imag(z)

IF abs(x) < 1/@s && abs(y - 1/@s) < 1/@s
bail = true

ENDIF

IF x < -1/@s && y < -x - 1/@s
z = 2*@s/(@s-1)*z + (@s+1)/(@s-1)

ELSEIF x > 1/@s && y < x + 1/@s
z = 2*@s/(@s-1)*z - (@s+1)/(@s-1)

ELSEIF x <= -1/@s && y > x + 1/@s
z = z + 1/@s
z = z*fn3(-1i*pi/2)
z = @s*z - 1

ELSEIF x >= 1/@s && y > x - 1/@s
z = z - 1/@s
z = z*fn3(1i*pi/2)
z = @s*z + 1

ELSEIF abs(x) < 1/@s
z = @s*z - 2*1i

ENDIF

ENDIF

IF i >= 2

z = (z-zc)-sp5

ENDIF

bailout:

|z| < @bailout && bail == true

default:

title = "KPK  CTT"
method = multipass
periodicity = 0

param bailout
caption = "Bailout"
default = 10000
endparam

param a
caption = "Square Size"
default = 0.1
endparam

param center
caption="Center of  Hemisphere"
default=(0,0)
endparam

param width
caption = "Width"
default = 1.0
hint = "Width of Hemisphere"
endparam

param n
caption = "Refractive Index"
hint="Refractive Index of Hemisphere"
default = 2.0
endparam

param r
caption = "Stretcher"
default = 1.0
min = -1.0
endparam

param size
caption = "Fractalisation"
default = 1.0
hint = "You can also choose \
negative values"
endparam

param spot
caption = "Spot Change"
default = true
endparam

param spot2
caption = "Circles"
default = true
endparam

param spot3
caption = "Multiply Change"
default = false
endparam

param spot4
caption = "z Change"
default = true
endparam

param spot5
caption = "Last  Change"
default = true
endparam

param spot6
caption = "Loop  Change 1"
default = true
endparam

param spokes
caption = "Bending"
default = 1.0
endparam

param offset
caption = "Offset"
default = (0.0,0.0)
endparam

param rot
caption = "Rotation"
default = 0.0
endparam

param power1
caption = "Tiny Effects"
default = 0.0
endparam

param s
caption = "Design Step"
default = 3.0
endparam

func fn1
caption = "Function 1"
default = abs()
endfunc

func fn2
caption = "Function 2"
default = recip()
endfunc

func fn3
caption = "Function 3"
default = cos()
endfunc

func fn4
caption = "Function 4"
default = trunc()
endfunc
}

kpkslicedhippie {
; Written by KPK July, 2000
;
; With parts of Samuel Monnier's
; Squarry Koch Curve formula and
; his Octogonal Slices transform
;
; Spot effect after an idea of Andras Szolek
;
init:

i = 0
z = #pixel
z = z*fn2(1i*pi/180*@rot)

zc = fn1(z/4)*0.7

bool bail = true

x = real(z)
y = imag(z)

tes = fn1(z)

n = fn4(@power1^i)*zc

z = 0

float arg = 0
float angle = @angle*pi/180

z = #pixel
arg = atan2(z)

IF arg > pi/2
z = -1i*z

ELSEIF arg > -pi/2 && arg < 0
z = 1i*z

ELSEIF arg < -pi/2
z = -z

ENDIF

arg = atan2(z)

IF arg > pi/2 - angle
z = z*exp(-1i*pi/2)

ELSEIF arg < pi/2 - angle && arg > angle
z = z*@fn5(-1i*pi/4)
z = z*cos(angle)/cos(pi/4-angle)

ENDIF

z = z*exp(1i*pi/180*@rot1)

IF @spot == true
sp = 2

ELSE
sp = 1

ENDIF

IF @spot2 == true
sp2 = abs(tes)

ELSE
sp2 = sqrt(tes)

ENDIF

IF @spot3 == true
sp3 = 1/fn2(@r)*real(z) + 1i*fn2(@r)*imag(z)+n

ELSE
sp3 = 1/fn2(@r)*imag(z)/(2i*fn2(@r)*real(z)*n)+n

ENDIF

IF @spot4 == true
sp4 = 1/sqrt(2)*z*exp(1i*pi/4)

ELSE
sp4 = 1/fn2(@r)*imag(z)*(2i*fn2(@r)*real(z)*n)+n

ENDIF

IF @spot5 == true
sp5 =  zc

ELSE
sp5 = (@s*z - 2*1i)

ENDIF

loop:

i = i + 1

n = fn4(@power1^i)*zc

bool bail = true

IF i == 2
z = sp3

IF @mode == 0

IF |x| < 1 && |y| < 1
bail = true

ENDIF

IF sp2 < pi/4
z = z*fn3(1i*pi/2)*sp

ELSEIF (tes < -pi/4) && (tes > -3*pi/4)
z = z*fn3(1i*pi)

ELSEIF abs(tes) > 3*pi/4
z = z*fn3(1i*3*pi/2)

ENDIF

z = z - 1i

ELSEIF @mode == 1

z = sp4
x = real(z)
y = imag(z)

IF |x| > 1 || |y| > 1
bail = true

ENDIF

tes = fn1(z)

IF sp2 < pi/4
z = z*fn3(1i*pi/2)*sp

ELSEIF (tes < -pi/4) && (tes > -3*pi/4)
z = z*fn3(1i*pi)

ELSEIF abs(tes) > 3*pi/4
z = z*fn3(1i*3*pi/2)

ENDIF

z = -z + 1i

ENDIF

ELSEIF i > 2

z = z + zc

z = 1/fn2(@r)*real(z) + 1i*fn2(@r)*imag(z)

x = real(z)
y = imag(z)

IF abs(x) < 1/@s && abs(y - 1/@s) < 1/@s
bail = true

ENDIF

IF x < -1/@s && y < -x - 1/@s
z = 2*@s/(@s-1)*z + (@s+1)/(@s-1)

ELSEIF x > 1/@s && y < x - 1/@s
z = 2*@s/(@s-1)*z - (@s+1)/(@s-1)

ELSEIF x <= -1/@s && y > -x - 1/@s
z = z + 1/@s
z = z*fn3(-1i*pi/2)
z = @s*z - 1

ELSEIF x >= 1/@s && y > x - 1/@s
z = z - 1/@s
z = z*fn3(1i*pi/2)
z = @s*z + 1

ELSEIF abs(x) < 1/@s
z = @s*z - 2*1i

ENDIF
ENDIF

IF i >= 2
z = z - sp5

ENDIF

bailout:

|z| < @bailout && bail == true

default:

title = "KPK Sliced Hippie"
method = multipass
periodicity = 0

param bailout
caption = "Bailout"
default = 1000
endparam

param angle
caption = "Angle"
default = 0.0
endparam

param rot1
caption = "Rotation 1"
default = 45.0
endparam

param r
caption = "Smoothness"
default = 1.0
min = 0.0
endparam

param mode
caption = "Variation"
default = 0
enum = "Arranged" "Mixed" "None ?"
endparam

param spot
caption = "Spot Change"
default = false
endparam

param spot2
caption = "Distortion Change"
default = true
endparam

param spot3
caption = "Multiply Change"
default = true
endparam

param spot4
caption = "z Change"
default = true
endparam

param spot5
caption = "Last Change"
default = true
endparam

param s
caption = "Magnification step"
default = 4.0
endparam

param rot
caption = "Rotation 2"
default = 0.0
endparam

param power1
caption = "Distorts the shape"
default = 2.0
endparam

func fn1
caption = "Function 1"
default = sqrt()
endfunc

func fn2
caption = "Function 2"
default = sqrt()
endfunc

func fn3
caption = "Function 3"
default = exp()
endfunc

func fn4
caption = "Distortion Function"
default = abs()
endfunc

func fn5
caption = "Slice Function"
default = abs()
endfunc

}

kpkslicedpinsky {
; Written by KPK July, 2000
;
; With parts of Samuel Monnier's
; Octogonal Slices formula
;
; Revised version 6 August 2000

init:

complex z = pixel
zc = fn4(z/@sizesq)*@sizesq
z = 2*(z - (0.25*zc))/(0.5*@power)

float arg = 0
float angle = @angle*pi/180

arg = atan2(z)

IF arg > pi/2
z = -1i*z

ELSEIF arg > -pi/2 && arg < 0
z = 1i*z

ELSEIF arg < -pi/2
z = -z

ENDIF

arg = atan2(z)

IF arg > pi/2 - angle
z = z*exp(-1i*pi/2)

ELSEIF arg < pi/2 - angle && arg > angle
z = z*fn1(-1i*pi/4)
z = z*cos(angle)/cos(pi/4-angle)

ENDIF

z = z*exp(1i*pi/180*@rot1)

loop:

IF (imag(z)>0.5)
z = 2*real(z) + fn2(2*imag(z)-1)

ELSEIF (real(z)>0.5)
z = 2*real(z)-1 + fn2(2*imag(z))

ELSE
z = 2*real(z) + fn3(2*imag(z))

ENDIF

bailout:
(@test == 0 && |z| <= @bailout) ||                                         \
(@test == 1 && sqr(real(z)) <= @bailout) ||                                \
(@test == 2 && sqr(imag(z)) <= @bailout) ||                                \
(@test == 3 && (sqr(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (sqr(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (sqr(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (sqr(real(z) + imag(z)) <= @bailout))

default:
title = "KPK Sliced Pinsky"
center = (0.5, 0.1)
magn = 1.5
maxiter = 500

param bailout
caption = "Bailout"
default = 1e20
endparam

param test
caption = "Shape Modifier"
default = 0
enum = "mod" "real" "imag" "or" "and" "manh" "manr"
endparam

param angle
caption = "Angle"
default = 0.0
endparam

param rot1
caption = "Rotation 1"
default = 45.0
endparam

param power
caption = "Power"
default = (2,0)
endparam

param sizesq
caption = "Magnification"
default = 3
endparam

func fn1
caption = "Slice Function"
default = exp()
endfunc

func fn2
caption = "Pinsky Function 1"
default = flip()
endfunc

func fn3
caption = "Pinsky Function 2"
default = flip()
endfunc

func fn4
caption = "Pinsky Function 3"
default = ident()
endfunc

}

KPKslicedjester {
; Written by KPK July, 2000
;
; Changed parts of Andreas Lober's
; Lattice algorythm and parts of
; Samuel Monnier's Octogonal Slices
; transform integrated.
;
; KPK Reflex transform implemented.
;
; Use Function 5 and Slice Function for
; overall changes of the image shape.
;
; Revised version 6 August 2000
init:

complex z = 0.3*fn1(pixel^@spokes)
zc = fn2(z/2)*0.2
z = 2*(z - zc)+ 0.5

x = 0
y = 0

xf = 0
yf = 0

xc = 0
yc = 0

z = 0

IF (@with == 0)

float arg = 0
float angle = @angle*pi/180

z = #pixel
arg = atan2(z)

IF arg > pi/2
z = -1i*z

ELSEIF arg > -pi/2 && arg < 0
z = 1i*z

ELSEIF arg < -pi/2
z = -z

ENDIF

arg = atan2(z)

IF arg > pi/2 - angle
z = z*exp(-1i*pi/2)

ELSEIF arg < pi/2 - angle && arg > angle
z = z*@fn6(-1i*pi/4)
z = z*cos(angle)/cos(pi/4-angle)

ENDIF

z = z*exp(1i*pi/180*@rot1)

;Reflex part:

ELSEIF (@with == 1)

float x1 = real(#pixel)
float y1 = imag(#pixel)

x1 = @a * atan(@a * imag(@fn1(#pixel)))
y1 = @a * log(@n * real(@fn2(#pixel)))

z = x1 + flip(y1)
complex z2 = #pixel-@Center

float beta = 0
float theta1 = 0
float x2 = 0
float x1 = cabs(z2)/@random

IF x1 > 1
z = z

ELSE

theta1 = round(x1)
y1 = abs(theta1)
beta = sin(x1/@n)
x2 = -y1/real(tan(theta1+beta)) + x1
z = z2/x1 * x2 + @Center

float arg = 0
float angle = @angle*pi/180

z = #pixel
arg = atan2(z)

IF arg > pi/2
z = -1i*z

ELSEIF arg > -pi/2 && arg < 0
z = 1i*z

ELSEIF arg < -pi/2
z = -z

ENDIF

arg = atan2(z)

IF arg > pi/2 - angle
z = z*exp(-1i*pi/2)

ELSEIF arg < pi/2 - angle && arg > angle
z = z*@fn6(-1i*pi/4)
z = z*cos(angle)/cos(pi/4-angle)

ENDIF

z = z*exp(1i*pi/180*@rot1)

ENDIF
ENDIF

loop:

IF (imag(z)>0.5)
z = 2*real(z) + @fn5(2*imag(z)-1)

ELSEIF (real(z)>0.5)
z = 2*real(z)-1 + @fn5(2*imag(z))

ELSEIF (imag(z)<-0.1)
z = 2*imag(z)+1 + @fn5(2*real(z))

ELSEIF (real(z)>0.1)
z = fn3(imag(z^@structure1)) * fn4(sin(z^@structure2))

ELSE
z = 2*real(z) + flip(2*imag(z))

ENDIF

IF     (@second == 1)
z = round(@erf1*z) - @erf2*z

ELSEIF (@second == 2)
z = trunc(@erf1*z) - @erf2*z

ELSEIF (@second == 3)
z = floor(@erf1*z) - @erf2*z

ELSEIF (@second == 4)
z = ceil(@erf1*z)  - @erf2*z

ELSEIF (@second == 5)
z = abs(@erf1*z)   - @erf2*z^2

ENDIF

x = real(z)
y = imag(z)

IF   (@second == 0)

xf = @erf*round(x)
yf = @erf*round(y)

xc = xf+@erf
yc = yf+@erf

ELSEIF (@second == 1)

xf = floor(@erf*x)/@erf
yf = floor(@erf*y)/@erf

xc = ceil(@erf*x)/@erf
yc = ceil(@erf*y)/@erf

ELSEIF (@second == 2)

xf = @erf^x
yf = @erf^y

xc = xf*@erf
yc = yf*@erf

ELSEIF (@second == 3)

xf = floor(@erf^x)*@erf
yf = floor(@erf^y)*@erf

xc = ceil(@erf*x)/@erf
yc = ceil(@erf*y)/@erf

ELSEIF (@second == 4)

xf = floor(@erf*x)*@erf
yf = floor(@erf*y)*@erf

xc = ceil(@erf^x)^@erf
yc = ceil(@erf^y)^@erf

ELSEIF (@second == 5)

xf = fn1(@erf*x)*@erf
yf = fn1(@erf*y)*@erf

xc = fn2(@erf^x)^@erf
yc = fn2(@erf^y)^@erf

ELSEIF (@second == 6)

xf = fn1(@erf*x)*@erf
yf = fn2(@erf*y)*@erf

xc = fn1(@erf^x)^@erf
yc = fn2(@erf^y)^@erf

ENDIF

a = xf + 1i*yc
b = xc + 1i*yc
c = xf + 1i*yf
d = xc + 1i*yf

IF (@first == 1)
z = a*x + b*y + 1i*(c*x+d*y)

ELSEIF (@first == 2)
z = a*z + b

ELSEIF (@first == 3)
z = a*z + b*z

ELSEIF (@first == 4)
z = c*z + d*z

ELSEIF (@first == 5)
z = a*z + (b-c)^z - b

ELSEIF (@first == 6)
z = a*x + (b+c)*x*y + d*y

ELSEIF (@first == 7)
z = a*y + b*x*y + 1i*(c*x*y + d*y^2)

ENDIF

bailout:
(@test == 0 && |z| <= @bailout) ||                                         \
(@test == 1 && sqr(real(z)) <= @bailout) ||                                \
(@test == 2 && sqr(imag(z)) <= @bailout) ||                                \
(@test == 3 && (sqr(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (sqr(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (sqr(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (sqr(real(z) + imag(z)) <= @bailout))

default:
title = "KPK Sliced Jester"
center = (0.4, 0.2)
magn = 1.0
maxiter = 500
periodicity = 0

param with
caption = "Reflection?"
enum    = "No" "Yes"
default = 0
endparam

param first
caption = "1st Change"
enum    = "None" "Linear?" "Try" "One more" "Jessas" \
"Product" "Some" "Where"
default = 0
endparam

param erf
caption = "Surprise"
default = 1.0
endparam

param spokes
caption = "Sometimes"
default = 1
endparam

param bailout
caption = "Bailout"
default = 1e20
endparam

param test
caption = "Shape Modifier"
default = 0
enum = "mod" "real" "imag" "or" "and" "manh" "manr"
endparam

param structure1
caption = "Structure 1"
default = 2
endparam

param structure2
caption = "Structure 2"
default = 2
endparam

param second
caption = "2nd Change"
enum = "None" "Fine" "Nice" "Sweet" "Famous" \
"Fool" "Mr. X"
default = 0
hint = "With Fool and Mr. X you can use \
functions 1 and 2 for further changes"
endparam

param erf1
caption = "real/imag Factor 1"
default = (4.0,1.0)
endparam

param erf2
caption = "real/imag Factor 2"
default = (1.0,0.0)
endparam

param angle
caption = "Angle"
default = 0.0
endparam

param rot1
caption = "Rotation 1"
default = 45.0
endparam

param a
caption = "Reduction"
default = 1.0
hint = "Works only with 'Reflection? Yes'"
endparam

param random
caption = "Sphere"
default = 0.0
hint = "Choose 0 for no sphere. Works only with 'Reflection? Yes'"
endparam

param n
caption = "Splitting"
default = 2.0
hint = "Works only with 'Reflection? Yes'"
endparam

param center
caption = "Center"
default = (0.0,0.0)
hint = "Works only with 'Reflection? Yes'"
endparam

func fn1
caption = "Function 1"
default = abs()
endfunc

func fn2
caption = "Function 2"
default = sqr()
endfunc

func fn3
caption = "Function 3"
default = sin()
endfunc

func fn4
caption = "Function 4"
default = cos()
endfunc

func fn5
caption = "Function 5"
default = ident()
endfunc

func fn6
caption = "Slice Function"
default = exp()
endfunc

}

kpkmoon1 {
; Written by KPK July, 2000
;
; With parts of Samuel Monnier's
; Squarry Koch Curve formula and
; his Octogonal Slices transform
; and parts of the KPK Magic Glass
; transform
;
; Spot effect after an idea of Andras Szolek
;
init:

i = 0
z = #pixel
z = z*exp(1i*pi/180*@rot)

zc = fn1(z/2)*0.7

float x1 = imag(#pixel)
float y1 = real(#pixel)
x1 = x1 + x1 % @a
y1 = y1 + y1 % @a
z = x1 + flip(y1)
complex z2 = #pixel-@Center
float beta = 0
float theta1 = 0
float x2 = 0
float x1 = cabs(z2)/@width

IF x1 > 1
z = z

ELSE
theta1 = acos(x1)
y1 = sin(theta1)
beta = asin(x1/@n)
x2 = -y1/real(tan(theta1+beta))+ x1
z = z2/x1 * x2 + @Center

ENDIF

bool bail = true

x = real(z)
y = imag(z)

tes = fn1(z)

n = fn4(@power1^i)*zc

z = 0

float arg = 0
float angle = @angle*pi/180

z = #pixel
arg = atan2(z)

IF arg > pi/2
z = -1i*z

ELSEIF arg > -pi/2 && arg < 0
z = 1i*z

ELSEIF arg < -pi/2
z = -z

ENDIF

arg = atan2(z)

IF arg > pi/2 - angle
z = z*exp(-1i*pi/2)

ELSEIF arg < pi/2 - angle && arg > angle
z = z*@fn5(-1i*pi/4)
z = z*cos(angle)/cos(pi/4-angle)

ENDIF

z = z*exp(1i*pi/180*@rot1)

IF @spot == true
sp = 2

ELSE
sp = 1

ENDIF

IF @spot2 == true
sp2 = abs(tes)

ELSE
sp2 = sqrt(tes)

ENDIF

IF @spot3 == true
sp3 = 1/fn2(@r)*real(z) + 1i*fn2(@r)*imag(z)+n

ELSE
sp3 = 1/fn2(@r)*imag(z)/(2i*fn2(@r)*real(z)*n)+n

ENDIF

IF @spot4 == true
sp4 = 1/sqrt(2)*z*exp(1i*pi/4)

ELSE
sp4 = 1/fn2(@r)*imag(z)*(2i*fn2(@r)*real(z)*n)+n

ENDIF

IF @spot5 == true
sp5 =  zc

ELSE
sp5 = (@s*z - 2*1i)

ENDIF

loop:

i = i + 1

n = fn4(@power1^i)*zc

bool bail = true

IF i == 2
z = sp3

IF @mode == 0

IF |x| < 1 && |y| < 1
bail = true

ENDIF

IF sp2 < pi/4
z = z*fn3(1i*pi/2)*sp

ELSEIF (tes < -pi/4) && (tes > -3*pi/4)
z = z*fn3(1i*pi)

ELSEIF abs(tes) > 3*pi/4
z = z*fn3(1i*3*pi/2)

ENDIF

z = z - 1i

ELSEIF @mode == 1

z = #pixel

IF real(z) >= 0
z = (z+1)*(@fn6(-1i*pi/2))*@mir

ELSE
z = (z-1)*(@fn6(1i*3*pi/2))*@mir

ENDIF

ELSEIF @mode == 2

z = sp4
x = real(z)
y = imag(z)

IF |x| > 1 || |y| > 1
bail = true

ENDIF

tes = fn1(z)

IF sp2 < pi/4
z = z*fn3(1i*pi/2)*sp

ELSEIF (tes < -pi/4) && (tes > -3*pi/4)
z = z*fn3(1i*pi)

ELSEIF abs(tes) > 3*pi/4
z = z*fn3(1i*3*pi/2)

ENDIF

z = -z + 1i

ENDIF

ELSEIF i > 2

z = z + zc

z = 1/fn2(@r)*real(z) + 1i*fn2(@r)*imag(z)

x = real(z)
y = imag(z)

IF abs(x) < 1/@s && abs(y - 1/@s) < 1/@s
bail = true

ENDIF

IF x < -1/@s && y < -x - 1/@s
z = 2*@s/(@s-1)*z + (@s+1)/(@s-1)

ELSEIF x > 1/@s && y < x - 1/@s
z = 2*@s/(@s-1)*z - (@s+1)/(@s-1)

ELSEIF x <= -1/@s && y > -x - 1/@s
z = z + 1/@s
z = z*fn3(-1i*pi/2)
z = @s*z - 1

ELSEIF x >= 1/@s && y > x - 1/@s
z = z - 1/@s
z = z*fn3(1i*pi/2)
z = @s*z + 1

ELSEIF abs(x) < 1/@s
z = @s*z - 2*1i

ENDIF
ENDIF

IF i >= 2
z = z - sp5

ENDIF

bailout:

(@test == 0 && |z| <= @bailout && bail == true  ||    \
(@test == 1 && (sqr(real(z) + imag(z)) <= @bailout)))

default:

title = "KPK Moon 1"
method = multipass
periodicity = 0

param bailout
caption = "Bailout"
default = 1000
endparam

param mode
caption = "Variation"
default = 0
enum = "Arranged" "Mirror" "Mixed" "None ?"
endparam

param test
caption = "Test Shape"
default = 1
enum = "Var 1" "Var 2"
endparam

param mir
caption = "Mirror Parameter"
default = (1.0, 1.0)
endparam

param a
caption = "Lunar Factor"
default = 0.0
endparam

param center
caption = "Position of Moon"
default = (0.5,0.1)
endparam

param width
caption = "Width"
default = 1.0
hint = "Width of Moon"
endparam

param n
caption = "Moon Index"
default = 1.0
endparam

param angle
caption = "Angle"
default = 0.0
endparam

param rot1
caption = "Rotation 1"
default = 0.0
endparam

param r
caption = "Smoothness"
default = 1.0
endparam

param spot
caption = "Spot Change"
default = false
endparam

param spot2
caption = "Distortion Change"
default = true
endparam

param spot3
caption = "Multiply Change"
default = true
endparam

param spot4
caption = "z Change"
default = true
endparam

param spot5
caption = "Last Change"
default = true
endparam

param s
caption = "Magnification step"
default = 4.0
endparam

param rot
caption = "Rotation 2"
default = 0.0
endparam

param power1
caption = "Distorts the shape"
default = 2.0
endparam

func fn1
caption = "Function 1"
default = cabs()
endfunc

func fn2
caption = "Function 2"
default = sqrt()
endfunc

func fn3
caption = "Function 3"
default = exp()
endfunc

func fn4
caption = "Distortion Function"
default = abs()
endfunc

func fn5
caption = "Slice Function"
default = abs()
endfunc

func fn6
caption = "Mirror  Function"
default = exp()
endfunc

}

kpkbarninsky {
; Written by KPK August 2000
;
; From the original Sierpinski formula
; by Luke Plant plus enhancements by
; Samuel Monnier
;
; Additional bailout ideas by Andreas Lober
; and David Makin
init:

complex z = #pixel

loop:

IF real(z) * imag(@start) + real(@start) * imag(z) >= 0
z = (z - 1) * @start
ELSE
z = (z + 1) * @start
ENDIF

IF (imag(z)>0.5)
z = @f1(2*real(z) + @f4(2*imag(z)-1))
ELSEIF (real(z)>0.5)
z = @f2(2*real(z)-1 + @f4(2*imag(z)))
ELSE
z = @f3(2*real(z) + @f4(2*imag(z)))
ENDIF

bailout:
((@test == 0 && |z| <= @bailout) ||                         \
(@test == 1 && @goofFunc(real(z)) <= @bailout) ||                                \
(@test == 2 && @goofFunc(imag(z)) <= @bailout) ||                                \
(@test == 3 && (@goofFunc(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (@goofFunc(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (@goofFunc(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (@goofFunc(real(z) + imag(z)) <= @bailout)) ||                    \
(@test == 7 && (abs(sqr(real(z))/imag(z)) <= @bailout)) ||                 \
(@test == 8 && (abs(sqr(imag(z))/real(z)) <= @bailout)) ||                 \
(@test == 9 && (@bailFunc(z)*@bailExponent) <= @bailout)) ||                 \
(@test == 10 && (@bailFunc(z)^@bailExponent) <= @bailout)

default:
title = "KPK Barninsky"
center = (0.4, 0.4)
magn = 1.0
maxiter = 149
method = multipass
periodicity = 0

param bailout
caption = "Bailout value"
default = 127
min = 1
endparam

param start
caption = "Start Parameter "
default = (1.0, 1.0)
endparam

param bailExponent
caption = "Bailout Exponent"
default = 3.0
endparam

param test
caption = "Shape Modifier"
enum = "mod" "real" "imag" "or" "and" "manh" \
"manr" "abs(x*x/y)" "abs(y*y/x)" "iter" \
"10"
default = 10
endparam

func f1
caption = "Function 1"
default = ident()
endfunc

func f2
caption = "Function 2"
default = ident()
endfunc

func f3
caption = "Function 3"
default = ident()
endfunc

func f4
caption = "Function 4"
default = flip()
endfunc

func bailFunc
caption = "Bailout Fct."
default = ident()
endfunc

func goofFunc
caption = "Goofy Fct."
default = sqr()
endfunc
}

kpkbarnskypro {
; Written by KPK July/August, 2000
;
; With parts of Samuel Monnier's
; Octogonal Slices formula (Thanks
; Sam for your kind permission)
;
; Parts of the Barnsley algorithm implemented
; with permission of Frederik Slijkerman
;
; With a very big "THANK YOU" to
; Michèle Dessureault (MD) for the permission
; to use parts of her excellent code
;
; Also a very big "THANK YOU" goes
; to David Makin for his kind permission
;
; A very special "THANK YOU" goes to
; Andreas Lober for looking through the code
; and for his additional ideas
;
; Bailout test code with ideas from Michèle
; Dessureault, Andreas Lober, David Makin, KPK
; Bailout test code worked out by Andreas Lober,
; with additional features created by KPK
;
; Spot effect after an idea of Andras Szolek
;

init:

int j = 0
int iter = 1

complex z  = #pixel
float x  = real(z)
float y  = imag(z)
float t  = x

float t1 = 0
float t2 = 0

complex c = @seed
complex zold = z

float ang = #pi*@ang/180.0
float r0c0 = @a*cos(ang)-@b*sin(ang)
float r0c1 = @a*sin(ang)+@b*cos(ang)
float r1c0 = @c*cos(ang)-@d*sin(ang)
float r1c1 = @c*sin(ang)+@d*cos(ang)

float arg = 0
float angle = @angle*#pi/180

bool bail = true

int j = 0

IF (@fractal == 22)
c = @Fn7(c)
ENDIF

IF (@mode1 == 0)
z = 0.2*@fn1(#pixel^@spokes)
arg = atan2(z)

ELSEIF (@mode1 == 1)
z = 0.2*@fn1(pixel^@spokes)
zc = @fn4(z/@sizesq)*@sizesq
z = 2*(z - (0.25*zc))/(0.5*@power)

j = @numberOfTurns

WHILE (j > 0)
arg = atan2(z)

IF (arg > #pi/2)
z = -1i*z

ELSEIF (arg > -#pi/2 && arg < 0)
z = 1i*z

ELSEIF (arg < -#pi/2)
z = -z

ENDIF

arg = atan2(z)

IF (arg > #pi/2 - angle)
z = z*exp(-1i*#pi/2)

ELSEIF (arg < #pi/2 - angle && arg > angle)
z = z*@fn1(-1i*#pi/4)
z = z*cos(angle)/cos(#pi/4-angle)

ENDIF

j = j - 1

ENDWHILE ; j

IF @spot == true
sp = z*exp(1i*#pi/180*@rot1)

ELSE
sp = z^exp(1i*#pi/180*@rot1)
z = sp

ENDIF

bool est_pair = true
int temp = 0
float signe = 1.0

ENDIF ; @mode

float testAngle1 = #pi/@corte1
float testAngle2 = 3*testAngle1

complex rotAngle1  = @corte2*1i*testAngle1
complex rotAngle2  = @corte2*1i*testAngle2

IF (@turnMode)
complex zRound = 0
complex zZ     = z

IF (@turnScale != 0)
complex zRound = round(z*@turnScale)/@turnScale
complex zZ     = z-zRound
ENDIF

float targ = atan2(zZ)

IF (abs(targ) < testAngle1)
z = zZ*exp(rotAngle1)+zRound
ELSEIF (abs(targ) > testAngle2)
z = zZ*exp(rotAngle2)+zRound
ENDIF
ENDIF ; @turnMode

complex oldZ = 0
loop:

iter = iter + 1
oldZ = z

IF (@zJouk != 0 && z != 0)
z = z + @zJouk/z
ENDIF

IF (@mode == 0)

j = @numberOfSkys
WHILE (j > 0)
IF (imag(z) >= 0)
z = fn1(z - 1) * @start
ELSE
z = fn2(z + 1) * @start
ENDIF

j = j - 1
ENDWHILE ; j

ELSEIF (@mode == 1)

j = @numberOfSkys
WHILE (j > 0)
IF (real(z) * imag(@start) + real(@start) * imag(z) >= 0)
z = fn1(z - 1) * @start
ELSE
z = fn2(z + 1) * @start
ENDIF

j = j - 1
ENDWHILE ; j

ELSEIF (@mode == 2)

j = @numberOfSkys
WHILE (j > 0)
IF (imag(z)>0.5)
z = 2*real(z) + fn2(2*imag(z)-1)
ELSEIF (real(z)>0.5)
z = 2*real(z)-1 + fn2(2*imag(z))
ELSE
z = 2*real(z) + fn3(2*imag(z))
ENDIF

j = j - 1
ENDWHILE ; j

IF real(z) >= 0
z = (z - 1) * @start
ELSE
z = (z + 1) * @start
ENDIF

ELSEIF (@mode == 3)

j = @numberOfSkys
WHILE (j > 0)
IF real(z) >= 0
z = fn1(z - 1) * @start
ELSE
z = fn2(z + 1) * @start
ENDIF

IF (imag(z)>0.5)
z = 2*real(z) + fn2(2*imag(z)-1)
ELSEIF (real(z)>0.5)
z = 2*real(z)-1 + fn2(2*imag(z))
ELSE
z = 2*real(z) + fn3(2*imag(z))
ENDIF

j = j - 1
ENDWHILE ; j

ELSEIF @mode == 4

j = @numberOfSkys
WHILE (j > 0)
IF real(z) >= 0
z = fn1(z - 1) * @start
ELSE
z = @fn5(z) - 1 + @start *real(z)
ENDIF

j = j - 1
ENDWHILE ; j

ELSEIF @mode == 5

j = @numberOfSkys
WHILE (j > 0)
IF (imag(z)>0.5)
z = 2*real(z) + fn2(2*imag(z)-1)
ELSEIF (real(z)>0.5)
z = 2*real(z)-1 + fn2(2*imag(z))
ELSE
z = 2*real(z) + fn3(2*imag(z))
ENDIF

IF real(z) >= 0
z = fn1(z - 1) * @start
ELSE
z = @fn6(z) - 1
ENDIF

j = j - 1
ENDWHILE ; j

ELSEIF @mode == 6

j = @numberOfSkys
WHILE (j > 0)
IF imag(z) >=0
z = fn1(z - 1) * @start
ELSEIF real(z) >=0
z = real(z) * imag(@start) + real(@start) * imag(z)
ELSE
z = @fn6(z + 1) * @start
ENDIF

j = j - 1
ENDWHILE ; j

ELSEIF @mode == 7

j = @numberOfSkys
WHILE (j > 0)
zold = z
x = real(z)
y = imag(z)
t = x
x = x*r0c0 + y*r1c0 + @x
y = t*r0c1 + y*r1c1 + @y
z = x + flip(y)

IF @fractal == 0
z = z^@power + c

ELSEIF @fractal == 1
z = ((z^2+c-1)/(2*z+c-2))^2

ELSEIF @fractal == 2
z = ((z^3+3*(c-1)*z+(c-1)*(c-2))/(3*z^2+3*(c-2)*z+(c-1)*(c-2)+1))^2

ELSEIF @fractal == 3
z=@Fn7(z)+c

ELSEIF @fractal == 4
z=1/@Fn7(z)+c

ELSEIF @fractal == 5
z=z*@Fn7(z)+c

ELSEIF @fractal == 6
z=(@Fn7(z)-c)/z

ELSEIF @fractal == 7
z=z/(@Fn7(z)-c)

ELSEIF @fractal == 8
z=z*@Fn7(z)+z+c

ELSEIF @fractal == 9
z=@Fn7(z)+z*z+c

ELSEIF @fractal == 10
z=z*(@Fn7(z)+z)+c

ELSEIF @fractal == 11
z=c*@Fn7(z)

ELSEIF @fractal == 12
z=@Fn7(z)+z+c

ELSEIF @fractal == 13
z=c*@Fn7(z)+z

ELSEIF @fractal == 14
t = x
x = -y*y
y = t*y
z = x + flip(y) + c

ELSEIF @fractal == 15
t1 = x*x - y*y
t2 = 2*x*y
x = t1 + t2
y = t1 - t2
z = x + flip(y) + c

ELSEIF @fractal == 16
t = x*x
x = t*t - y*y
y = 2*t*y
z = x + flip(y) + c

ELSEIF @fractal == 17
t = x*x*x
t1 = 3*x*x*y
t2 = 3*x*y*y
y = y*y*y
x = t + t1 - t2 + y
y = t - t1 - t2 + y
z = x + flip(y) + c

ELSEIF @fractal == 18
t = x
x = real(c) - x*x + imag(c)*y
z = x + flip (t)

ELSEIF @fractal == 19
z = c*z*(1-z)

ELSEIF @fractal == 20
z = z*(1-z) + c

ELSEIF @fractal == 21
z = @fn8(c*@fn7(z))

ELSEIF @fractal == 22
z = @fn8(z*c)

ELSEIF @fractal == 23
IF x >= 0
z = (z-1)*c
ELSE
z = (z+1)*c
ENDIF

ELSEIF @fractal == 24
IF x*imag(c)+real(c)*y >= 0
z = (z-1)*c
ELSE
z = (z+1)*c
ENDIF

ENDIF

IF @smallbail <= |z-zold| + @bailout1
bail = false

ENDIF

j = j - 1
ENDWHILE ; j

ELSEIF @mode == 8

int temp = 0
float signe = 1.0
float temp3 = 0
complex temp2 = 0

IF @sgn == true
temp3 = real(z) * imag(z)
IF temp3 < 0
signe = -1.0
ENDIF
ENDIF

j = @numberOfSkys
WHILE (j > 0)
IF @pairimp == 0 || @pairimp == 2
temp2 = z
ELSEIF @pairimp == 1
temp2 = real(z) * imag(@start) + real(@start) * imag(z)
ENDIF

j = j - 1
ENDWHILE ; j

IF @intf == 0
temp = ceil(signe*cabs(temp2))
ELSEIF @intf == 1
temp = round(signe*cabs(temp2))
ENDIF

IF temp % 2 == 0
est_pair = true
ELSE
est_pair = false
ENDIF

IF est_pair
IF @pairimp == 0 || @pairimp == 1
z = (z - 1) * @start
ELSEIF @pairimp == 2
z = sqr(z) - 1
ENDIF

ELSE
IF @pairimp == 0 || @pairimp == 1
z = (z + 1) * @start
ELSEIF @pairimp == 2
z = sqr(z) - 1 + @start * real(z)
ENDIF
ENDIF
ENDIF

complex bailCheck = 0
complex bailZ = 0

IF (@bailMode == 0)
bailZ = z
ELSEIF (@bailMode == 1)
bailZ = z-oldZ
ELSEIF (@bailMode == 2)
bailZ = (z+oldZ)/2
ELSEIF (@bailMode == 3)
bailZ = z-#pixel
ELSEIF (@bailMode == 4)
bailZ = z/|@goofFunc(oldZ)|
ENDIF

IF (@test == 0)
bailCheck = bailZ
ELSEIF (@test == 1)
bailCheck = real(bailZ)^2
ELSEIF (@test == 2)
bailCheck = imag(bailZ)^2
ELSEIF (@test == 3)
float bailRe = real(bailZ)^2
float bailIm = imag(bailZ)^2
IF (bailRe < bailIm)
bailCheck = bailIm
ELSE
bailCheck = bailRe
ENDIF
ELSEIF (@test == 4)
float bailRe = real(bailZ)^2
float bailIm = imag(bailZ)^2
IF (bailRe > bailIm)
bailCheck = bailIm
ELSE
bailCheck = bailRe
ENDIF
ELSEIF (@test == 5)
bailCheck = (abs(real(bailZ)) + abs(imag(bailZ)))^2
ELSEIF (@test == 6)
bailCheck = @goofFunc(real(bailZ)) + imag(bailZ)
ELSEIF (@test == 7)
bailCheck = @goofFunc((real(bailZ)/imag(bailZ)))^2
ELSEIF (@test == 8)
bailCheck = @goofFunc((imag(bailZ)/real(bailZ)))^2
ELSEIF (@test == 9)
bailCheck = @goofFunc(bailZ*iter)
ELSEIF (@test == 10)
bailCheck = @goofFunc(bailZ + iter)/sqrt(#maxiter)
ELSEIF (@test == 11)
bailCheck = @goofFunc(real(bailZ) - imag(bailZ))^2
ELSEIF (@test == 12)
float phi = atan2(bailZ)/#pi
IF phi < 0.0
phi = phi + 2.0
ENDIF
bailCheck = bailZ*phi^2
ELSEIF (@test == 13)
float phi = atan2(bailZ)/#pi
IF phi < 0.0
phi = phi + 2.0
ENDIF
bailCheck = bailZ/phi^2
ELSEIF (@test == 14)
float phi = atan2(bailZ)/#pi
IF phi < 0.0
phi = phi + 2.0
ENDIF
bailCheck = bailZ*phi^2/sqrt(iter)
ELSEIF (@test == 15)
float phi = atan2(bailZ)/#pi
IF phi < 0.0
phi = phi + 2.0
ENDIF
bailCheck = bailZ*iter/phi^2
ELSEIF (@test == 16)
float reZ = real(bailZ)
bailCheck = reZ*reZ/abs(imag(bailZ))
ELSEIF (@test == 17)
bailCheck = @goofFunc(abs(real(bailZ))) + abs(imag(bailZ))
ELSEIF (@test == 18)
bailCheck = @goofFunc(bailZ)*iter/#maxiter
ENDIF

bailCheck = @bailFunc(bailCheck)

bailout:

bail && (  (@test <= 18 && |bailCheck| <= @bailout) \
|| (@test == 19 && real(@bailFunc(z))*real(@goofFunc(oldZ)) <  @bailout) \
|| (@test == 20 && imag(@bailFunc(z))*imag(@goofFunc(oldZ)) <  @bailout) \
|| (@test == 21 && real(@bailFunc(z))*imag(@goofFunc(oldZ)) <  @bailout) \
|| (@test == 22 && imag(@bailFunc(z))*real(@goofFunc(oldZ)) <  @bailout) \
)

default:
title = "KPK Barnsky pro"
center = (0.5, 0.1)
magn = 0.2
maxiter = 500

param bailout
caption = "Bailout"
default = 4
endparam

param bailout1
caption = "Small bailout"
default = 1e-5
hint = "Bailout for detecting convergence. Keep it small."
endparam

param mode1
caption = "Start"
default = 0
enum = "Start Barney" "Start Barnsky"
endparam

param mode
caption = "Variation"
default = 1
enum = "The Real B" "The Unreal B" "Barney" "Barnsky" "Marnmi" \
"Barnmi" "Squarry" "Dave" "MD"
hint  = "Choose The Real B for the classical Barnsley set. When choosen Dave, go to Fractal Type for further variations"
endparam

param fractal
caption = "Fractal Type"
enum = "Standard" "Magnet1" "Magnet2" "Fn+c" "1/Fn+c" "z*Fn+c" \
"(Fn-c)/z" "z/(Fn-c)" "z*Fn+z+c" "Fn+z^2+c" "z*(Fn+z)+c" \
"c*Fn" "Fn+z+c" "c*Fn+z" "Fastdraw" "Two Square 3" \
"X Squared" "Two Cube" "Henon" "Lambda" "Breeder" \
"Cheb fn1(c*fn(z))" "Cheb1 fn1(z*fn(c))" "Barnsley 1" \
"Barnsley 2"
hint = "Runs only with Variation Dave"
default = 0
endparam

param numberOfTurns
caption = "Number of Turns"
default = 1
endparam

param numberOfSkys
caption = "Number of Skys"
default = 1
endparam

param start
caption = "Barnsley Set"
default = (0.6, 1.1)
hint = "Responsible for the spiral type of the Barnsley set. Choose 0 for the Re value for a squared spiral"
endparam

param spot
caption = "Spot Change"
default = true
endparam

param test
caption = "Shape Modifier"
enum = "mod" "real" "imag" "or" "and" "manh" \
"manr" "abs(x*x/y)" "abs(y*y/x)" "iter" \
"avg iter" "diff" "angle" "angle inv"  \
"angle/iter" "iter/angle" "float" "check" "dust" \
"crossing 1" "crossing 2" "hyper crossing 1" "hyper crossing 2"
default = 0
hint = "Changes the overall outlook of the image. I strongly recommend to try out the different possibilities here!"
endparam

param bailMode
caption = "Shaping"
enum = "Normal" "Smooth" "Average" "Mixel" "Normed"
default = 0
hint = "Just some more variations affecting the overall outlook"
endparam

param angle
caption = "Angle"
default = 0.0
endparam

param rot1
caption = "Rotation"
default = 45.0
endparam

param spokes
caption = "Spokes"
default = 1.0
hint = "Splits the image. Decimal values are possible!"
endparam

param seed
caption = "Magic Set"
default = (0.3,1.1)
endparam

param smallbail
caption = "Convergence"
enum = "disabled" "enabled"
default = 1
endparam

param ang
caption = "Rotation Transform"
default = 0.0
endparam

param x
caption = "Translation (x)"
default = 0.0
hint = "Translates (moves) the real value \
at each iteration."
endparam

param y
caption = "Translation (y)"
default = 0.0
hint = "Translates (moves) the imaginary value \
at each iteration."
endparam

param a
caption = "Matrix r0,c0"
default = 1.0
hint = "Row 0 Column 0 of a generalised \
transformation matrix - use 1.0 \
for the identity matrix."
endparam

param b
caption = "Matrix r0,c1"
default = 0.0
hint = "Row 0 Column 1 of a generalised \
transformation matrix - use 0.0 \
for the identity matrix."
endparam

param c
caption = "Matrix r1,c0"
default = 0.0
hint = "Row 1 Column 0 of a generalised \
transformation matrix - use 0.0 \
for the identity matrix."
endparam

param d
caption = "Matrix r1,c1"
default = 1.0
hint = "Row 1 Column 1 of a generalised \
transformation matrix - use 1.0 \
for the identity matrix."
endparam

param power
caption = "Power"
default = (2,0)
endparam

param sizesq
caption = "Magnification"
default = 3
endparam

param pairimp
caption = "MD Type"
default = 1
enum = "first" "second" "third"
hint = "Works together with param Variation MD"
endparam

param sgn
caption = "Apply MD"
default = false
endparam

param turnMode
caption = "Turnaround Mode"
default = false
endparam

param turnScale
caption = "Turn Scale"
default = 1.0
min     = 0.0
endparam

param corte1
caption = "Turnaround #1"
default = 4.0
endparam

param corte2
caption = "Turnaround #2"
default = 2.0
endparam

param zJouk
caption = "Joukowskij"
default = (0.0,0.0)
endparam

param intf
caption = "MD Factor"
enum = "ceil" "round"
endparam

func fn1
caption = "Slice Function"
default = ident()
endfunc

func fn2
caption = "Pinsky Function 1"
default = ident()
endfunc

func fn3
caption = "Pinsky Function 2"
default = flip()
endfunc

func fn4
caption = "Pinsky Function 3"
default = ident()
endfunc

func fn5
caption = "Marnmi Function"
default = ident()
endfunc

func fn6
caption = "Barn/Sqar Fct."
default = sqr()
endfunc

func Fn7
caption = "Dave Fct. 1"
default = acos()
endfunc

func Fn8
caption = "Dave Fct. 2"
default = cos()
endfunc

func bailFunc
caption = "Shape Fct."
default = ident()
endfunc

func goofFunc
caption = "Goofy Fct."
default = sqr()
endfunc

}

kpkdonquixley {
; Written by KPK August 2000
;
; Additional bailout ideas by Andreas Lober
; and David Makin
init:

z = 0.2*fn1(pixel^@spokes)
c = #pixel

loop:

IF (imag(z)>@shape)
z = @factor*real(z) + flip(@factor*imag(z)-1)

ELSEIF (real(z)>@shape)
z = @factor*real(z)-1 + flip(@factor*imag(z))

ELSE
z = @factor*real(z) + flip(@factor*imag(z))
z = @fn2( z )

ENDIF

j = @numberOfSkys

WHILE (j > 0)

IF (imag(z)>0.5)

z = (4 * (real(z)) + imag(z) * (z))

ELSEIF (real(z)>0.5)

z = (z*z-1 + (c*fn1(z) * (fn2(z))))

ELSEIF real(z) * imag(@start) + real(@start) * imag(z) >= 0
z = fn1(z - 1) * @start

ELSE
z = fn2(z + 1) * @start

ENDIF

j = j - 1

ENDWHILE ; j

bailout:

((@test == 0 && |z| <= @bailout) ||                         \
(@test == 1 && @goofFunc(real(z)) <= @bailout) ||                                \
(@test == 2 && @goofFunc(imag(z)) <= @bailout) ||                                \
(@test == 3 && (@goofFunc(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (@goofFunc(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (@goofFunc(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (@goofFunc(real(z) + imag(z)) <= @bailout)) ||                    \
(@test == 7 && (abs(sqr(real(z))/imag(z)) <= @bailout)) ||                 \
(@test == 8 && (abs(sqr(imag(z))/real(z)) <= @bailout)) ||                 \
(@test == 9 && (@bailFunc(z)*@bailExponent) <= @bailout)) ||                 \
(@test == 10 && (@bailFunc(z)^@bailExponent) <= @bailout)

default:
title = "KPK Don Quixley"
center = (0.5, 0.1)
magn = 0.5
maxiter = 500

param bailout
caption = "Bailout"
default = 4
endparam

param bailExponent
caption = "Bailout Exponent"
default = 3.0
endparam

param test
caption = "Shape Modifier"
enum = "mod" "real" "imag" "or" "and" "manh" \
"manr" "abs(x*x/y)" "abs(y*y/x)" "iter" \
"10"
default = 6
endparam

param start
caption = "Start Parameter"
default = (0.6, 1.1)
endparam

param numberOfSkys
caption = "Number of Skys"
default = 1
endparam

param spokes
caption = "Number of Spokes"
default = 2
endparam

param factor
caption = "Transformation"
default = 1.0
endparam

param shape
caption = "Cutting"
default = 0.0
endparam

func fn1
caption = "Function 1"
default = ident()
endfunc

func fn2
caption = "Function 2"
default = flip()
endfunc

func bailFunc
caption = "Bailout Fct."
default = ident()
endfunc

func goofFunc
caption = "Goofy Fct."
default = sqr()
endfunc

}

Kpktreebarney {
; Written by KPK September 2000
;
; From the coloring method Fractal
; Tree by Samuel Monnier
;
; Additional bailout ideas by Andreas
; Lober
;
; Barnsley algorithm implemented
init:

int iter = 1
z = 0
float arg = 0
int i = 0
int j = 0
float d = 0
float dist = 1e20
float x = 0
float y = 0

z = #pixel

bool bail = true

float dr = pi/180*@rotincr/2

complex oldZ = 0

loop:

IF (@mode == 0)

IF (real(z) * imag(@start) + real(@start) * imag(z) >= 0)
z = fn1(z - 1) * @start
ELSE
z = fn2(z + 1) * @start
ENDIF

z = z - @center
z = z*exp(-1i*@rot*pi/180)
z = z/@size
i = 0

IF (imag(z) >= 0)
z = fn1(z - 1) * @start
ELSE
z = fn2(z + 1) * @start
ENDIF

WHILE  i < @niter
i = i + 1

x = abs(real(z))
y = imag(z)
z = x + 1i*y
arg = -atan2(z) + pi/2

IF y >= -1 && y <= 0
d = x^@power
ELSEIF  y < -1
d = cabs(z + 1i)^@power
ELSEIF  y > 0
d = cabs(z)^@power
ENDIF

IF  d < dist
dist = d
ENDIF

j = @order-1
rotincr = j*dr

WHILE  j > 0
j = j - 2
IF  arg < (j+1)*dr
rotincr = j*dr
ENDIF
ENDWHILE

z = z*exp(1i*rotincr)
z = z*@magnincr
z = z - 1i

ENDWHILE

IF (imag(z) >= 0)
z = fn1(z - 1) * @start
ELSE
z = fn2(z + 1) * @start
ENDIF

ELSEIF (@mode == 1)

z = z - @center
z = z*exp(-1i*@rot*pi/180)
z = z/@size
i = 0

WHILE  i < @niter
i = i + 1

x = abs(real(z))
y = imag(z)
z = x + 1i*y
arg = -atan2(z) + pi/2

IF  y >= -1 && y <= 0
d = x^@power
ELSEIF  y < -1
d = cabs(z + 1i)^@power
ELSEIF  y > 0
d = cabs(z)^@power
ENDIF

IF d < dist
dist = d
ENDIF

j = @order-1
rotincr = j*dr

WHILE  j > 0
j = j - 2
IF  arg < (j+1)*dr
rotincr = j*dr
ENDIF
ENDWHILE

z = z*exp(1i*rotincr)
z = z*@magnincr
z = z - 1i

ENDWHILE

ELSEIF (@mode == 2)

IF (imag(z) >= 0)
z = fn1(z - 1) * @start
ELSE
z = fn2(z + 1) * @start
ENDIF
ENDIF

complex bailCheck = 0
complex bailZ = 0

IF (@bailMode == 0)
bailZ = z
ELSEIF (@bailMode == 1)
bailZ = z-oldZ
ELSEIF (@bailMode == 2)
bailZ = (z+oldZ)/2
ELSEIF (@bailMode == 3)
bailZ = z-#pixel
ELSEIF (@bailMode == 4)
bailZ = z/|@goofFunc(oldZ)|
ENDIF

IF (@test == 0)
bailCheck = bailZ
ELSEIF (@test == 1)
bailCheck = real(bailZ)^2
ELSEIF (@test == 2)
bailCheck = imag(bailZ)^2
ELSEIF (@test == 3)
float bailRe = real(bailZ)^2
float bailIm = imag(bailZ)^2
IF (bailRe < bailIm)
bailCheck = bailIm
ELSE
bailCheck = bailRe
ENDIF
ELSEIF (@test == 4)
float bailRe = real(bailZ)^2
float bailIm = imag(bailZ)^2
IF (bailRe > bailIm)
bailCheck = bailIm
ELSE
bailCheck = bailRe
ENDIF
ELSEIF (@test == 5)
bailCheck = (abs(real(bailZ)) + abs(imag(bailZ)))^2
ELSEIF (@test == 6)
bailCheck = @goofFunc(real(bailZ)) + imag(bailZ)
ELSEIF (@test == 7)
bailCheck = @goofFunc((real(bailZ)/imag(bailZ)))^2
ELSEIF (@test == 8)
bailCheck = @goofFunc((imag(bailZ)/real(bailZ)))^2
ELSEIF (@test == 9)
bailCheck = @goofFunc(bailZ*iter)
ELSEIF (@test == 10)
bailCheck = @goofFunc(bailZ + iter)/sqrt(#maxiter)
ELSEIF (@test == 11)
bailCheck = @goofFunc(real(bailZ) - imag(bailZ))^2
ELSEIF (@test == 12)
float phi = atan2(bailZ)/#pi
IF phi < 0.0
phi = phi + 2.0
ENDIF
bailCheck = bailZ*phi^2
ELSEIF (@test == 13)
float phi = atan2(bailZ)/#pi
IF phi < 0.0
phi = phi + 2.0
ENDIF
bailCheck = bailZ/phi^2
ELSEIF (@test == 14)
float phi = atan2(bailZ)/#pi
IF phi < 0.0
phi = phi + 2.0
ENDIF
bailCheck = bailZ*phi^2/sqrt(iter)
ELSEIF (@test == 15)
float phi = atan2(bailZ)/#pi
IF phi < 0.0
phi = phi + 2.0
ENDIF
bailCheck = bailZ*iter/phi^2
ELSEIF (@test == 16)
float reZ = real(bailZ)
bailCheck = reZ*reZ/abs(imag(bailZ))
ELSEIF (@test == 17)
bailCheck = @goofFunc(abs(real(bailZ))) + abs(imag(bailZ))
ELSEIF (@test == 18)
bailCheck = @goofFunc(bailZ)*iter/#maxiter
ENDIF

bailCheck = @bailFunc(bailCheck)

bailout:

bail && (  (@test <= 18 && |bailCheck| <= @bailout) \
|| (@test == 19 && real(@bailFunc(z))*real(@goofFunc(oldZ)) <  @bailout) \
|| (@test == 20 && imag(@bailFunc(z))*imag(@goofFunc(oldZ)) <  @bailout) \
|| (@test == 21 && real(@bailFunc(z))*imag(@goofFunc(oldZ)) <  @bailout) \
|| (@test == 22 && imag(@bailFunc(z))*real(@goofFunc(oldZ)) <  @bailout) \
)

default:
title = "KPK Treebarney"

param bailout
caption = "Bailout"
default = 10000000
endparam

param mode
caption = "Start"
default = 0
enum = "Treebarney" "The Tree" "Barney"
endparam

param start
caption = "Barnsley Param."
default = (0.6, 1.1)
endparam

param power
caption = "Power"
default = 1.0
endparam

param order
caption = "Tree Order"
default = 3
endparam

param rotincr
caption = "Tree Angle"
default = 60.0
endparam

param magnincr
caption = "Tree Magnification"
default = 1.5
endparam

param center
caption = "Center"
default = (0,0)
endparam

param rot
caption = "Rotation"
default = 0.0
endparam

param size
caption = "Size"
default = 1.0
hint = "Works with start parameter Treebarney and The Tree"
endparam

param niter
caption = "Number of Iteration"
default = 11
endparam

param itertr
caption = "Iteration to observe"
default = 1
endparam

param test
caption = "Shape Modifier"
enum = "mod" "real" "imag" "or" "and" "manh" \
"manr" "abs(x*x/y)" "abs(y*y/x)" "iter" \
"avg iter" "diff" "angle" "angle inv"  \
"angle/iter" "iter/angle" "float" "check" "dust" \
"crossing 1" "crossing 2" "hyper crossing 1" "hyper crossing 2"
default = 0
endparam

param bailMode
caption = "Shaping"
enum = "Normal" "Smooth" "Average" "Mixel" "Normed"
default = 0
endparam

func fn1
caption = "Slice Function"
default = ident()
endfunc

func fn2
caption = "Pinsky Function 1"
default = ident()
endfunc

func bailFunc
caption = "Shape Fct."
default = ident()
endfunc

func goofFunc
caption = "Goofy Fct."
default = sqr()
endfunc

}

Kpktribarnsky {
; Written by KPK August 2000
;
; Some code used with kind permission
; of Samuel Monnier
;
; Additional bailout ideas from Dave
; Makin and Andreas Lober

init:

z = #pixel
float x = real(z)
float y = imag(z)
float a = @alpha*pi/180
float g = tan(a)

bool bail = false

int i = 0

z = x - @tw*y + flip(y)
x = real(z)

loop:

i = i + 1

IF i == 1
IF g*x + g < y || -g*x + g < y || y < 0
bail = true
endif

z = -2*z
z = z + 1i*g
z = z - @offset

ELSE

z = z + @offset
x = real(z)
y = imag(z)

IF real(z) * imag(@start) + real(@start) * imag(z) >= 0
z = (z - 1) * @start
ELSE
z = (z + 1) * @start
ENDIF

IF -g*x + g >= y  && g*x + g >= y && y >= 0
bail = true
ELSEIF g*x + g < y
z = 2*z + 2 - 1i*g
ELSEIF -g*x + g < y
z = 2*z - 2 - 1i*g
ELSEIF y < 0
z = 2*z + 1i*g
ENDIF

z = z - @offset
ENDIF

bailout:

bail == false && ((@test == 0 && |z| <= @bailout) ||                         \
(@test == 1 && @goofFunc(real(z)) <= @bailout) ||                                \
(@test == 2 && @goofFunc(imag(z)) <= @bailout) ||                                \
(@test == 3 && (@goofFunc(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (@goofFunc(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (@goofFunc(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (@goofFunc(real(z) + imag(z)) <= @bailout)) ||                    \
(@test == 7 && (abs(sqr(real(z))/imag(z)) <= @bailout)) ||                 \
(@test == 8 && (abs(sqr(imag(z))/real(z)) <= @bailout)) ||                 \
(@test == 9 && |@bailFunc(z)*@bailExponent| <= @bailout)) ||                 \
(@test == 10 && |@bailFunc(z)^@bailExponent| <= @bailout)

default:
title = "KPK Tribarnsky"
method = multipass
periodicity = 0
center = (0.0,0.5)

param bailout
caption = "Bailout"
default = 1000
hint = "Increase the values for edgy effects"
endparam

param bailExponent
caption = "Bailout Exponent"
default = 3.0
hint = "Try out values between 0.01 and 5"
endparam

param start
caption = "Start Parameter"
default = (1.0, 1.0)
hint = "Try out Re 0 and Im 1.1 for a squared structure. Increase the Re value carefully"
endparam

param alpha
caption = "Alpha"
default = 60.0
hint = "Set 60 for an equilateral triangle"
endparam

param tw
caption = "Twist"
default = 0.0
endparam

param offset
caption = "Offset"
default = (0,0)
endparam

param test
caption = "Shape Modifier"
enum = "mod" "real" "imag" "or" "and" "manh" \
"manr" "abs(x*x/y)" "abs(y*y/x)" "iter" \
"10"
default = 10
endparam

func fn1
caption = "Function 1"
default = ident()
endfunc

func fn2
caption = "Function 2"
default = ident()
endfunc

func bailFunc
caption = "Bailout Fct."
default = ident()
endfunc

func goofFunc
caption = "Goofy Fct."
default = sqr()
endfunc
}

kpkskcdbarnsky {
; Written by KPK August 2000
;
; With parts of  Samuel Monnier's
; Squarry Koch Curve formula
;
; Andreas Lober
;
; Spot effect after an idea of Andras Szolek
;
init:

i = 0
int iter = 1
z = #pixel

x = real(z)
y = imag(z)

tes = fn1(z)

zc = sqr(z/2)*0.7

float arg = 0
float angle = @angle*#pi/180

bool bail = true

IF (@mode1 == 0)
z = 0.2*@fn1(#pixel^@spokes)
arg = atan2(z)

ELSEIF (@mode1 == 1)
z = 0.2*@fn1(pixel^@spokes)
zc = @fn4(z/@sizesq)*@sizesq
z = 2*(z - (0.25*zc))/(0.5*@power)

arg = atan2(z)

IF (arg > #pi/2)
z = -1i*z

ELSEIF (arg > -#pi/2 && arg < 0)
z = 1i*z

ELSEIF (arg < -#pi/2)
z = -z

ENDIF

arg = atan2(z)

IF (arg > #pi/2 - angle)
z = z*exp(-1i*#pi/2)

ELSEIF (arg < #pi/2 - angle && arg > angle)
z = z*@fn1(-1i*#pi/4)
z = z*cos(angle)/cos(#pi/4-angle)

ENDIF
ENDIF

IF @spot == true
sp = 2

ELSE
sp = 1

ENDIF

IF @spot2 == true
sp2 = abs(tes)

ELSE
sp2 = sqrt(tes)

ENDIF

complex oldZ = 0

loop:

iter = iter + 1
oldZ = z
i = i + 1

bool bail = true

IF i == 2
z = 1/fn2(@r)*real(z) + 1i*fn2(@r)*imag(z)

IF @mode == 0

IF |x| < 1 && |y| < 1
bail = true

ENDIF

IF (imag(z) >= 0)
z = fn1(z - 1) * @start
ELSE
z = fn2(z + 1) * @start
ENDIF

IF sp2 < pi/4
z = z*fn3(1i*pi/2)*sp

ELSEIF (tes < -pi/4) && (tes > -3*pi/4)
z = z*fn3(1i*pi)

ELSEIF abs(tes) > 3*pi/4
z = z*fn3(1i*3*pi/2)

ENDIF

z = z - 1i

ELSEIF @mode == 1

z = 1/sqrt(2)*z*exp(1i*pi/4)
x = real(z)
y = imag(z)

IF |x| > 1 || |y| > 1
bail = true

ENDIF

tes = fn1(z)

IF (real(z) * imag(@start) + real(@start) * imag(z) >= 0)
z = fn1(z - 1) * @start
ELSE
z = fn2(z + 1) * @start
ENDIF

IF sp2 < pi/4
z = z*fn3(1i*pi/2)*sp

ELSEIF (tes < -pi/4) && (tes > -3*pi/4)
z = z*fn3(1i*pi)

ELSEIF abs(tes) > 3*pi/4
z = z*fn3(1i*3*pi/2)

ENDIF

z = -z + 1i

ENDIF

ELSEIF i > 2

z = z + zc

z = 1/sqrt(@r)*real(z) + 1i*sqrt(@r)*imag(z)

x = real(z)
y = imag(z)

IF abs(x) < 1/@s && abs(y - 1/@s) < 1/@s
bail = true

ENDIF

IF x < -1/@s && y < -x - 1/@s
z = 2*@s/(@s-1)*z + (@s+1)/(@s-1)

ELSEIF x > 1/@s && y < x - 1/@s
z = 2*@s/(@s-1)*z - (@s+1)/(@s-1)

ELSEIF x <= -1/@s && y > -x - 1/@s
z = z + 1/@s
z = z*fn3(-1i*pi/2)
z = @s*z - 1

ELSEIF x >= 1/@s && y > x - 1/@s
z = z - 1/@s
z = z*fn3(1i*pi/2)
z = @s*z + 1

ELSEIF abs(x) < 1/@s
z = @s*z - 2*1i

ENDIF

ENDIF

IF i >= 2
z = z - zc

ENDIF

complex bailCheck = 0
complex bailZ = 0

IF (@bailMode == 0)
bailZ = z
ELSEIF (@bailMode == 1)
bailZ = z-oldZ
ELSEIF (@bailMode == 2)
bailZ = (z+oldZ)/2
ELSEIF (@bailMode == 3)
bailZ = z-#pixel
ELSEIF (@bailMode == 4)
bailZ = z/|@goofFunc(oldZ)|
ENDIF

IF (@test == 0)
bailCheck = bailZ
ELSEIF (@test == 1)
bailCheck = real(bailZ)^2
ELSEIF (@test == 2)
bailCheck = imag(bailZ)^2
ELSEIF (@test == 3)
float bailRe = real(bailZ)^2
float bailIm = imag(bailZ)^2
IF (bailRe < bailIm)
bailCheck = bailIm
ELSE
bailCheck = bailRe
ENDIF
ELSEIF (@test == 4)
float bailRe = real(bailZ)^2
float bailIm = imag(bailZ)^2
IF (bailRe > bailIm)
bailCheck = bailIm
ELSE
bailCheck = bailRe
ENDIF
ELSEIF (@test == 5)
bailCheck = (abs(real(bailZ)) + abs(imag(bailZ)))^2
ELSEIF (@test == 6)
bailCheck = @goofFunc(real(bailZ)) + imag(bailZ)
ELSEIF (@test == 7)
bailCheck = @goofFunc((real(bailZ)/imag(bailZ)))^2
ELSEIF (@test == 8)
bailCheck = @goofFunc((imag(bailZ)/real(bailZ)))^2
ELSEIF (@test == 9)
bailCheck = @goofFunc(bailZ*iter)
ELSEIF (@test == 10)
bailCheck = @goofFunc(bailZ + iter)/sqrt(#maxiter)
ELSEIF (@test == 11)
bailCheck = @goofFunc(real(bailZ) - imag(bailZ))^2
ELSEIF (@test == 12)
float phi = atan2(bailZ)/#pi
IF phi < 0.0
phi = phi + 2.0
ENDIF
bailCheck = bailZ*phi^2
ELSEIF (@test == 13)
float phi = atan2(bailZ)/#pi
IF phi < 0.0
phi = phi + 2.0
ENDIF
bailCheck = bailZ/phi^2
ELSEIF (@test == 14)
float phi = atan2(bailZ)/#pi
IF phi < 0.0
phi = phi + 2.0
ENDIF
bailCheck = bailZ*phi^2/sqrt(iter)
ELSEIF (@test == 15)
float phi = atan2(bailZ)/#pi
IF phi < 0.0
phi = phi + 2.0
ENDIF
bailCheck = bailZ*iter/phi^2
ELSEIF (@test == 16)
float reZ = real(bailZ)
bailCheck = reZ*reZ/abs(imag(bailZ))
ELSEIF (@test == 17)
bailCheck = @goofFunc(abs(real(bailZ))) + abs(imag(bailZ))
ELSEIF (@test == 18)
bailCheck = @goofFunc(bailZ)*iter/#maxiter
ENDIF

bailCheck = @bailFunc(bailCheck)

bailout:

bail && (  (@test <= 18 && |bailCheck| <= @bailout) \
|| (@test == 19 && real(@bailFunc(z))*real(@goofFunc(oldZ)) <  @bailout) \
|| (@test == 20 && imag(@bailFunc(z))*imag(@goofFunc(oldZ)) <  @bailout) \
|| (@test == 21 && real(@bailFunc(z))*imag(@goofFunc(oldZ)) <  @bailout) \
|| (@test == 22 && imag(@bailFunc(z))*real(@goofFunc(oldZ)) <  @bailout) \
)

default:

title = "KPK SKCD Barnsky"
method = multipass
periodicity = 0

param bailout
caption = "Bailout"
default = 1000
endparam

param start
caption = "Start Parameter "
default = (1.0, 1.0)
endparam

param mode1
caption = "Start"
default = 1
enum = "Start Barney" "Start Barnsky"
endparam

param test
caption = "Shape Modifier"
enum = "mod" "real" "imag" "or" "and" "manh" \
"manr" "abs(x*x/y)" "abs(y*y/x)" "iter" \
"avg iter" "diff" "angle" "angle inv"  \
"angle/iter" "iter/angle" "float" "check" "dust" \
"crossing 1" "crossing 2" "hyper crossing 1" "hyper crossing 2"
default = 0
endparam

param bailMode
caption = "Shaping"
enum = "Normal" "Smooth" "Average" "Mixel" "Normed"
default = 0
endparam

param spokes
caption = "Spokes"
default = 1.0
hint = "Decimal values are possible!"
endparam

param power
caption = "Power"
default = (2,0)
endparam

param sizesq
caption = "Magnification"
default = 3
endparam

param r
caption = "Smoothness"
default = 1.0
min = 1.0
endparam

param mode
caption = "Variation"
default = 0
enum = "Arranged" "Distorted"
endparam

param spot
caption = "Spot Change"
default = false
endparam

param spot2
caption = "Distortion Change"
default = true
endparam

param s
caption = "Magnification step"
default = 4.0
endparam

param angle
caption = "Angle"
default = 0.0
endparam

func fn1
caption = "Function 1"
default = ident()
endfunc

func fn2
caption = "Function 2"
default = ident()
endfunc

func fn3
caption = "Function 3"
default = exp()
endfunc

func bailFunc
caption = "Shape Fct."
default = ident()
endfunc

func goofFunc
caption = "Goofy Fct."
default = sqr()
endfunc
}

kpkbarnsley4t {
; Written by KPK November 2000
;
; After the Barnsley code by Luke Plant
;
; Additional bailout ideas by Andreas Lober
; and David Makin
init:

z = pixel
z = 0.2*@f1(pixel^@spokes)
sm = @j

loop:

IF @invert
z = 1/z
ENDIF

IF (@mode == 0)

IF real(z) * imag(@start) + real(@start) * imag(z) >= 0
z = @f1(z - 1) * @start
ELSE
z = @f2(z + 1) * @start
ENDIF

IF real(z) >= 0
z = @f3(z - 1) * @start
ELSE
z = @f4(z + 1) * @start
ENDIF

ELSEIF (@mode == 1)

IF real(z) >= 0
z = @f3(z - 1) * @start
ELSE
z = @f4(z + 1) * @start
ENDIF

ELSEIF (@mode == 2)

IF (imag(z)>@corte)
z = @factor*real(z) + flip(@factor*imag(z)-1)
ELSEIF real(z) >= 0
z = @f3(z - 1) * @start
ELSEIF (real(z)>@corte)
z = @factor*real(z)-1 + flip(@factor*imag(z))
ELSEIF real(z) >= 0
z = @f4(z + 1) * @start
ELSE
z = @factor*real(z) + flip(@factor*imag(z))
z = @f2(z)
ENDIF

ELSEIF (@mode == 3)

float x = @conv * real(z)
float y = @conv * imag(z)

z = x + flip( y )

IF ( x > @corte )
IF ( y > @corte )

ELSE
z = z - 1
ENDIF
ENDIF

complex z1 = z

IF ( y > @corte )
z1 = z1 - flip( (1, 0) )
ENDIF

IF (@mode2 == 0)
z = @f1(z1) + @f2(sm)
IF real(z) >= 0
z = @f3(z - 1) * @start
ELSE
z = @f4(z + 1) * @start
ENDIF
ELSEIF (@mode2 == 1)
z = @f1(z1) - @f2(sm)
ELSEIF (@mode2 == 2)
z = @f1(z1) * @f2(sm)
ELSEIF (@mode2 == 3)
z = @f1(z1) / @f2(sm)
ELSEIF (@mode2 == 4)
z = @f1(z1 + sm)
ELSEIF (@mode2 == 5)
z = @f1(z1 - sm)
ENDIF

ENDIF

bailout:

((@test == 0 && |z| <= @bailout) ||                         \
(@test == 1 && @goofFunc(real(z)) <= @bailout) ||                                \
(@test == 2 && @goofFunc(imag(z)) <= @bailout) ||                                \
(@test == 3 && (@goofFunc(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (@goofFunc(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (@goofFunc(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (@goofFunc(real(z) + imag(z)) <= @bailout)) ||                    \
(@test == 7 && (abs(sqr(real(z))/imag(z)) <= @bailout)) ||                 \
(@test == 8 && (abs(sqr(imag(z))/real(z)) <= @bailout)) ||                 \
(@test == 9 && (@bailFunc(z)*@bailExponent) <= @bailout)) ||                 \
(@test == 10 && (@bailFunc(z)^@bailExponent) <= @bailout) ||                 \
(@test == 11 &&  (|z + pixel| < @bailout))

default:
title = "KPK Barnsley 4T"
center = (0.4, 0.4)
magn = 0.1
maxiter = 149
method = multipass
periodicity = 0

param bailout
caption = "Bailout value"
default = 2
min = 1
endparam

param start
caption = "Barnsley Set"
default = (0.6, 1.2)
endparam

param mode
caption = "Variation"
enum = "4T" "Classic" "Sierpley" "Sir P."
default = 1
endparam

param mode2
caption = "Sierp Variation"
default = 1
enum = "Barnsley Mix" "Fct. Mix I" "Fct. Mix II" "Fct. Mix III" "Fct. Mix IV" "Fct. Mix V"
hint = "Use With Variation Sir P."
endparam

param j
caption = "Sierp Set"
default = (0.0, 0.0)
hint = "Use With Variation Sir P."
endparam

param bailExponent
caption = "Bailout Exponent"
default = 3.0
endparam

param test
caption = "Shape Modifier"
enum = "mod" "real" "imag" "or" "and" "manh" \
"manr" "abs(x*x/y)" "abs(y*y/x)" "iter" \
"10" "11"
default = 5
endparam

param factor
caption = "Transform Factor"
default = 2.0
endparam

param conv
default = 2.0
caption = "Convergence"
hint = "Use With Variation Sir P."
endparam

param corte
caption = "Cutting edges"
default = 0.5
endparam

param invert
caption = "Invert z"
default = false
endparam

param spokes
caption = "Spokes"
default = 1.0
hint = "Decimal values possible!"
endparam

func f1
caption = "Function 1"
default = ident()
endfunc

func f2
caption = "Function 2"
default = ident()
endfunc

func f3
caption = "Function 3"
default = ident()
endfunc

func f4
caption = "Function 4"
default = flip()
endfunc

func bailFunc
caption = "Bailout Fct."
default = ident()
endfunc

func goofFunc
caption = "Goofy Fct."
default = sqr()
endfunc
}

kpkbarnsley4tz {
; Written by KPK December 2000
;
; After the Barnsley code by Luke Plant
;
; Additional bailout ideas by Andreas Lober
; and David Makin
;
; Hints:
;
; When "Additional Z" is enabled, all the listed
; "Variation" parameters are affected
;
; The "Change" parameters can be used in
; every combination
;
; The "Change something" parameter works very well
; with Function 3 set to flip
;
; Functions 5 and 6 are only for use with parameter
; "Change more++"
;
; "Sierp Variation" and "Sierp Set" are only for
; use with Variation "Sir P."
;
; Try out changing the Bailout Value in small steps!
;
init:

i = 0
z = pixel
z = 0.2*@f1(pixel^@spokes)
sm = @j
a = @f1(real(z))
b = @f2(imag(z))
z = a + flip(b)

loop:

IF @zch == true
z = @f3(z)*exp(1i*i)
ENDIF

IF @more1 == true
z = z * @p2 + pixel
ENDIF

IF @more2 == true
IF imag(z) >= 0
z = @f3(z - 1) * @start
ELSE
z = @f4(z + 1) * @start
ENDIF
ENDIF

IF @more3 == true
z = @f5(@px)*@f6(z+@px)
ENDIF

IF @invert
z = 1/z
ENDIF

IF (@mode == 0)

IF real(z) * imag(@start) + real(@start) * imag(z) >= 0
z = @f1(z - 1) * @start
ELSE
z = @f2(z + 1) * @start
ENDIF

IF real(z) >= 0
z = @f3(z - 1) * @start
ELSE
z = @f4(z + 1) * @start
ENDIF

ELSEIF (@mode == 1)

IF real(z) >= 0
z = @f3(z - 1) * @start
ELSE
z = @f4(z + 1) * @start
ENDIF

ELSEIF (@mode == 2)

IF (imag(z)>@corte)
z = @factor*real(z) + flip(@factor*imag(z)-1)
ELSEIF real(z) >= 0
z = @f3(z - 1) * @start
ELSEIF (real(z)>@corte)
z = @factor*real(z)-1 + flip(@factor*imag(z))
ELSEIF real(z) >= 0
z = @f4(z + 1) * @start
ELSE
z = @factor*real(z) + flip(@factor*imag(z))
z = @f2(z)
ENDIF

ELSEIF (@mode == 3)

float x = @conv * real(z)
float y = @conv * imag(z)

z = x + flip( y )

IF ( x > @corte )
IF ( y > @corte )

ELSE
z = z - 1
ENDIF
ENDIF

complex z1 = z

IF ( y > @corte )
z1 = z1 - flip( (1, 0) )
ENDIF

IF (@mode2 == 0)
z = @f1(z1) + @f2(sm)
IF real(z) >= 0
z = @f3(z - 1) * @start
ELSE
z = @f4(z + 1) * @start
ENDIF
ELSEIF (@mode2 == 1)
z = @f1(z1) - @f2(sm)
ELSEIF (@mode2 == 2)
z = @f1(z1) * @f2(sm)
ELSEIF (@mode2 == 3)
z = @f1(z1) / @f2(sm)
ELSEIF (@mode2 == 4)
z = @f1(z1 + sm)
ELSEIF (@mode2 == 5)
z = @f1(z1 - sm)
ENDIF

ELSEIF (@mode == 4)

IF real(z) >= 0
z = @f3(z - 1) * @start
ELSE
z = @f4(z + 1) * @start
ENDIF

z = @f1(1-abs(imag(z)*@p1-real(z)))+flip(@f2(1-abs(1-real(z)-imag(z))))-@p2

ELSEIF (@mode == 5)

IF (imag(z)>@corte)
z = @factor*real(z) + flip(@factor*imag(z)-1)
ELSEIF real(z) >= 0
z = @f3(z - 1) * @start
ELSEIF (real(z)>@corte)
z = @factor*real(z)-1 + flip(@factor*imag(z))
ELSEIF real(z) >= 0
z = @f4(z + 1) * @start
ELSE
z = @factor*real(z) + flip(@factor*imag(z))
z = @f2(z)
ENDIF

z = @f1(1-abs(imag(z)*@p1-real(z)))+flip(@f2(1-abs(1-real(z)-imag(z))))-@p2

ENDIF

z = @f1(1-abs(imag(z)*@p1-real(z)))+flip(@f2(1-abs(1-real(z)-imag(z))))-@p2

IF (@mode == 0)

IF real(z) * imag(@start) + real(@start) * imag(z) >= 0
z = @f1(z - 1) * @start
ELSE
z = @f2(z + 1) * @start
ENDIF

IF real(z) >= 0
z = @f3(z - 1) * @start
ELSE
z = @f4(z + 1) * @start
ENDIF

ELSEIF (@mode == 1)

IF real(z) >= 0
z = @f3(z - 1) * @start
ELSE
z = @f4(z + 1) * @start
ENDIF

ELSEIF (@mode == 2)

IF (imag(z)>@corte)
z = @factor*real(z) + flip(@factor*imag(z)-1)
ELSEIF real(z) >= 0
z = @f3(z - 1) * @start
ELSEIF (real(z)>@corte)
z = @factor*real(z)-1 + flip(@factor*imag(z))
ELSEIF real(z) >= 0
z = @f4(z + 1) * @start
ELSE
z = @factor*real(z) + flip(@factor*imag(z))
z = @f2(z)
ENDIF

ELSEIF (@mode == 3)

float x = @conv * real(z)
float y = @conv * imag(z)

z = x + flip( y )

IF ( x > @corte )
IF ( y > @corte )

ELSE
z = z - 1
ENDIF
ENDIF

complex z1 = z

IF ( y > @corte )
z1 = z1 - flip( (1, 0) )
ENDIF

IF (@mode2 == 0)
z = @f1(z1) + @f2(sm)
IF real(z) >= 0
z = @f3(z - 1) * @start
ELSE
z = @f4(z + 1) * @start
ENDIF
ELSEIF (@mode2 == 1)
z = @f1(z1) - @f2(sm)
ELSEIF (@mode2 == 2)
z = @f1(z1) * @f2(sm)
ELSEIF (@mode2 == 3)
z = @f1(z1) / @f2(sm)
ELSEIF (@mode2 == 4)
z = @f1(z1 + sm)
ELSEIF (@mode2 == 5)
z = @f1(z1 - sm)
ENDIF

ELSEIF (@mode == 4)

IF real(z) >= 0
z = @f3(z - 1) * @start
ELSE
z = @f4(z + 1) * @start
ENDIF

z = @f1(1-abs(imag(z)*@p1-real(z)))+flip(@f2(1-abs(1-real(z)-imag(z))))-@p2

ELSEIF (@mode == 5)

IF (imag(z)>@corte)
z = @factor*real(z) + flip(@factor*imag(z)-1)
ELSEIF real(z) >= 0
z = @f3(z - 1) * @start
ELSEIF (real(z)>@corte)
z = @factor*real(z)-1 + flip(@factor*imag(z))
ELSEIF real(z) >= 0
z = @f4(z + 1) * @start
ELSE
z = @factor*real(z) + flip(@factor*imag(z))
z = @f2(z)
ENDIF

z = @f1(1-abs(imag(z)*@p1-real(z)))+flip(@f2(1-abs(1-real(z)-imag(z))))-@p2

ENDIF
ENDIF

bailout:

((@test == 0 && |z| <= @bailout) ||                         \
(@test == 1 && @goofFunc(real(z)) <= @bailout) ||                                \
(@test == 2 && @goofFunc(imag(z)) <= @bailout) ||                                \
(@test == 3 && (@goofFunc(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (@goofFunc(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (@goofFunc(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (@goofFunc(real(z) + imag(z)) <= @bailout)) ||                    \
(@test == 7 && (abs(sqr(real(z))/imag(z)) <= @bailout)) ||                 \
(@test == 8 && (abs(sqr(imag(z))/real(z)) <= @bailout)) ||                 \
(@test == 9 && (@bailFunc(z)*@bailExponent) <= @bailout)) ||                 \
(@test == 10 && (@bailFunc(z)^@bailExponent) <= @bailout) ||                 \
(@test == 11 &&  (|z + pixel| < @bailout))

default:
title = "KPK Barnsley 4TZ"
center = (0.4, 0.4)
magn = 0.1
maxiter = 149
method = multipass
periodicity = 0

param bailout
caption = "Bailout value"
default = 2
min = 1
endparam

enum = "Without Z" "With Z"
default = 0
endparam

param start
caption = "Barnsley Set"
default = (0.6, 1.2)
endparam

param mode
caption = "Variation"
enum = "4T" "Classic" "Sierpley" "Sir P." "CZ" "Sir Z"
default = 1
endparam

param mode2
caption = "Sierp Variation"
default = 1
enum = "Barnsley Mix" "Fct. Mix I" "Fct. Mix II" "Fct. Mix III" "Fct. Mix IV" "Fct. Mix V"
hint = "Use With Variation Sir P."
endparam

param j
caption = "Sierp Set"
default = (0.0, 0.0)
hint = "Use With Variation Sir P."
endparam

param bailExponent
caption = "Bailout Exponent"
default = 3.0
endparam

param test
caption = "Shape Modifier"
enum = "mod" "real" "imag" "or" "and" "manh" \
"manr" "abs(x*x/y)" "abs(y*y/x)" "iter" \
"10" "11"
default = 5
endparam

param p1
default = 1.0
caption = "Z Parameter 1"
endparam

param p2
default = (1.0, 0.5)
caption = "Z Parameter 2"
endparam

param zch
caption = "Change something"
default = true
hint = "Set Function 3 to flip!"
endparam

param more1
caption = "Change more"
default = false
hint = "Use together with Z Parameter 2"
endparam

param more2
caption = "Change more+"
default = false
hint = "Use together with Functions 3 and 4"
endparam

param more3
caption = "Change more++"
default = false
hint = "Use together with Functions 5 and 6 and More++ Parameter"
endparam

param px
caption = "More++ Parameter"
default = (-0.2, 1.0)
hint = "Use with param Change more++"
endparam

param factor
caption = "Transform Factor"
default = 2.0
endparam

param conv
default = 2.0
caption = "Convergence"
hint = "Use With Variation Sir P."
endparam

param corte
caption = "Cutting edges"
default = 0.5
endparam

param invert
caption = "Invert z"
default = false
endparam

param spokes
caption = "Split"
default = 1.0
hint = "Decimal values possible!"
endparam

func f1
caption = "Function 1"
default = ident()
endfunc

func f2
caption = "Function 2"
default = ident()
endfunc

func f3
caption = "Function 3"
default = ident()
endfunc

func f4
caption = "Function 4"
default = flip()
endfunc

func f5
caption = "Function 5"
default = exp()
endfunc

func f6
caption = "Function 6"
default = cosh()
endfunc

func bailFunc
caption = "Bailout Fct."
default = ident()
endfunc

func goofFunc
caption = "Goofy Fct."
default = sqr()
endfunc
}

kpkMoebiusMandelbarnsley {
;
; Written by KPK January 2001
;
; From a pre-version of
; Andreas Lober's Moebius' Mandel formula
;
;
init:

z = @start
float xLim = abs(real(@limit))
float yLim = abs(imag(@limit))
float reZ = 0
float imZ = 0

loop:

IF @more == true
IF real(z) >= 0
z = @f1(z - 1) * @start2
ELSE
z = @f2(z + 1) * @start2
ENDIF

z = z^@power + #pixel

reZ = real(z)
imZ = imag(z)

reZNew = reZ
imZNew = imZ

IF (reZ < -xLim)
reZNew = reZNew + 2*xLim
IF (@mode == 1)
imZNew = imZNew - yLim
ELSEIF (@mode == 2)
imZNew = -imZNew
ENDIF

ELSEIF (reZ > xLim)
reZNew = reZNew - 2*xLim
IF (@mode == 1)
imZNew = imZNew + yLim
ELSEIF (@mode == 2)
imZNew = -imZNew
ENDIF
ENDIF

IF (imZ < -yLim)
imZNew = imZNew + 2*yLim
IF (@mode == 1)
reZNew = reZNew - xLim
ELSEIF (@mode == 2)
reZNew = -reZNew
ENDIF

ELSEIF (imZ > yLim)
imZNew = imZNew - 2*yLim
IF (@mode == 1)
reZNew = reZNew + xLim
ELSEIF (@mode == 2)
reZNew = reZNew
ENDIF
ENDIF

z = reZNew + 1i*imZNew

ENDIF

bailout:
((@test == 0 && |z| <= @bailout) ||                         \
(@test == 1 && @goofFunc(real(z)) <= @bailout) ||                                \
(@test == 2 && @goofFunc(imag(z)) <= @bailout) ||                                \
(@test == 3 && (@goofFunc(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (@goofFunc(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (@goofFunc(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (@goofFunc(real(z) + imag(z)) <= @bailout)) ||                    \
(@test == 7 && (abs(sqr(real(z))/imag(z)) <= @bailout)) ||                 \
(@test == 8 && (abs(sqr(imag(z))/real(z)) <= @bailout)) ||                 \
(@test == 9 && (@bailFunc(z)*@bailExponent) <= @bailout)) ||                 \
(@test == 10 && (@bailFunc(z)^@bailExponent) <= @bailout) ||                 \
(@test == 11 &&  (|z + pixel| < @bailout))

default:
title = "KPK Moebius' Mandel Barnsley"
center = (-0.5, 0)
maxiter = 100
method = multipass
periodicity = 0

param start
caption = "Starting point"
default = (0,0)
hint = "Perturbation. Use (0,0) for the standard Mandelbrot set."
endparam

param limit
caption = "Moebius limits"
default = (2,2)
endparam

param mode
caption = "Moebius Mode"
enum    = "Normal" "Double" "Inverse"
default = 0
endparam

param test
caption = "Shape Modifier"
enum = "mod" "real" "imag" "or" "and" "manh" \
"manr" "abs(x*x/y)" "abs(y*y/x)" "iter" \
"10" "11"
default = 5
endparam

param power
caption = "Power"
default = (1,0)
hint = "This defines the power of the Mandelbrot set. Use (2,0) \
for the standard Mandelbrot set."
endparam

param bailout
caption = "Bailout value"
default = 4.0
hint = "Defines how soon an orbit bails out, i.e. doesn't belong \
to the inner set anymore."
endparam

param bailExponent
caption = "Bailout Exponent"
default = 3.0
endparam

param more
caption = "Barnsley"
default = true
endparam

param start2
caption = "Barnsley Set"
default = (0.8, 0.8)
endparam

func f1
caption = "Function 1"
default = ident()
endfunc

func f2
caption = "Function 2"
default = ident()
endfunc

func bailFunc
caption = "Bailout Fct."
default = ident()
endfunc

func goofFunc
caption = "Goofy Fct."
default = sqr()
endfunc

switch:
type = "kpkMoebiusJuliabarnsley"
seed = #pixel
power = power
bailout = bailout
limit = limit
mode = mode

}

kpkMoebiusJuliabarnsley {
;
; Written by KPK January 2001
;
; From a pre-version of
; Andreas Lober's Moebius' Julia formula
;
init:
z = #pixel
float xLim = abs(real(@limit))
float yLim = abs(imag(@limit))
float reZ = 0
float imZ = 0

loop:

IF @more == true
IF real(z) >= 0
z = @f1(z - 1) * @start2
ELSE
z = @f2(z + 1) * @start2
ENDIF

z = z^@power + @seed

reZ = real(z)
imZ = imag(z)

reZNew = reZ
imZNew = imZ

IF (reZ < -xLim)
reZNew = reZNew + 2*xLim
IF (@mode == 1)
imZNew = imZNew - yLim
ELSEIF (@mode == 2)
imZNew = -imZNew
ENDIF

ELSEIF (reZ > xLim)
reZNew = reZNew - 2*xLim
IF (@mode == 1)
imZNew = imZNew + yLim
ELSEIF (@mode == 2)
imZNew = -imZNew
ENDIF
ENDIF

IF (imZ < -yLim)
imZNew = imZNew + 2*yLim
IF (@mode == 1)
reZNew = reZNew - xLim
ELSEIF (@mode == 2)
reZNew = -reZNew
ENDIF

ELSEIF (imZ > yLim)
imZNew = imZNew - 2*yLim
IF (@mode == 1)
reZNew = reZNew + xLim
ELSEIF (@mode == 2)
reZNew = reZNew
ENDIF
ENDIF

z = reZNew + 1i*imZNew

ENDIF

bailout:

((@test == 0 && |z| <= @bailout) ||                         \
(@test == 1 && @goofFunc(real(z)) <= @bailout) ||                                \
(@test == 2 && @goofFunc(imag(z)) <= @bailout) ||                                \
(@test == 3 && (@goofFunc(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (@goofFunc(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (@goofFunc(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (@goofFunc(real(z) + imag(z)) <= @bailout)) ||                    \
(@test == 7 && (abs(sqr(real(z))/imag(z)) <= @bailout)) ||                 \
(@test == 8 && (abs(sqr(imag(z))/real(z)) <= @bailout)) ||                 \
(@test == 9 && (@bailFunc(z)*@bailExponent) <= @bailout)) ||                 \
(@test == 10 && (@bailFunc(z)^@bailExponent) <= @bailout) ||                 \
(@test == 11 &&  (|z + pixel| < @bailout))

default:
title = "KPK Moebius' Julia Barnsley"
center = (-0.5, 0)
maxiter = 100
method = multipass
periodicity = 0

param seed
caption = "Julia seed"
default = (-1.25, 0)
hint = "Use this to create many different Julia sets. You can \
also set this value using the Switch feature."
endparam

param limit
caption = "Moebius limits"
default = (2,2)
endparam

param mode
caption = "Moebius Mode"
enum    = "Normal" "Double" "Inverse"
default = 2
endparam

param power
caption = "Power"
default = (1,0)
hint = "This defines the power of the Julia set. Use (2,0) \
for the standard Julia set."
endparam

param bailout
caption = "Bailout value"
default = 4.0
min = 1.0
hint = "Defines how soon an orbit bails out, i.e. doesn't belong \
to the Mandelbrot set anymore."
endparam

param test
caption = "Shape Modifier"
enum = "mod" "real" "imag" "or" "and" "manh" \
"manr" "abs(x*x/y)" "abs(y*y/x)" "iter" \
"10" "11"
default = 5
endparam

param bailExponent
caption = "Bailout Exponent"
default = 3.0
endparam

param more
caption = "Barnsley"
default = true
endparam

param start2
caption = "Barnsley Set"
default = (0.8, 0.8)
endparam

func f1
caption = "Function 1"
default = ident()
endfunc

func f2
caption = "Function 2"
default = ident()
endfunc

func bailFunc
caption = "Bailout Fct."
default = ident()
endfunc

func goofFunc
caption = "Goofy Fct."
default = sqr()
endfunc

switch:
type = "kpkMoebiusMandelbarnsley"
seed = #pixel
power = power
bailout = bailout
limit = limit
mode = mode

}

kpkzeppbarn {
; Written by KPK January/February 2001
;
; Updated March 2001
;
; After the Barnsley code by Luke Plant
;
; With parts of Samuel Monnier's
; Octogonal Slices formula and his
; Square Spiral and Polygon Spiral transform
;
; Enhancements by Andreas Lober
;
; Additional bailout ideas by Andreas Lober
; and David Makin
Init:

float ratioSum = (@xRatio + @yRatio)/2
float xRatio = @xRatio/ratioSum
float yRatio = @yRatio/ratioSum

complex z = pixel
zc = fn4(z/@sizesq)*@sizesq
z = 2*(z - (0.25*zc))/(0.5*@power)

nz = 0
int i = 0
int j = 0

float r = @rw/@rh
float arg = 0
float magn = (sin(pi-pi*(@order-2)/@order-pi/180*@alpha)+sin(pi/180*@alpha))/sin(pi*(@order-2)/@order)*@mtw

z = z*exp(1i*pi/180*@rot1)*(pixel^@spokes)

float arg = 0
float angle = @angle*pi/180

arg = atan2(z)

IF arg > pi/2
z = -1i*z

ELSEIF arg > -pi/2 && arg < 0
z = 1i*z

ELSEIF arg < -pi/2
z = -z

ENDIF

arg = atan2(z)

IF arg > pi/2 - angle
z = z*exp(-1i*pi/2)

ELSEIF arg < pi/2 - angle && arg > angle
z = z*fn1(-1i*pi/4)
z = z*cos(angle)/cos(pi/4-angle)

ENDIF

z = z*exp(1i*pi/180*@rot1)

loop:

IF @invert
z = 1/z
ENDIF

IF (@mode == 0)

p = @start
z = 1-fn1(imag(z)*p-real(z))+fn2(1-abs(1-real(z)-imag(z)))

IF real(z) >= 0
z = fn3(z - 1) * @start
ELSE
z = fn4(z + 1) * @start
ENDIF

ELSEIF (@mode == 1)

p = @start
z = 1-fn1(imag(z)*p-real(z))+fn2(1-@f5(1-real(z)-imag(z)))

IF (imag(z)>@corte)
z = @factor*real(z) + flip(@factor*imag(z)-1)
ELSEIF real(z) >= 0
z = fn1(z - 1) * @start
ELSEIF (real(z)>@corte)
z = @factor*real(z)-1 + flip(@factor*imag(z))
ELSEIF real(z) >= 0
z = fn4(z + 1) * @start
ELSE
z = @factor*real(z) + flip(@factor*imag(z))
z = fn2(z)
ENDIF

ELSEIF (@mode == 2)

IF (imag(z)>@corte)
z = @factor*real(z) + flip(@factor*imag(z)-1)
ELSEIF real(z) >= 0
z = fn1(z - 1) * @start
ELSEIF (real(z)>@corte)
z = @factor*real(z)-1 + flip(@factor*imag(z))
ELSEIF real(z) >= 0
z = fn4(z + 1) * @start
ELSE
z = @factor*real(z) + flip(@factor*imag(z))
z = fn2(z)
ENDIF

ELSEIF (@mode == 3)

IF real(z) * imag(@start) + real(@start) * imag(z) >= 0
z = fn1(z - 1) * @start
ELSE
z = fn2(z + 1) * p2
ENDIF

IF real(z) >= 0
z = fn3(z - 1) * p2
ELSE
z = fn4(z + 1) * @start
ENDIF

IF real(z) >= 0
z = fn3(z - 1) * p2
ELSE
z = fn4(z + 1) * @start
ENDIF

IF real(z) * imag(@start) + real(@start) * imag(z) >= 0
z = @f5(z - 1) * @start
ELSE
z = @f6(z + 1) * p2
ENDIF

ELSEIF (@mode == 4)

IF (imag(z)>0.5)
z = 2*real(z) + fn2(2*imag(z)-1)
ELSEIF (real(z)>0.5)
z = 2*real(z)-1 + fn2(2*imag(z))
ELSE
z = 2*real(z) + fn3(2*imag(z))
ENDIF

IF real(z) * imag(@start) + real(@start) * imag(z) >= 0
z = fn1(z - 1) * @start
ELSE
z = fn2(z + 1) * @start
ENDIF

IF real(z) >= 0
z = fn3(z - 1) * @start
ELSE
z = fn4(z + 1) * @start
ENDIF

ELSEIF (@mode == 5)

IF real(z) >= 0
z = fn3(z - 1) * @start
ELSE
z = fn4(z + 1) * @start
ENDIF

ELSEIF (@mode == 6)

IF real(z) >= 0
z = fn3(z - 1) * @start
ELSE
z = fn4(z + 1) * @start
ENDIF

WHILE i < @niter
i = i + 1

IF (@metric == 0) ; Sam
IF abs((real(z)/xRatio)^@xFact) < @xFact && abs((imag(z)/yRatio)^@yFact) < @yFact
nz = z
ENDIF

ELSEIF (@metric == 1) ; Others
IF (abs((real(z)/xRatio)^@xFact) + abs((imag(z)/yRatio)^@yFact) < 1)
nz = z
ENDIF
ENDIF

ztest = real(z)*sqrt(r)+1i*imag(z)/sqrt(r)
arg = atan2(ztest)
arg = -round(arg/(2*pi)*@order)/@order*(2*pi)
ztest = ztest*exp(1i*arg)

IF real(ztest) < 1
nz = z
ELSEIF j == 0
j = i
ELSE
i = @niter
ENDIF

z = z*exp(1i*pi/180*@alpha)*magn

ENDWHILE

z = (nz-@center)*exp(1i*pi/180*@rot)/@mag

IF @fun == 0
z = 1i*(nz-@center)*exp(1i*pi/180*@rot)/@mag

ELSEIF @fun == 1
Z = 1i*(nz+@center)^@f7(1i*pi/180*@rot)/@mag

ENDIF

ENDIF

bailout:
((@test == 0 && |z| <= @bailout) ||                         \
(@test == 1 && @goofFunc(real(z)) <= @bailout) ||                                \
(@test == 2 && @goofFunc(imag(z)) <= @bailout) ||                                \
(@test == 3 && (@goofFunc(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (@goofFunc(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (@goofFunc(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (@goofFunc(real(z) + imag(z)) <= @bailout)) ||                    \
(@test == 7 && (abs(sqr(real(z))/imag(z)) <= @bailout)) ||                 \
(@test == 8 && (abs(sqr(imag(z))/real(z)) <= @bailout)) ||                 \
(@test == 9 && (@bailFunc(z)*@bailExponent) <= @bailout)) ||                 \
(@test == 10 && (@bailFunc(z)^@bailExponent) <= @bailout) ||                 \
(@test == 11 &&  (|z + pixel| < @bailout))

default:

title = "KPK Zeppbarn"
center = (0.0, 0.0)
magn = 1.5
method = multipass
maxiter = 500

param bailout
caption = "Bailout"
default = 1.0
endparam

param bailExponent
caption = "Bailout Exponent"
default = 3.0
endparam

param mode
caption = "Variation"
enum = "Z1" "Z2" "PP" "BB" "S1" "S2" "SQP"
default = 0
endparam

param invert
caption = "Invert z"
default = false
endparam

param start
caption = "Barnsley Set"
default = (0.8, 0.8)
endparam

param p2
default = (0.8, 0.8)
caption = "BB Parameter"
hint = "Use only with Variation BB"
endparam

param order
caption = "Order"
default = 4
endparam

param fun
caption = "Mapping Mode"
default = 0
enum = "Normal Mapping" "Fun"
endparam

param rw
caption = "Width Ratio"
default = 1.0
endparam

param rh
caption = "Heigh Ratio"
default = 1.0
endparam

param alpha
caption = "Angle Step"
default = 30.0
endparam

param center
caption = "Mapping Center"
default = (0,0)
endparam

param rot
caption = "Mapping Rotation"
default = 45.0
endparam

param rot1
caption = "General Rotation"
default = 0.0
endparam

param mag
caption = "General Thickness"
default = 1.0
endparam

param niter
caption = "Iteration Number"
default = 111
endparam

param metric
caption = "Metrics/Shapes"
enum    = "Geometric Mix I" "Geometric Mix II"
default = 0
endparam

param xRatio
caption = "X Ratio"
default = 1.0
min     = 0.001
endparam

param yRatio
caption = "Y Ratio"
default = 1.0
min     = 0.001
endparam

param xFact
caption = "X Thickness"
default = 1.0
endparam

param yFact
caption = "Y Thickness"
default = 1.0
endparam

param mtw
caption = "Magnif. Tweak"
default = 1.0
endparam

param factor
caption = "Transform Factor"
default = 2.0
endparam

param corte
caption = "Cutting edges"
default = 0.5
endparam

param test
caption = "Shape Modifier"
enum = "mod" "real" "imag" "or" "and" "manh" \
"manr" "abs(x*x/y)" "abs(y*y/x)" "iter" \
"10" "11"
default = 5
endparam

param angle
caption = "Angle"
default = 0.0
endparam

param rot1
caption = "Rotation"
default = 45.0
endparam

param power
caption = "Power"
default = (2,0)
endparam

param sizesq
caption = "Magnification"
default = 3
endparam

param spokes
caption = "Spiral Multiplier"
default = 0.0
hint = "Decimal values possible!"
endparam

func fn1
caption = "Function 1"
default = ident()
endfunc

func fn2
caption = "Function 2"
default = flip()
endfunc

func fn3
caption = "Function 3"
default = ident()
endfunc

func fn4
caption = "Function 4"
default = ident()
endfunc

func f5
caption = "Function 5"
default = ident()
endfunc

func f6
caption = "Function 6"
default = ident()
endfunc

func f7
caption = "Fun Func"
default = exp()
endfunc

func bailFunc
caption = "Bailout Fct."
default = ident()
endfunc

func goofFunc
caption = "Goofy Fct."
default = sqr()
endfunc
}

kpkwiggbarn {
; Written by KPK February 2001
;
; After the Barnsley code by Luke Plant
;
; With parts of Samuel Monnier's
; Octogonal Slices formula, Squared
; Spiral and Polygon Spiral transform and
; Edward Perry's Wiggle code
;
; Modified Squared Spiral transform code
;
; Additional bailout ideas by Andreas Lober
; and David Makin
Init:

float ratioSum = (@xRatio + @yRatio)/2
float xRatio = @xRatio/ratioSum
float yRatio = @yRatio/ratioSum

z = #pixel
nz = 0
int i = 0
int j = 0

zc = fn4(z/@sizesq)*@sizesq
z = 2*(z - (0.25*zc))/(0.5*@power)

float arg = 0
float angle = @angle*pi/180
float magn = (sin(pi-pi*(@order-2)/@order-pi/180*@alpha)+sin(pi/180*@alpha))/sin(pi*(@order-2)/@order)*@mtw
float r = @rw/@rh
float arg = 0

arg = atan2(z)

IF arg > pi/2
z = -1i*z
ELSEIF arg > -pi/2 && arg < 0
z = 1i*z
ELSEIF arg < -pi/2
z = -z
ENDIF

arg = atan2(z)

IF arg > pi/2 - angle
z = z*exp(-1i*pi/2)

ELSEIF arg < pi/2 - angle && arg > angle
z = z*fn1(-1i*pi/4)
z = z*cos(angle)/cos(pi/4-angle)

ENDIF

int     i   = 0

float   x   = 0.0
float   y   = 0.0

int     mod = trunc(real(@modu));
int     rem = trunc(imag(@modu));

IF (rem >= mod)
rem = 0
ENDIF

z = z*exp(1i*pi/180*@rot1)*(pixel^@spokes)

loop:

IF @invert
z = 1/z
ENDIF

IF (@wigg == true)

IF (i % mod == rem)

z = (z * @mult) + @offs
z = @pfun(z)

IF (@pola == 1 || @pola == 3)
z = ((0, 0) + cabs(z)) + (flip((0, 0) + atan2(z)))
ENDIF

IF     (@appl == 0)
z = @afun(z)
z = @bfun(z)
ELSEIF(@appl == 1)
z = @afun((0, 0) + real(z)) + @fn2(@bfun((0, 0) + imag(z)))
ENDIF

IF (@pola == 2 || @pola == 3)
x = real(z), y = imag(z)
z = ((0,0) + (x * cos(y))) + flip((0,0) + (x * sin(y)))
ENDIF

IF real(z) >= 0
z = @fn3(z - 1) * @start
ELSE
z = @fn4(z + 1) * @start
ENDIF
ENDIF
ENDIF

IF (@mode == 0)

p = @start
z = 1-fn1(imag(z)*p-real(z))+fn2(1-abs(1-real(z)-imag(z)))

IF real(z) >= 0
z = fn3(z - 1) * @start
ELSE
z = fn4(z + 1) * @start
ENDIF

ELSEIF (@mode == 1)

p = @start
z = 1-fn1(imag(z)*p-real(z))+fn2(1-@f5(1-real(z)-imag(z)))

IF (imag(z)>@corte)
z = @factor*real(z) + flip(@factor*imag(z)-1)
ELSEIF real(z) >= 0
z = fn1(z - 1) * @start
ELSEIF (real(z)>@corte)
z = @factor*real(z)-1 + flip(@factor*imag(z))
ELSEIF real(z) >= 0
z = fn4(z + 1) * @start
ELSE
z = @factor*real(z) + flip(@factor*imag(z))
z = fn2(z)
ENDIF

ELSEIF (@mode == 2)

IF (imag(z)>@corte)
z = @factor*real(z) + flip(@factor*imag(z)-1)
ELSEIF real(z) >= 0
z = fn1(z - 1) * @start
ELSEIF (real(z)>@corte)
z = @factor*real(z)-1 + flip(@factor*imag(z))
ELSEIF real(z) >= 0
z = fn4(z + 1) * @start
ELSE
z = @factor*real(z) + flip(@factor*imag(z))
z = fn2(z)
ENDIF

ELSEIF (@mode == 3)

IF real(z) * imag(@start) + real(@start) * imag(z) >= 0
z = fn1(z - 1) * @start
ELSE
z = fn2(z + 1) * p2
ENDIF

IF real(z) >= 0
z = fn3(z - 1) * p2
ELSE
z = fn4(z + 1) * @start
ENDIF

IF real(z) >= 0
z = fn3(z - 1) * p2
ELSE
z = fn4(z + 1) * @start
ENDIF

IF real(z) * imag(@start) + real(@start) * imag(z) >= 0
z = @f5(z - 1) * @start
ELSE
z = @f6(z + 1) * p2
ENDIF

ELSEIF (@mode == 4)

IF (imag(z)>0.5)
z = 2*real(z) + fn2(2*imag(z)-1)
ELSEIF (real(z)>0.5)
z = 2*real(z)-1 + fn2(2*imag(z))
ELSE
z = 2*real(z) + fn3(2*imag(z))
ENDIF

IF real(z) * imag(@start) + real(@start) * imag(z) >= 0
z = fn1(z - 1) * @start
ELSE
z = fn2(z + 1) * @start
ENDIF

IF real(z) >= 0
z = fn3(z - 1) * @start
ELSE
z = fn4(z + 1) * @start
ENDIF

ELSEIF (@mode == 5)

IF real(z) >= 0
z = fn3(z - 1) * @start
ELSE
z = fn4(z + 1) * @start
ENDIF

ELSEIF (@mode == 6)

IF real(z) >= 0
z = fn3(z - 1) * @start
ELSE
z = fn4(z + 1) * @start
ENDIF

WHILE i < @niter
i = i + 1

IF (@metric == 0) ; Sam
IF abs((real(z)/xRatio)^@xFact) < @xFact && abs((imag(z)/yRatio)^@yFact) < @yFact
nz = z
ENDIF

ELSEIF(@metric == 1) ; Others
IF (abs((real(z)/xRatio)^@xFact) + abs((imag(z)/yRatio)^@yFact) < 1)
nz = z
ENDIF
ENDIF

z = z*exp(1i*pi/180*@alpha)*magn/@magnStep

ENDWHILE

z = (nz-@center)*exp(1i*pi/180*@rot)/@mag

IF @fun == 0
z = 1i*(nz-@center)*exp(1i*pi/180*@rot)/@mag

ELSEIF @fun == 1
Z = 1i*(nz+@center)^@f7(1i*pi/180*@rot)/@mag

ENDIF

ELSEIF (@mode == 7)

IF real(z) >= 0
z = fn3(z - 1) * @start
ELSE
z = fn4(z + 1) * @start
ENDIF

WHILE i < @niter
i = i + 1

IF (@metric == 0) ; Sam
IF abs((real(z)/xRatio)^@xFact) < @xFact && abs((imag(z)/yRatio)^@yFact) < @yFact
nz = z
ENDIF

ELSEIF(@metric == 1) ; Others
IF (abs((real(z)/xRatio)^@xFact) + abs((imag(z)/yRatio)^@yFact) < 1)
nz = z
ENDIF
ENDIF

ztest = real(z)*sqrt(r)+1i*imag(z)/sqrt(r)
arg = atan2(ztest)
arg = -round(arg/(2*pi)*@order)/@order*(2*pi)
ztest = ztest*exp(1i*arg)

IF real(ztest) < 1
nz = z
ELSEIF j == 0
j = i
ELSE
i = @niter
ENDIF

z = z*exp(1i*pi/180*@alpha)*magn

ENDWHILE

z = (nz-@center)*exp(1i*pi/180*@rot)/@mag

IF @fun == 0
z = 1i*(nz-@center)*exp(1i*pi/180*@rot)/@mag

ELSEIF @fun == 1
Z = 1i*(nz+@center)^@f7(1i*pi/180*@rot)/@mag

ENDIF

ENDIF

bailout:
((@test == 0 && |z| <= @bailout) ||                         \
(@test == 1 && @goofFunc(real(z)) <= @bailout) ||                                \
(@test == 2 && @goofFunc(imag(z)) <= @bailout) ||                                \
(@test == 3 && (@goofFunc(real(z)) <= @bailout && sqr(imag(z)) < @bailout)) ||   \
(@test == 4 && (@goofFunc(real(z)) <= @bailout || sqr(imag(z)) < @bailout)) ||   \
(@test == 5 && (@goofFunc(abs(real(z)) + abs(imag(z))) <= @bailout)) ||          \
(@test == 6 && (@goofFunc(real(z) + imag(z)) <= @bailout)) ||                    \
(@test == 7 && (abs(sqr(real(z))/imag(z)) <= @bailout)) ||                 \
(@test == 8 && (abs(sqr(imag(z))/real(z)) <= @bailout)) ||                 \
(@test == 9 && (@bailFunc(z)*@bailExponent) <= @bailout)) ||                 \
(@test == 10 && (@bailFunc(z)^@bailExponent) <= @bailout) ||                 \
(@test == 11 &&  (|z + pixel| < @bailout))

default:

title = "KPK Wiggbarn"
center = (0.0, 0.0)
magn = 1.5
method = multipass
maxiter = 500

param bailout
caption = "Bailout"
default = 1.5
endparam

param bailExponent
caption = "Bailout Exponent"
default = 3.0
endparam

param mode
caption = "Variation"
enum = "Z1" "Z2" "PP" "BB" "S1" "S2" "SQ" "SQP"
default = 0
endparam

param wigg
caption = "Wiggley"
default = true
endparam

param order
caption = "Order"
default = 4
hint = "Use only with Variation SQP"
endparam

param fun
caption = "Mapping Mode"
default = 0
enum = "Normal Mapping" "Fun"
endparam

param rw
caption = "Width Ratio"
default = 1.0
hint = "Use only with Variation SQP"
endparam

param rh
caption = "Heigh Ratio"
default = 1.0
hint = "Use only with Variation SQP"
endparam

param alpha
caption = "SQ Angle Step"
default = 30.0
hint = "Use only with Variation SQ"
endparam

param center
caption = "SQ Map. Center"
default = (0,0)
hint = "Use only with Variation SQ"
endparam

param rot
caption = "SQ Map. Rotation"
default = 45.0
hint = "Use only with Variation SQ"
endparam

param mag
caption = "SQ Gener. Thickn."
default = 1.0
hint = "Use only with Variation SQ/SQP"
endparam

param niter
caption = "SQ Iter Number"
default = 20
hint = "Use only with Variation SQ/SQP"
endparam

param metric
caption = "Metrics/Shapes"
enum    = "Geometric Mix I" "Geometric Mix II"
default = 0
hint = "Use only with Variation SQ/SQP"
endparam

param xRatio
caption = "SQ X Ratio"
default = 1.0
min     = 0.001
hint = "Use only with Variation SQ/SQP"
endparam

param yRatio
caption = "SQ Y Ratio"
default = 1.0
min     = 0.001
hint = "Use only with Variation SQ/SQP"
endparam

param xFact
caption = "SQ X Thickness"
default = 1.0
hint = "Use only with Variation SQ/SQP"
endparam

param yFact
caption = "SQ Y Thickness"
default = 1.0
hint = "Use only with Variation SQ/SQP"
endparam

param magnStep
caption = "SQ Mag. Step"
default = 1.0
hint = "Use only with Variation SQ"
endparam

param mtw
caption = "Magnif. Tweak"
default = 1.0
endparam

param invert
caption = "Invert z"
default = false
endparam

param start
caption = "Barnsley Set"
default = (0.8, 0.8)
endparam

param p2
default = (0.8, 0.8)
caption = "BB Parameter"
hint = "Use only with Variation BB"
endparam

param factor
caption = "Transform Factor"
default = 2.0
endparam

param corte
caption = "Cutting edges"
default = 0.5
endparam

param test
caption = "Shape Modifier"
enum = "mod" "real" "imag" "or" "and" "manh" \
"manr" "abs(x*x/y)" "abs(y*y/x)" "iter" \
"10" "11"
default = 5
endparam

param angle
caption = "Angle"
default = 45.0
endparam

param rot1
caption = "General Rotation"
default = 45.0
endparam

param spokes
caption = "Spiral Multiplier"
default = 0.0
hint = "Decimal values possible!"
endparam

param power
caption = "Power"
default = (2,0)
endparam

param sizesq
caption = "Magnification"
default = 3
endparam

param modu
caption = "Modulus"
default = (1, 1)
endparam

param pola
caption = "Polarization"
enum    = "None" "In" "Out" "Both"
default = 0
endparam

param appl
caption = "Application"
enum = "Joined" "Split"
default = 0
endparam

param mult
caption = "Multiplier"
default = (0.0, 1.0)
endparam

param offs
caption = "Offset"
default = (1.0, 0.0)
endparam

func pfun
caption = "Preparation"
default = ident()
endfunc

func afun
caption = "A Function"
default = ident()
endfunc

func bfun
caption = "B Function"
default = ident()
endfunc

func fn1
caption = "Function 1"
default = ident()
endfunc

func fn2
caption = "Function 2"
default = flip()
endfunc

func fn3
caption = "Function 3"
default = ident()
endfunc

func fn4
caption = "Function 4"
default = ident()
endfunc

func f5
caption = "Function 5"
default = ident()
endfunc

func f6
caption = "Function 6"
default = ident()
endfunc

func f7
caption = "Fun Func"
default = exp()
endfunc

func bailFunc
caption = "Bailout Fct."
default = ident()
endfunc

func goofFunc
caption = "Goofy Fct."
default = sqr()
endfunc
}```