Folds
to generate a new and unique variation
Every variart piece is a small program. This is the one that drew what you're looking at.
var cream = '#F2EEE4';
// Each hue with the near-black it deepens to in the crease.
var hues = [
['#E48AAE', '#4A1A2C'], ['#6F93D6', '#141C3A'], ['#48A9A2', '#0E2B2A'],
['#8A4BB0', '#22102E'], ['#D2303F', '#3A0A10'], ['#C83AAE', '#3A0A30']
];
var folds = intVariable('Folds', 6, 16);
var depth = intVariable('Depth', 90, 200);
s.rect(0, 0, width, height).attr({fill: cream});
// The coloured mass runs from the topmost wings (a Depth above the first
// crease) down to the last crease; centre that span, and shorten it as the
// wings deepen so the tip stays clear of the bottom edge.
var span = 260 - depth * 0.5;
var top = (height + depth - span) / 2;
var bottom = top + span;
var hue = getRandomInt(0, hues.length - 1);
var drift = getRandomArbitary(0, Math.PI * 2);
// One fold past the last, in plain cream, so the stack ends on bare paper.
for (var i = 0; i <= folds; i++){
var t = i / (folds - 1);
var ax = width / 2 + Math.sin(drift + t * 3) * 50;
var ay = top + (bottom - top) * t;
// Rise barely varies, so the folds nest in parallel rather than crossing.
var rise = depth * getRandomArbitary(0.95, 1.05);
var ly = ay - rise;
var ry = ay - rise * getRandomArbitary(0.9, 1.1);
// Wings lie almost level at the edges, then dive into the crease.
var d = 'M-10,' + ly +
' C' + (ax * 0.55) + ',' + (ly - 12) + ' ' + (ax - 25) + ',' + (ay - rise * 0.55) + ' ' + ax + ',' + ay +
' C' + (ax + 25) + ',' + (ay - rise * 0.55) + ' ' + (ax + (width - ax) * 0.45) + ',' + (ry - 12) + ' ' + (width + 10) + ',' + ry +
' L' + (width + 10) + ',' + (height + 10) + ' L-10,' + (height + 10) + ' Z';
// Mostly a slow walk round the spectrum, with the odd leap.
hue = (hue + (getRandomInt(0, 3) == 0 ? getRandomInt(2, 4) : getRandomInt(0, 1))) % hues.length;
var h = hues[hue];
var g = s.gradient('R(' + ax + ',' + ay + ',' + (width * 0.55) + ')' + h[1] + '-' + h[0] + ':18-' + cream + ':70');
s.path(d).attr({fill: i == folds ? cream : g});
}
Copyright © 2014–2026 Logic and Matter. All rights reserved. Questions? Comments? hello@variart.io