I’m wondering what the best way to take vectors from an SVG and create an extruded shape. Here’s an example of a drawn asset with it’s top point at 0,0.
I could spend the time writing something that parses the path of the line (sometimes it has beziers) but I was wondering if there’s a more acceptable method like an SVG loader or a tool? The goal is to pull in an SVG asset, parse the path then use the vector points to created an extruded shape.
The height/width of the asset is to be standardized ie. 100px x 100px so that I can scale and size the geometry as I need.
var NUM_POINTS = 6;
var path = document.getElementById("test");
var len = path.getTotalLength();
var points = [];
for (var i=0; i < NUM_POINTS; i++) {
var pt = path.getPointAtLength(i * len / (NUM_POINTS-1));
points.push([pt.x, pt.y]);
}
console.log("points = ", points);
Hmmmmm, I hate relying on the browser for these sorts of things so while getPointAtLength is tempting I rather take the hit on bundle size for svg-path-to-polygons. Looks like it’ll work nicely. Thanks again @Evgeni_Popov