UF着色代码
StalkTraps {
; Paul W. Carlson
; Variant #1 extracted from "R4MndStksM2".
; Variant #2 extracted from "Spir2_Trunc".
; Variant #3 extracted from "Dbl_Expos_Newt1".
; By Ken Childress June 1999.
init:
bool trapped = FALSE
int iter = 0
float range_num = 0
float num_ranges = real(@RangesColors)
float colors_in_range = imag(@RangesColors)
float index_factor = (colors_in_range - 1) / @size
float color_index = 254
; Initialization for Variant #2
bool first = TRUE
; Initialization for Variant #3
float dist = 0
complex c = #pixel
complex sc = sqrt(-(1 / c^2))
loop:
IF
@Variant == 0
float zr = real(#z)
float zi = imag(#z)
float dist = abs((zr - 0.5)^2 + (zi - 0.5)^2 - 0.1)
IF !trapped && (dist < @size) && (iter > @skip)
trapped = TRUE
range_num = iter % num_ranges
color_index = index_factor * dist + range_num * colors_in_range
ENDIF
ELSEIF @Variant == 1
float zr = abs(real(#z))
float zi = abs(imag(#z))
IF (zr <= zi)
float dist = zr
ELSE
dist = zi
ENDIF
IF !trapped && (dist < @size) && |#z| <
@MaxZ && !first
trapped = TRUE
range_num = iter % num_ranges
color_index = index_factor * dist + range_num * colors_in_range
ENDIF
first = FALSE
ELSEIF @Variant == 2
IF !trapped && iter >= @skip
; Get minimum distance to an axis
IF (abs(real(#z)) <= abs(imag(#z)))
float min_dist = abs(real(#z))
ELSE
min_dist = abs(imag(#z))
ENDIF
;Check for stalk
IF (dist == 0 && min_dist < @size)
dist = min_dist
ENDIF
;Bailout depends on convergence to a root
IF (|#z + c| < @convergence)
trapped = TRUE
ELSEIF (|#z - c| < @convergence)
trapped = TRUE
ELSEIF (|#z + sc| < @convergence)
trapped = TRUE
ELSEIF (|#z - sc| < @convergence)
trapped = TRUE
ENDIF
IF trapped
range_num = iter % num_ranges
color_index = index_factor * dist + range_num * colors_in_range
ENDIF
ENDIF
ENDIF
iter = iter + 1
final:
IF trapped
#index = ((real(color_index)+1) % 256) / 256 +
@randomness * real(#random)
ELSE
IF @solid
#solid = TRUE
ELSE
#index = @back_color / 256
ENDIF
ENDIF
default:
title="Stalk Traps"
param Variant
caption = "Stalk Variant"
enum = "Variant #1" "Variant #2" "Variant #3"
default = 0
hint = "The Stalk Trap variant to use."
endparam
param size
caption = "Stalk Width Factor"
default = 2.0
hint = "Controls stalk width."
endparam
param skip
caption = "Iterations to skip"
default = 0
hint = "Iterations to skip. \
This is not used by Variant #2."
endparam
param MaxZ
caption = "Maximum Z"
default = 4.0
hint = "Maximum value of abs(z). \
This is used by only Variant #2."
endparam
param convergence
caption = "Convergence Value"
default = 1.0e-7
hint = "The value to check for convergence. \
This is not used by Variant #1 or Variant #2."
endparam
param RangesColors
caption = "Ranges and Colors"
default = (2,125)
hint = "Number of Color Ranges and Number of Colors in each Range."
endparam
param back_color
caption = "Background Color"
hint = "This is the color used for orbits that aren't trapped. It has \
no effect if the background is solid."
default = 254
min = 0
max = 255
endparam
param solid
caption = "Solid Background"
hint = "If this is enabled orbits that aren't trapped become solid."
default = false
endparam
param randomness
caption = "Random Texture"
default = 0.0
hint = "This adds a random texture to the coloring."
endparam
}