Graphic patterns, visual backgrounds, handcrafted icons, and generative decorations

A CSS-like language

<css-doodle>

  @grid: 16x9 / 100% auto _1px;
  transition: @r(1s) ease;
  background:@p(
    #ff8830, #d1b8a0, #aeced2, #cbdcdf
  );
  clip-path: polygon(@p(
    '0 0, 100% 0, 100% 100%',
    '0 0, 100% 0, 0 100%',
    '0 0, 100% 100%, 0 100%',
    '100% 0, 100% 100%, 0 100%'
  ));

</css-doodle>
@grid: 16x9 / 100% auto _1px; background:@p( #ff8830, #d1b8a0, #aeced2, #cbdcdf ); clip-path: polygon(@p( '0 0, 100% 0, 100% 100%', '0 0, 100% 0, 0 100%', '0 0, 100% 100%, 0 100%', '100% 0, 100% 100%, 0 100%' )); transition: @r(1s) ease;

Browse examples

Write SVG with the same CSS-like syntax.

Nested, readable, no XML

<css-doodle>

  @grid: 16x9 / 100% auto;
  background: @svg(
    viewBox: -3 -3 6 6;
    fill: none;
    stroke-width: .25;
    stroke: #e91e63;
    g {
      transform: rotate($(90 * @p.m4.n));
      circle*4 {
        cx, cy: @pn.cycle(3 -3);
        r: @pn(2, 4, 4, 2)
      }
    }
  )

</css-doodle>
@grid: 16x9 / 100% auto; background: @svg( viewBox: -3 -3 6 6; fill: none; stroke-width: .25; stroke: #e91e63; g { transform: rotate($(90 * @p.m4.n)); circle*4 { cx, cy: @pn.cycle(3 -3); r: @pn(2, 4, 4, 2); } } );

SVG playground Learn more

A tiny DSL that compiles to a shader.

No GLSL, runs on the GPU

<css-doodle>

  @grid: 1 / 100% auto (16/9);
  @content: @pattern(
    grid: 48x27;
    shape: circle;
    size: sin(3*log(dr) - 2t - da);
    fill: hsl(sin(dr/100 + 2t/100) .75 .65)
  );

</css-doodle>
@grid: 1 / 100% auto (16/9); @content: @pattern( grid: 48x27; shape: circle; size: sin(3*log(dr) - 2t - da); fill: hsl(sin(dr/100 + 2t/100) .75 .65); );

Learn more

A shape generator from equations.

clip-path: @shape()

<css-doodle>

  @grid: 1 / 100% auto (16/9) ß1px ;
  background: #07121f;
  clip-path: @shape(
    points: 2000;
    scale: .061 .06;
    -x: 1.81(11cos(.6t) + cos(55t) - 2.8);
    -y: 2.5(11sin(9.03t) - sin(77t)) + 17;
  );

</css-doodle>
@grid: 1 / 100% auto (16/9) border; background: #07121f; clip-path: @shape( points: 2000; scale: .061 .06; -x: 1.81(11cos(.6t) + cos(55t) - 2.8); -y: 2.5(11sin(9.03t) - sin(77t)) + 17; );

Shape playground Learn more

Render from the terminal.

cssd render

# generate image from css-doodle code
$ cssd render code.css

# make image larger
$ cssd render code.css -x 10

# generate image from codepen
$ cssd render codepen.io/yuanchuan/pen/MQEeJo

# custom selectors
$ cssd render index.html -s '.container'

Learn more

Support css-doodle

Donations keep the library going. If you’ve found it valuable, consider backing it.

Thanks to all our backers.
  • boneyao
  • Incognito
  • Johann Tepstad
  • Aragakey J.
  • Alex Russell
  • Avral
  • Keith Kurson
  • Eric Treacy
  • Taehoon Moon
  • robert
  • Rich Holman
  • Yuan Chuan