Sierpinski triangle/Graphical

From Rosetta Code
Revision as of 01:30, 6 May 2011 by rosettacode>Dgamey (→‎Icon and Unicon)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Sierpinski triangle/Graphical is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.

Produce an ASCII representation of a Sierpinski triangle of order N in any orientation. For example, the Sierpinski triangle of order 4 should look like this:

Icon and Unicon

The following code is from program by Ralph E. Griswold that demonstrates an interesting way to draw the Sierpinski Triangle. For an explanation, see "Chaos and Fractals", Heinz-Otto Peitgen, Harmut Jurgens, and Dietmar Saupe, Springer-Verlah, 1992, pp. 132-134. <lang Icon>link wopen

procedure main()

  local width, offset, x, y
  WOpen("label=sierpinski", "size=300,300") |
     stop("*** cannot open window")
  width := 256
  offset := 30
  every y := 0 to width - 1 do
     every x := 0 to width - 1 do
        if iand(x, y) = 0 then DrawPoint(x + offset, y + offset)
 Event()

end</lang>

[Graphics/sier1.icn]