(
{
width,
height,
shape,
opacity,
id,
}: {
width: number
height: number
shape: string
opacity: number
id: string
},
style: Record<string, any>
)
| 133 | } |
| 134 | |
| 135 | export function boxShadow( |
| 136 | { |
| 137 | width, |
| 138 | height, |
| 139 | shape, |
| 140 | opacity, |
| 141 | id, |
| 142 | }: { |
| 143 | width: number |
| 144 | height: number |
| 145 | shape: string |
| 146 | opacity: number |
| 147 | id: string |
| 148 | }, |
| 149 | style: Record<string, any> |
| 150 | ) { |
| 151 | if (!style.boxShadow) return null |
| 152 | |
| 153 | let shadow = '' |
| 154 | let innerShadow = '' |
| 155 | |
| 156 | for (let i = style.boxShadow.length - 1; i >= 0; i--) { |
| 157 | let s = '' |
| 158 | |
| 159 | const shadowStyle = style.boxShadow[i] |
| 160 | |
| 161 | if (shadowStyle.spreadRadius && shadowStyle.inset) { |
| 162 | shadowStyle.spreadRadius = -shadowStyle.spreadRadius |
| 163 | } |
| 164 | |
| 165 | // Expand the area for the filter to prevent it from cutting off. |
| 166 | const grow = |
| 167 | (shadowStyle.blurRadius * shadowStyle.blurRadius) / 4 + |
| 168 | (shadowStyle.spreadRadius || 0) |
| 169 | |
| 170 | const left = Math.min( |
| 171 | -grow - (shadowStyle.inset ? shadowStyle.offsetX : 0), |
| 172 | 0 |
| 173 | ) |
| 174 | const right = Math.max( |
| 175 | grow + width - (shadowStyle.inset ? shadowStyle.offsetX : 0), |
| 176 | width |
| 177 | ) |
| 178 | const top = Math.min( |
| 179 | -grow - (shadowStyle.inset ? shadowStyle.offsetY : 0), |
| 180 | 0 |
| 181 | ) |
| 182 | const bottom = Math.max( |
| 183 | grow + height - (shadowStyle.inset ? shadowStyle.offsetY : 0), |
| 184 | height |
| 185 | ) |
| 186 | |
| 187 | const sid = `satori_s-${id}-${i}` |
| 188 | const maskId = `satori_ms-${id}-${i}` |
| 189 | const shapeWithSpread = shadowStyle.spreadRadius |
| 190 | ? shape.replace( |
| 191 | 'stroke-width="0"', |
| 192 | `stroke-width="${shadowStyle.spreadRadius * 2}"` |
no test coverage detected
searching dependent graphs…