MCPcopy Create free account
hub / github.com/SplootCode/splootcode / getNodeShape

Function getNodeShape

packages/editor/src/components/node_block.tsx:47–89  ·  view source on GitHub ↗
(
  className: string,
  x: number,
  y: number,
  width: number,
  leftCurve: boolean,
  rightCurve: boolean,
  ref: React.RefObject<SVGPathElement>,
  fillColor: string
)

Source from the content-addressed store, hash-verified

45}
46
47export function getNodeShape(
48 className: string,
49 x: number,
50 y: number,
51 width: number,
52 leftCurve: boolean,
53 rightCurve: boolean,
54 ref: React.RefObject<SVGPathElement>,
55 fillColor: string
56) {
57 let leftSide: string
58 let rightSide: string
59 if (leftCurve) {
60 leftSide = `a 20 20 0 0 1 0 ${NODE_BLOCK_HEIGHT}`
61 } else {
62 leftSide = `q -4,0 -4,4 v ${NODE_BLOCK_HEIGHT - 8} q 0,4 4,4`
63 width -= 4
64 x += 4
65 }
66
67 if (rightCurve) {
68 rightSide = `a 20 20 0 0 1 0 ${-NODE_BLOCK_HEIGHT}`
69 } else {
70 rightSide = `q 4,0 4,-4 v ${-NODE_BLOCK_HEIGHT + 8} q 0,-4 -4,-4`
71 width -= 4
72 }
73
74 let styles = {}
75 // Don't override the fill and stroke if invalid or selected.
76 if (className === 'svgsplootnode') {
77 styles = { fill: fillColor, stroke: fillColor }
78 }
79
80 return (
81 <path
82 ref={ref}
83 tabIndex={0}
84 className={className}
85 style={styles}
86 d={`M ${x} ${y} ${leftSide} h ${width} ${rightSide} z`}
87 />
88 )
89}
90
91@observer
92export class EditorNodeBlock extends React.Component<NodeBlockProps> {

Callers 2

renderMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected