Posted to tcl by avl at Sun Mar 19 12:31:47 GMT 2017view pretty
grid [canvas .c -w 256 -he 256]
.c create rect 0 0 200 200
set p [image create photo -width 256 -height 256]
set h [expr 255**3]
for {set x 0} {$x<256} {incr x} {
for {set y 0} {$y<256} {incr y} {
set a [expr {$x*4/255.0-2}]
set b [expr {$y*4/255.0-2}]
set c $a
set d $b
set n 0
while {$n<200} {
set a [expr {$a*$a-$b*$b+$c}]
set b [expr {2*$a*$b+$d}]
if {$a*$a+$b*$b>4} {break}
incr n
}
#.c create rect $x $y $x $y -fill [format #%06x [expr $n*$h/100]]
#puts "$x $y $a $b $n [format #%06x [expr $n*$h/100]]"
$p put [format #%06x [expr {$n*$h/200}]] -to $x $y
}
}
.c create image 128 128 -image $p