Public
Edited
Mar 12
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
scalePath = (path, value, getSmaller) => {
// Path format = [{x: n, y: n}, {x: n, y: n}]
var bottomOfPath = []
var topOfPath = []
for(var i = 0; i< path.length; i++){
var reducer = getSmaller ? value*((path.length-i)/path.length) : value*(i/path.length)
var d = path[i]
// Get the following path
var dn = path[i+1]
if(dn){
// Get perpendicular line based on the angle from the current point to next point
var perp = getAngledLineFromPoints(d, dn, value * reducer, d, true)
// Append each point to the top and bottom arrays, which are recombined later
bottomOfPath.push(perp[0])
topOfPath.push(perp[1])
}
}
// Flip the order of topOfPath (as we're returning to the start)
// and append to the end of bottomofPath
return {
path: bottomOfPath.concat(topOfPath.reverse()),
// Only using these start and end arrays to show the extras
start: bottomOfPath,
end: topOfPath.reverse()
}
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more