(
x: number,
y: number,
w: number,
h: number,
attrs: {
fill?: string;
fillOpacity?: number;
stroke?: string;
strokeWidth?: number;
dash?: string;
} = {}
)
| 166 | } |
| 167 | |
| 168 | function rect( |
| 169 | x: number, |
| 170 | y: number, |
| 171 | w: number, |
| 172 | h: number, |
| 173 | attrs: { |
| 174 | fill?: string; |
| 175 | fillOpacity?: number; |
| 176 | stroke?: string; |
| 177 | strokeWidth?: number; |
| 178 | dash?: string; |
| 179 | } = {} |
| 180 | ): string { |
| 181 | const parts = [ |
| 182 | `x="${round(x)}"`, |
| 183 | `y="${round(y)}"`, |
| 184 | `width="${round(w)}"`, |
| 185 | `height="${round(h)}"`, |
| 186 | `fill="${attrs.fill ?? 'none'}"`, |
| 187 | ]; |
| 188 | if (attrs.fillOpacity !== undefined) parts.push(`fill-opacity="${attrs.fillOpacity}"`); |
| 189 | if (attrs.stroke) { |
| 190 | parts.push(`stroke="${attrs.stroke}"`, `stroke-width="${attrs.strokeWidth ?? 1}"`); |
| 191 | if (attrs.dash) parts.push(`stroke-dasharray="${attrs.dash}"`); |
| 192 | } |
| 193 | return `<rect ${parts.join(' ')} />`; |
| 194 | } |
| 195 | |
| 196 | /** |
| 197 | * Cut a string to what fits, with an ellipsis — the arithmetic twin of the |
no test coverage detected