author Yannick Deubel (https://github.com/yandeu)
 *  copyright license https export const debugSettings = { colors : { dynamic : '#ff0000' , static : '#90ee90' , sensor : '#ffff00' , sleeping : '#464646' } , lineWidth : 2 , fill : false , opacity : 0.25 } ; export const getDebugColors = ( options = { } ) => { const { colors } = debugSettings ; if ( options . isStatic ) return colors . static ; if ( options . isSensor ) return colors . sensor ; if ( options . isSleeping ) return colors . sleeping ; return colors . dynamic ; } ; export const adjustDebugColor = ( body , depth = 0 , _fill ? , _stroke ? ) => { const color = getDebugColors ( body ) ; const opacity = debugSettings . opacity ; const lineWidth = debugSettings . lineWidth ; const shouldFill = debugSettings . fill ; let fill = _fill ?? color + Math . round ( 255 * opacity ) . toString ( 16 ) ; if ( ! shouldFill ) fill = _fill ?? 'transparent' ; if ( body . isSleeping && ! body . isStatic && ! body . isSensor ) fill = _fill ?? color ; const stroke = _stroke ?? color ; body . render . fillStyle = fill ; body . render . strokeStyle = stroke ; body . render . lineWidth = lineWidth ; if ( depth >= 5 ) return ; body . parts . forEach ( part => { adjustDebugColor ( part , depth + 1 , fill , stroke ) ; } ) ; } ;