(
index: number,
ratio: Rectangular = { x: 0, y: 0, width: 1, height: 1 }
)
| 313 | } |
| 314 | |
| 315 | getRatioForIndex( |
| 316 | index: number, |
| 317 | ratio: Rectangular = { x: 0, y: 0, width: 1, height: 1 } |
| 318 | ): Rectangular | undefined { |
| 319 | let portionIndex = 0; |
| 320 | |
| 321 | if (index >= this.portionLength) { |
| 322 | return; |
| 323 | } |
| 324 | |
| 325 | for (let i = 0; i < this.children.length; i++) { |
| 326 | const portion = this.children[i]; |
| 327 | |
| 328 | if (portionIndex === index && portion.children.length === 0) { |
| 329 | return this.getRatioForPortion(portion, ratio); |
| 330 | } |
| 331 | |
| 332 | if (portion.portionLength + portionIndex > index) { |
| 333 | return portion.getRatioForIndex( |
| 334 | index - portionIndex, |
| 335 | this.getRatioForPortion(portion, ratio) |
| 336 | ); |
| 337 | } |
| 338 | |
| 339 | portionIndex += portion.portionLength; |
| 340 | } |
| 341 | |
| 342 | return ratio; |
| 343 | } |
| 344 | |
| 345 | getRatioForPortion( |
| 346 | portion: Portion, |
no test coverage detected