# Lindstrom's snowflake

```\$hexagons = []; \$num_flakes = 7; \$num_hexagons_per_flake = 7; \$hexagon_side = 20; \$hexagon_half_side = \$hexagon_side / 2; \$d = 2 * \$hexagon_side; list(\$svg_width, \$svg_height) = [500, 500]; list(\$center_x, \$center_y) = [\$svg_width / 2, \$svg_height / 2]; \$apothem = \$hexagon_side * sqrt(3) / 2; \$p1x = round(\$center_x - \$hexagon_half_side); \$p1y = round(\$center_y - \$apothem); \$p2x = round(\$center_x + \$hexagon_half_side); \$p2y = round(\$center_y - \$apothem); \$p3x = round(\$center_x + \$hexagon_side); \$p3y = round(\$center_y); \$p4x = round(\$center_x + \$hexagon_half_side); \$p4y = round(\$center_y + \$apothem); \$p5x = round(\$center_x - \$hexagon_half_side); \$p5y = round(\$center_y + \$apothem); \$p6x = round(\$center_x - \$hexagon_side); \$p6y = round(\$center_y); \$angle = 0; for(\$i = 0; \$i < \$num_flakes; \$i++) { \$rad = deg2rad(\$angle); \$not_first_i = \$i != 0; \$tx = \$not_first_i ? round(\$d*cos(\$rad)) : 0; \$ty = \$not_first_i ? round(\$d*sin(\$rad)) : 0; \$angle1 = 0; for(\$j = 0; \$j < \$num_hexagons_per_flake; \$j++) { \$rad1 = deg2rad(\$angle1); \$not_first_j = \$j != 0; \$tx1 = (\$not_first_j ? round(\$d*cos(\$rad1)) : 0) + 3*\$tx; \$ty1 = (\$not_first_j ? round(\$d*sin(\$rad1)) : 0) + 3*\$ty; \$hexagons[] = "<polygon points='\$p1x,\$p1y \$p2x,\$p2y \$p3x,\$p3y \$p4x,\$p4y \$p5x,\$p5y \$p6x,\$p6y' fill='black' transform='translate({\$tx1} {\$ty1})' />"; if(\$not_first_j) {\$angle1 += 60;} } if(\$not_first_i) {\$angle += 60;} } \$hexagons = implode('', \$hexagons);```