license import { arrayToMatrix4x4 , Matrix4x4 } from './calculate_inverse_matrix' ; import { Rect } from './interfaces/shape_interfaces' ; param subRect param rectWidth param rectHeight param flipHorizontaly export function getRotatedSubRectToRectTransformMatrix ( subRect , rectWidth , rectHeight , flipHorizontally ) { const a = subRect . width ; const b = subRect . height ; const flip = flipHorizontally ? - 1 : 1 ; const c = Math . cos ( subRect . rotation ) ; const d = Math . sin ( subRect . rotation ) ; const e = subRect . xCenter ; const f = subRect . yCenter ; const g = 1.0 / rectWidth ; const h = 1.0 / rectHeight ; const matrix = new Array ( 16 ) ; matrix [ 0 ] = a * c * flip * g ; matrix [ 1 ] = - b * d * g ; matrix [ 2 ] = 0.0 ; matrix [ 3 ] = ( - 0.5 * a * c * flip + 0.5 * b * d + e ) * g ; matrix [ 4 ] = a * d * flip * h ; matrix [ 5 ] = b * c * h ; matrix [ 6 ] = 0.0 ; matrix [ 7 ] = ( - 0.5 * b * c - 0.5 * a * d * flip + f ) * h ; matrix [ 8 ] = 0.0 ; matrix [ 9 ] = 0.0 ; matrix [ 10 ] = a * g ; matrix [ 11 ] = 0.0 ; matrix [ 12 ] = 0.0 ; matrix [ 13 ] = 0.0 ; matrix [ 14 ] = 0.0 ; matrix [ 15 ] = 1.0 ; return arrayToMatrix4x4 ( matrix ) ; }