-
-
-
-
-
-
-
-
-
-
draw[array_, options___] := Module[ {interval, topinterval, width, height, f, coords}, {height, width} = Dimensions[array]; interval = 2. Pi/width; topinterval = 2. Pi (1 + interval)/width; coords = Position[array, 1]; f[{x_, r_}] := Rotate[Translate[ Cuboid[-#, #] &[.5 topinterval {1, 1, 1}], {1, 0, -interval x}], interval r, {0, 0, 1}(*;{1,0,0}*), {0, 0, 0}]; Graphics3D[{{Lighter[LightBlue], Opacity[.5], Sphere[{0, 0, -interval height/2}, .5]}, EdgeForm[None], White, f /@ coords}, options, Boxed -> False]]; draw[CellularAutomaton[22, ConstantArray[0, 500]~ReplacePart~{1 -> 1, 251 -> 1}, 125], Lighting -> "Neutral"]
-
draw2[im_Image, options___] := draw2[ImageData[ColorConvert[im, "RGB"]], options]; draw2[array_, options___] := Module[ {interval, width, height, f, cubes, coords}, {height, width} = Dimensions[array][[{1, 2}]]; interval = 2. Pi/width; coords = Position[array, p_ /; p != {0, 0, 0}, {2}]; f[{x_, r_}] := Rotate[Translate[ Cuboid[-#, #] &[.5 interval {1, 1, 1}], {1, 0, -interval x}], interval r, {0, 0, 1}, {0, 0, 0}]; cubes = MapThread[{RGBColor @@ #1, f[#2]} &, {array[[##]] & @@@ coords, coords}]; Graphics3D[{{Lighter[LightBlue], Opacity[.5], Sphere[{0, 0, -interval height/2}, .5]}, EdgeForm[None], cubes}, options, Boxed -> False]]; (*this rule from "http://web.cecs.pdx.edu/~mm/evca-review.pdf"*) rules = Thread[Tuples[{0, 1}, {7}] -> IntegerDigits[FromDigits["0504058705000f77037755837bffb77f", 16], 2, 128]]; arr = FixedPointList[CellularAutomaton[rules], RandomInteger[1, 600]]; arrEdge = ArrayPlot[arr, PixelConstrained -> 1, Frame -> False] // EdgeDetect // ImageData; (*ad hoc coloring, originally intended for particle animation*) pat1 = {{_, _, _, _, _}, {_, 1, 0, 0, 1}, {_, _, _, _, _}}; pat2 = {{_, 1, _, _, _}, {_, _, 1, _, _}, {_, _, _, 1, _}}; pat3 = {{_, _, _, _, _}, {_, 1, 1, 1, _}, {_, _, _, _, _}}; (f[#1 | Reverse /@ #1, _] = #2) & @@@ {_ -> {0, 0, 0}, pat1 -> {1, 0, 0}, pat2 -> {0, 1, 0}, pat3 -> {0, 0, 1}}; (*see also ImageFilter, ImageConvolve, a million other things*) colored = CellularAutomaton[{f, {}, {1, 2}}, arrEdge]; Image[colored] draw2[colored, Lighting -> "Neutral"]
This page is an excerpt from the sierpinski triangle page to end most sierpinski triangle pages .