MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / rect

Function rect

ui/src/lib/export-svg.ts:168–194  ·  view source on GitHub ↗
(
  x: number,
  y: number,
  w: number,
  h: number,
  attrs: {
    fill?: string;
    fillOpacity?: number;
    stroke?: string;
    strokeWidth?: number;
    dash?: string;
  } = {}
)

Source from the content-addressed store, hash-verified

166}
167
168function 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

Callers 5

document_Function · 0.85
flowCardSvgFunction · 0.85
flowCapSvgFunction · 0.85
flowSvgFunction · 0.85
mapNodeSvgFunction · 0.85

Calls 3

pushMethod · 0.80
roundFunction · 0.70
joinMethod · 0.45

Tested by

no test coverage detected