From 8f0353357f58ada81b40bd76d1958e35cbe21ea0 Mon Sep 17 00:00:00 2001 From: Lauren Choi Date: Tue, 9 Nov 2021 15:10:48 -0500 Subject: added arrowhead --- .../CollectionFreeFormLinkView.tsx | 30 +++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinkView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinkView.tsx index 9d256f18b..27a34a9fa 100644 --- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinkView.tsx +++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinkView.tsx @@ -154,6 +154,25 @@ export class CollectionFreeFormLinkView extends React.Component { + let hex = c.toString(16); + return hex.length == 1 ? "0" + hex : hex; + } + + rgbToHex = (rgbString: string) => { + let rgbVals = [] + for (let i = 0; i < rgbString.length; i++) { + if (parseInt(rgbString[i])) { + let curr = '' + while (parseInt(rgbString[i]) != NaN) { + curr += (rgbString[i]) + } + rgbVals.push(parseInt(curr)) + } + } + return "#" + this.componentToHex(rgbVals[0]) + this.componentToHex(rgbVals[1]) + this.componentToHex(rgbVals[2]); + } + @computed.struct get renderData() { this._start; SnappingManager.GetIsDragging(); const { A, B, LinkDocs } = this.props; @@ -208,15 +227,24 @@ export class CollectionFreeFormLinkView extends React.Component= linkColorList.length ? "black" : linkColorList[currRelationshipIndex]; + console.log(stroke) + console.log(this.rgbToHex(stroke)) //calculate stroke width/thickness based on the relative importance of the relationshipship (i.e. how many links the relationship has) //thickness varies linearly from 3px to 12px for increasing link count const strokeWidth = linkSize === -1 ? "3px" : Math.floor(2 + 10 * (linkSize / Math.max(...linkRelationshipSizes))) + "px"; return !a.width || !b.width || ((!this.props.LinkDocs[0].linkDisplay) && !aActive && !bActive) ? (null) : (<> + + + + + + d={`M ${pt1[0]} ${pt1[1]} C ${pt1[0] + pt1norm[0]} ${pt1[1] + pt1norm[1]}, ${pt2[0] + pt2norm[0]} ${pt2[1] + pt2norm[1]}, ${pt2[0]} ${pt2[1]}`} + marker-end="url(#arrowhead)" /> {textX === undefined ? (null) : {Field.toString(this.props.LinkDocs[0].description as any as Field)} } -- cgit v1.2.3-70-g09d2