import { Fill , Stroke , Rect } from '../../../../../geoms/types' ; import { withContext } from '../../../../../renderers/canvas' ; import { degToRad } from '../../../../../utils/common' ; import { Point } from '../../../../../utils/point' ; import { renderRect } from '../primitives/rect' ; const DEFAULT_DEBUG_FILL = { color : [ 238 , 130 , 238 , 0.2 ] , } ; const DEFAULT_DEBUG_STROKE = { color : [ 0 , 0 , 0 , 0.2 ] , width : 1 , } ; internal export function renderDebugRect ( ctx , rect , rotation = 0 , fill = DEFAULT_DEBUG_FILL , stroke = DEFAULT_DEBUG_STROKE ) { withContext ( ctx , ( ) => { ctx . translate ( rect . x , rect . y ) ; ctx . rotate ( degToRad ( rotation ) ) ; renderRect ( ctx , { ... rect , x : 0 , y : 0 } , fill , stroke , true ) ; } ) ; } internal export function renderDebugRectCenterRotated ( ctx , center , rect , fill = DEFAULT_DEBUG_FILL , stroke = DEFAULT_DEBUG_STROKE , rotation = 0 ) { const { x , y } = center ; withContext ( ctx , ( ) => { ctx . translate ( x , y ) ; ctx . rotate ( degToRad ( rotation ) ) ; ctx . translate ( - x , - y ) ; renderRect ( ctx , { ... rect , x : x - rect . width / 2 , y : y - rect . height / 2 } , fill , stroke ) ; } ) ; }