Skip to content

Instantly share code, notes, and snippets.

@captainbrosset
Created March 5, 2021 09:34
Show Gist options
  • Save captainbrosset/a9bbaad5eca3bb27c855a46bd423409b to your computer and use it in GitHub Desktop.
Save captainbrosset/a9bbaad5eca3bb27c855a46bd423409b to your computer and use it in GitHub Desktop.
Code snippets for the "How we built the DevTools Tooltips" article
// Get the first segment's start point.
const points = [segments[0].start];
// And append the end point of each segment, one by one, after that.
for (const segment of segments) {
if (!segment) {
continue;
}
points.push(segment.end);
}
let path = points.map(({x, y}) => `${x},${y}`).join('L');
path = `M${path}Z`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment