-
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.
feat: Grid Size Appropriateness metric #46
- Loading branch information
1 parent
ffa63f0
commit c16cef0
Showing
11 changed files
with
3,550 additions
and
28 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,5 +12,8 @@ | |
"url": "git+https://github.com/sergiomrebelo/evo-poster.git" | ||
}, | ||
"author": "Sérgio M. Rebelo <[email protected]> (https://sergiorebelo.work/)", | ||
"license": "ISC" | ||
"license": "ISC", | ||
"devDependencies": { | ||
"jest": "^29.6.1" | ||
} | ||
} |
18 changes: 0 additions & 18 deletions
18
src/@evoposter/evaluator/src/constraints/GridAppropriateSize.mjs
This file was deleted.
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
61 changes: 61 additions & 0 deletions
61
src/@evoposter/evaluator/src/metrics/GridAppropriateSize.mjs
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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/** | ||
* Grid Size Appropriateness | ||
* | ||
* Measure the appropriate of the used grid to the size of container | ||
* it is related to if the width and height of the grid is | ||
* in accordance with poster size | ||
* | ||
* Sérgio M. Rebelo | ||
* CDV lab. (CMS, CISUC, Portugal) | ||
* srebelo[at]dei.uc.pt | ||
* | ||
* v1.0.0 November 2023 | ||
*/ | ||
|
||
const DEBUG = true; | ||
|
||
export const compute = ( | ||
containerWidth, containerHeight, | ||
rows = [], columns = [], | ||
margins = {left:0, top:0, right:0, bottom:0} | ||
) => { | ||
console.log ("EXAMPLE=", containerWidth, containerHeight, rows, columns, margins); | ||
|
||
|
||
let invalid = false; | ||
// debug | ||
let msg = ""; | ||
|
||
// height calculation | ||
let height = margins.top+margins.bottom; | ||
for (let r of rows) { | ||
height = height + parseFloat(r); | ||
} | ||
// width calculation | ||
let width = margins.left+margins.right; | ||
for (let r of columns) { | ||
width = width + parseFloat(r); | ||
} | ||
|
||
if (height > containerHeight) { | ||
invalid = true; | ||
msg += `Grid height is bigger than container (grid:${height}, container:${containerHeight}). `; | ||
} else if (height < containerHeight) { | ||
msg += `Grid and container height are not the same (grid:${height}, container:${containerHeight}). `; | ||
} | ||
|
||
if (width > containerWidth) { | ||
invalid = true; | ||
msg += `Grid width is bigger than container (grid:${width}, container:${containerWidth}). `; | ||
} else if (width < containerWidth) { | ||
msg += `Grid and container width are not the same (grid:${width}, container:${containerWidth}). `; | ||
} | ||
|
||
if (msg !== "" && DEBUG) { | ||
console.warn(msg); | ||
} | ||
|
||
return invalid ? 1 : 0; | ||
} | ||
|
||
export { compute as default }; |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const params = [ | ||
{ | ||
width: 300, | ||
height: 423, | ||
rows: [379.95], | ||
columns: [135, 135], | ||
margins: {left: 15, top: 21.900000000000002, right: 15, bottom: 21.150000000000002}, | ||
invalid: false, | ||
}, | ||
{ | ||
width: 300, | ||
height: 423, | ||
rows: [377.84999999999997], | ||
columns: [135, 135], | ||
margins: {left: 15, top: 21.150000000000002, right: 15, bottom: 24.000000000000025}, | ||
invalid: true | ||
} | ||
]; | ||
|
||
|
||
describe(`Test the Grid Size Appropriateness metric`, () => { | ||
// Grid Size Appropriateness metric | ||
}); | ||
|
||
// (5) [72.85000000000001, 69.85, 71.95, 70.89999999999999, 70.89999999999999] (2) [135, 135] {left: 15, top: 33.27500000000001, right: 15, bottom: 33.27500000000001} |
Empty file.
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
Large diffs are not rendered by default.
Oops, something went wrong.