home

Sierpinski Triangle

A Sierpiński triangle is a fractal with the overall shape of an equilateral triangle, subdivided recursively into smaller equilateral triangles. The diagram shows a fifth-order Sierpiński triangle, which was experimentally realized out of Fe/C₃PC molecules on a reconstructed Au(100)-(hex) in 10.1021/jacs.7b05720.

The visualization shows a yellow Sierpiński triangle (representing Fe/C₃PC molecules) with a gold border (representing BPyB molecules) on a background of red dots arranged in a hexagonal close-packed pattern (representing the Au(100) substrate atoms). Previous molecular Sierpiński triangle fractals were limited to fourth-order due to kinetic growth constraints.


Sierpinski Triangle

Download

PNG PDF

Code

sierpinski-triangle.typ (109 lines)

#import "@preview/fractusist:0.3.0": lsystem, lsystem-use

#set page(width: auto, height: auto, margin: 0pt, fill: none)
#set text(fill: white, size: 12pt)

// Sierpiński triangle with Au(100) surface background
#box({
  let triangle-size = 128pt
  let margin = 20pt
  let canvas-width = triangle-size + 2 * margin
  let canvas-height = triangle-size * calc.pow(3, 0.5) / 2 + 2 * margin + 50pt

  rect(
    width: canvas-width,
    height: canvas-height,
    fill: rgb(50, 50, 50),
    {
      // Gold atoms in hexagonal close-packed arrangement
      let horizontal-spacing = 2.5pt
      let vertical-spacing = 2.2pt
      let dot-radius = 1pt
      let rows = int(canvas-height / vertical-spacing)
      let cols = int(canvas-width / horizontal-spacing)

      for y in range(-3, rows + 3) {
        let offset = if calc.odd(y) { horizontal-spacing / 2 } else { 0pt }

        for x in range(-3, cols + 3) {
          place(
            dx: x * horizontal-spacing + offset,
            dy: y * vertical-spacing,
            circle(
              radius: dot-radius,
              fill: rgb(200, 50, 50),
              stroke: none,
            ),
          )
        }
      }

      // Sierpiński triangle
      place(
        dx: margin / 2,
        dy: margin / 2 + 50pt,
        {
          lsystem(
            ..lsystem-use("Sierpinski Triangle"),
            order: 5,
            step-size: 4,
            start-angle: 1,
            fill: rgb(255, 230, 100),
            stroke: 0.5pt + rgb(200, 140, 0),
          )
        },
      )

      // 10nm scale bar
      let scale-bar-width = horizontal-spacing * 8
      let (scale-bar-height, scale-bar-margin) = (2pt, 20pt)

      place(
        dx: canvas-width - scale-bar-width - scale-bar-margin,
        dy: scale-bar-margin / 5,
        rect(width: scale-bar-width, height: scale-bar-height, fill: white),
      )

      place(
        dx: canvas-width - scale-bar-width - scale-bar-margin + scale-bar-width / 2 - 14pt,
        dy: scale-bar-margin / 5 + scale-bar-height + 2pt,
        [10 nm],
      )

      // Legend
      let color-square-size = 8pt
      let legend-items = (
        (rgb(200, 50, 50), [Au(100)]),
        (rgb(255, 230, 100), [Fe/C3PC]),
        (rgb(200, 140, 0), [BPyB]),
      )

      place(
        block(
          inset: (x: 3pt, y: 2pt),
          radius: 2pt,
          fill: rgb(30, 30, 30),
          {
            grid(
              columns: (color-square-size, auto),
              column-gutter: 2.5pt,
              row-gutter: 3pt,
              ..legend-items
                .map(((fill, label)) => (
                  rect(
                    width: color-square-size,
                    height: color-square-size,
                    fill: fill,
                    radius: 1pt,
                  ),
                  label,
                ))
                .flatten(),
            )
          },
        ),
      )
    },
  )
})