-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Andreas Herd
committed
Mar 23, 2024
1 parent
3e1e9b1
commit f92ab35
Showing
9 changed files
with
21 additions
and
26 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
docs/assets/find-solution-f3eccbc2.js → docs/assets/find-solution-d8115828.js
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
import '../types/ramda' | ||
|
||
import type { PositionedPicture, Config, NonEmptyArray, Solution } from '../types/types' | ||
import type { PositionedPicture, NonEmptyArray, Solution } from '../types/types' | ||
import { evolve, last, prop, sortBy } from 'ramda' | ||
import type { Ord } from 'ramda' | ||
import { sizeHomogeneity } from '../constants' | ||
|
||
const aspectRatioAndSize = (config: Config) => | ||
const aspectRatioAndSize = | ||
(solution: Solution): Ord => { | ||
const sizeHomogeneity = solution.pictures.length < config.randomizeThreshold | ||
? config.lowSizeHomogeneity | ||
: config.sizeHomogeneity | ||
return (solution.score + solution.sizeHomogeneity * sizeHomogeneity) / (sizeHomogeneity + 1) | ||
const sh = solution.pictures.length < 4 | ||
? .1 | ||
: sizeHomogeneity + solution.pictures.length * 0.1 | ||
return (solution.score + solution.sizeHomogeneity * sh) / (sh + 1) | ||
} | ||
|
||
export const evaluateSolutions = (results: NonEmptyArray<Solution>, config: Config): Solution => { | ||
const rated = sortBy(aspectRatioAndSize(config), results) | ||
export const evaluateSolutions = (results: NonEmptyArray<Solution>): Solution => { | ||
const rated = sortBy(aspectRatioAndSize, results) | ||
const winner = last(rated) | ||
return evolve({ pictures: sortBy<PositionedPicture>(prop('url')) }, winner) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters