18 lines
822 B
Plaintext
18 lines
822 B
Plaintext
n = 7;
|
|
colors = Blend[{Orange, Yellow, Green}, #] & /@ Subdivide[n - 1];
|
|
ClearAll[NextConfigs, NewConfig]
|
|
NewConfig[b1_List, b2_List] := Module[{diff, perp},
|
|
diff = b2 - b1;
|
|
perp = Cross[b2 - b1];
|
|
<|"quad" -> Polygon[{b1, b2, b2 + perp, b1 + perp}], "triang" -> Polygon[{b1 + 1.5 perp + diff/2, b1 + perp, b2 + perp}]|>
|
|
]
|
|
NextConfigs[config_Association] := Module[{tr},
|
|
tr = config["triangs"][[All, 1]];
|
|
tr = Join[NewConfig @@@ tr[[All, {2, 1}]], NewConfig @@@ tr[[All, {1, 3}]]];
|
|
<|"quads" -> tr[[All, "quad"]], "triangs" -> tr[[All, "triang"]]|>
|
|
]
|
|
nc = NewConfig[{-0.5, 0.0}, {0.5, 0.0}];
|
|
config = <|"quads" -> {nc["quad"]}, "triangs" -> {nc["triang"]}|>;
|
|
config = NestList[NextConfigs, config, n - 1];
|
|
Graphics[MapThread[{EdgeForm[Black], FaceForm[#2], #1["quads"], #1["triangs"]} &, {config, colors}]]
|