import { Rect } from '../../../../../geoms/types' ; import { CanvasRenderer , withContext } from '../../../../../renderers/canvas' ; import { degToRad , Rotation } from '../../../../../utils/common' ; import { Dimensions } from '../../../../../utils/dimensions' ; import { computeChartTransform } from '../../../state/utils/utils' ; internal export function withPanelTransform ( ctx , panel , rotation , renderingArea , fn , clippings ? ) { const transform = computeChartTransform ( panel , rotation ) ; withContext ( ctx , ( ) => { ctx . translate ( renderingArea . left + panel . left + transform . x , renderingArea . top + panel . top + transform . y ) ; ctx . rotate ( degToRad ( rotation ) ) ; if ( clippings ?. shouldClip ) { const { x , y , width , height } = clippings . area ; ctx . beginPath ( ) ; ctx . rect ( x , y , width , height ) ; ctx . clip ( ) ; } fn ( ctx ) ; } ) ; }