@doodle
A doodle inside a doodle. The nested code is rendered to an image for use as a background,
or inserted as a real <css-doodle> element with @content.
Syntax
- @doodle(<code>), @doodle<width>x<height>(<code>)
- @doodle.wrap(<code>), @doodle<width>x<height>.wrap(<code>)
- code
- A complete doodle. Its
@gridsize should be in percentages, so it fills whatever it is drawn into. - width, height
- Digits glued to the name set the pixel size of the rendered image:
@doodle200x100(…). One number is used for both.
As a background the image is sized to cover unless a background-size follows.
A nested doodle draws from the parent's random sequence unless its code sets @seed,
and time uniforms like @t keep working inside.
A @pattern, @shaders or @scene inside it is drawn once, as a still image at time 0.
Examples
@grid: 3 / 60vmin _2px;
background: @doodle(
@grid: 4 / 100%;
background: @p(#000, #e6437d, #ebbf4d);
margin: 1px;
); Recursion, two levels deep:
@grid: @p(2, 3) / 60vmin;
background: @doodle(
@grid: @r4 / 100%;
background: @doodle(
@grid: @r4 / 100%;
background: @svg(
viewBox: 0 0 1 1;
path {
d: M 0 0 L 1 0 L 1 1;
fill: #000;
}
);
);
); As an element, so the nested cells stay interactive:
@grid: 1 / 60vmin auto;
@content: @doodle(
@grid: 5 / 100%;
background: #000;
clip-path: polygon(@m3.M2.r(100%));
);
As a frame, with border-image. Use the sized form: a plain @doodle() image takes the size
of the element, so its nine pieces are stretched to fit the border. A grid that is a multiple of 3 puts the cuts
on cell edges, and an image three times the border width keeps each piece 1:1.
@grid: 1 / 60vmin;
border: 30px solid;
border-image: @doodle90(
@grid: 3 / 100%;
background: #000;
clip-path: @shape(clover 4);
@nth(1, 3, 7, 9) { background: #e6437d; }
) 33.34% round; Seamless tiles
@doodle.wrap() makes a tile that repeats without seams: whatever crosses one edge comes back at the opposite one.
The image keeps its own size, so @doodle100.wrap(…) repeats every 100px, unless a background-size follows.
A :doodle background inside stays underneath.
@grid: 1 / 60vmin;
background: @doodle100.wrap(
@grid: 4 / 100%;
@place: @r(100%) @r(100%);
@size: @r(10%, 40%);
border: 2px solid #000;
border-radius: 50%;
);