I'm trying to get the position
of the actual rotated rectangle inside the bounding box
.
The rectangle is rotated by 120deg
I'm trying to achieve the blue outline you can see here
I manage to get the rotation
right using the matrix
but I can't get the rest right.
Here is my code
let svg = document.querySelector('svg')
let overlay = document.querySelector('.overlay')
let rect = svg.children[0]
let bounds = rect.getBoundingClientRect()
let matrix = rect.getCTM()
overlay.style.top = bounds.top + 'px'
overlay.style.left = bounds.left + 'px'
overlay.style.width = bounds.width + 'px'
overlay.style.height = bounds.height + 'px'
overlay.style.transform = `matrix(${matrix.a},${matrix.b},${matrix.c},${matrix.d},0,0)`