( positionParams: PositionParams, width: number, height: number )
| 274 | * @returns w, h in grid units (unclamped, minimum 1) |
| 275 | */ |
| 276 | export function calcWHRaw( |
| 277 | positionParams: PositionParams, |
| 278 | width: number, |
| 279 | height: number |
| 280 | ): { w: number; h: number } { |
| 281 | const { margin, rowHeight } = positionParams; |
| 282 | const colWidth = calcGridColWidth(positionParams); |
| 283 | |
| 284 | // width = colWidth * w - (margin * (w - 1)) |
| 285 | // w = (width + margin) / (colWidth + margin) |
| 286 | const w = Math.max( |
| 287 | 1, |
| 288 | Math.round((width + margin[0]) / (colWidth + margin[0])) |
| 289 | ); |
| 290 | const h = Math.max( |
| 291 | 1, |
| 292 | Math.round((height + margin[1]) / (rowHeight + margin[1])) |
| 293 | ); |
| 294 | |
| 295 | return { w, h }; |
| 296 | } |
| 297 | |
| 298 | // ============================================================================ |
| 299 | // Utility Functions |
no test coverage detected
searching dependent graphs…