A web component for
Visual Art & Creative Coding
Empowering CSS as an artistic language
Empowering CSS as an artistic language
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> Nested, readable, no XML
<css-doodle>
@grid: 1 / 100% auto (16/9);
--c: #b6a8f2, #f2a7b8, #422abf x3, #1c1b1b;
@content: @svg(
viewBox: -57 -57 114 114;
stroke-linejoin: round;
circle*2400 {
fill: @p(--c);
r: $(.37 + abs.sin(8π/@N*@n(-1)*2));
cx, cy: @Plot(
r: 50 + 8*(sin(9t)*tan(14t) + tan(3t));
);
};
);
</css-doodle> No GLSL, runs on the GPU
<css-doodle>
@grid: 1 / 100% auto (16/9);
@content: @paint(
d: 0;
k*60 {
p: vec3(rotate(pos, t/4) * d, d + t);
d: d + .7length(fract(p) - .5) - .1;
}
fill: gradient(d / 10,
#fff, #fd7 .1, #e46 .3, #07121f
);
);
</css-doodle> One curve, drawn as a clip-path
<css-doodle>
@grid: 1 / 100% auto (16/9);
background: #2b4bb0;
clip-path: @shape(
points: 1200;
x: .1104(2.8 - 11cos(.6t) - cos(55t));
y: -1.04 - .1625(11sin(9.03t) - sin(77t));
round: .1;
);
</css-doodle> Written like @shape, drawn on the GPU
<css-doodle>
@grid: 1 / 100% auto (16/9);
@content: @scene(
sphere*5 {
smooth: .3;
r: .3 - .02n;
move: .5sin(t + 2n) .25cos(1.3t + n) .2sin(n);
fill: gradient(n / N, #f83, #fab, #baf, #ade);
}
view: 0 15;
shine: .4;
);
</css-doodle> cssd render
# install
$ npm install -g @css-doodle/cli
# generate image from css-doodle code
$ cssd render code.css
# make image larger
$ cssd render code.css -x 10
# record a 10-second video
$ cssd render code.css -t 10s -o loop.mp4
# generate image from a css-doodle.com link
$ cssd render css-doodle.com/d/R3WhVB20fJ9fbZ1L