Skip to content

Commit

Permalink
squash
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Herd committed Mar 23, 2024
1 parent 18f9d5c commit 182fb4e
Show file tree
Hide file tree
Showing 14 changed files with 62 additions and 56 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
Almost 10 years ago I [wrote an algorithm](https://github.com/mendrik/diorama) that layouts a set of images into a fixed-size rectangle. The old algorithm was heavily optimized for speed, making the code hard to read and even harder to maintain.

Recently (2023) I had an idea how to simplify the algorithm and decided to put this on to a more modern foundation.
The algorithm works now with full binary trees instead of full and balanced ones, reducing the amount of calculations needed. Further more for smaller amount of imnages we can now use a generator to get all tree permutations before switching to a random strategy, making this really snappy for smaller image sets.

Though the algorithm searches for gap-less solutions the provided demo here cheats by giving images a bit of space and avoids cropping.
It should be fairly trivial to display images via contain/cover modes in other scenarios.
The demo uses some css sugar (paddings, borders and rotation) for dramatic effect but under the bonnet the algorithm still creates gapless rectangles.

The result [can be seen here](https://mendrik.github.io/diorama-2023/).
The demo [can be seen here](https://mendrik.github.io/diorama-2023/).

## Layout algorithm

Expand All @@ -28,6 +28,6 @@ export const findSolution = (
```typescript
export type Config = {
maxComputationTime: number // ms how long the algorithm is allowed to search for a good solution, default 300ms
sizeHomogenity: number // how imporant equal picture-sizes are. If you don't care about cropping at all set this to 1000
randomizeThreshold: number // when to switch to random tree layout strategy
}
```
5 changes: 0 additions & 5 deletions docs/assets/find-solution-5a0fb4b2.js

This file was deleted.

5 changes: 5 additions & 0 deletions docs/assets/find-solution-9b735a6f.js

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions docs/assets/index-2fe90b35.js → docs/assets/index-e2c4e463.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<script type="module" crossorigin src="/diorama-2023/assets/index-2fe90b35.js"></script>
<link rel="stylesheet" href="/diorama-2023/assets/index-5d0ad71d.css">
<script type="module" crossorigin src="/diorama-2023/assets/index-e2c4e463.js"></script>
<link rel="stylesheet" href="/diorama-2023/assets/index-ade168fb.css">
</head>
<body>
<div id="root"></div>
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "diorama",
"version": "2.0.15",
"version": "2.0.16",
"keywords": [
"gallery",
"webworker",
Expand All @@ -16,7 +16,7 @@
"lib"
],
"repository": {
"url": "https://github.com/mendrik/diorama-2023",
"url": "git+https://github.com/mendrik/diorama-2023.git",
"type": "github"
},
"main": "./lib/diorama.umd.cjs",
Expand Down
Loading

0 comments on commit 182fb4e

Please sign in to comment.