Figma Support Forum

Adding strokeCap to individual vertices

I have a simple vector line going from point A to point B. I want to add Triangle arrow to the vertex at point B. This is how I am doing it but it is not getting applied. What am I doing wrong here?

var vector = figma.createVector()
vector.vectorNetwork.vertices[0].strokeCap = "NONE"
vector.vectorNetwork.vertices[1].strokeCap = "ARROW_EQUILATERAL"

I think this is because the strokeCap property is read-only. But I would like to know the answer as well.

This snippet from this article seems to work:

/* This plugin adds arrowheads to vectors */
/* Created by Duncan Geere, Jan 2020 */

for (const selection of figma.currentPage.selection) { 
  const node = selection as VectorNode

  /* make a copy of the original node */
  let copy = JSON.parse(JSON.stringify(node.vectorNetwork))
  /* if it has a strokeCap property, change */
  if ("strokeCap" in copy.vertices[copy.vertices.length-1]) {
    copy.vertices[copy.vertices.length-1].strokeCap = "ARROW_EQUILATERAL"
    copy.vertices[0].strokeCap = "NONE"

  /* assign the copy back to the original */
  node.vectorNetwork = copy
1 Like

Thank you so much @ReneLopez

1 Like