[BACK] [FORWARD] [Tutorial] [Table of Contents]


fractal


This procedure takes two arguments: a Rivl image (image) and n which determines the number of times to apply the following sequence of operations to the image:

  1. Shrink the image to half size.
  2. Create three duplicates of the image. Move them "north", "southwest", and "southeast" respectively.
  3. Merge the three duplicates into a single image.


rvl_proc fractal {image n} {
        set dx [expr 0.25 * [im_width $image]]
        set dy [expr 0.25 * [im_height $image]]
        for {set i 0} {$i < $n} {incr i} {
                # 1. Shrink to half size.
                im_scaleC! image 0.5

                # 2. Create and move three duplicates.
                set north [im_trans $image 0 -$dy]
                set sw  [im_trans $image -$dx $dy]
                set se  [im_trans $image $dx $dy]

                # 3. Merge the three duplicates.
                set image [im_overlay $north $sw $se]
        }
        return $image
}


Output from fractal for p = 0.0, 0.1, 0.4, 0.7


[Top]