moving-mondrian

Randomly generated animated images in the style of Piet Mondrian  https://p.ce9e.org/moving-mondrian/
git clone https://git.ce9e.org/moving-mondrian.git

commit
d6497db3737463a932025bffb8064190d9f6b66a
parent
700946bc2216f76b7570bc06f760f10ee33a4e45
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2024-05-10 18:21
tune: weight split direction based on aspect ratio

Diffstat

M mondrian.js 8 +++++++-

1 files changed, 7 insertions, 1 deletions


diff --git a/mondrian.js b/mondrian.js

@@ -80,7 +80,13 @@ var animate = function(element, delta) {
   80    80 			div.append(element);
   81    81 			div.append(other);
   82    82 		}
   83    -1 		div.dataset.dir = (Math.random() < 0.5) ? "vertical" : "horizontal";
   -1    83 
   -1    84 		var rect = element.getBoundingClientRect();
   -1    85 		if (rect.height > rect.width) {
   -1    86 			div.dataset.dir = (Math.random() < 0.2) ? "vertical" : "horizontal";
   -1    87 		} else {
   -1    88 			div.dataset.dir = (Math.random() < 0.8) ? "vertical" : "horizontal";
   -1    89 		}
   84    90 	}
   85    91 };
   86    92