PathToPoints icon indicating copy to clipboard operation
PathToPoints copied to clipboard

Array format

Open seamuskills opened this issue 3 years ago • 2 comments

It would be really cool if I could have it in an actual array format (no points without a comma). It would be even better if I would be able to get it in an array of objects so I could just paste it in my code and reference pts[index].x and pts[index].y.

seamuskills avatar Dec 13 '21 15:12 seamuskills

ps: this applies to the "Enhancement" label but i'm too dumb to know how to apply it to the issue in order to mark it properly :P

seamuskills avatar Dec 13 '21 15:12 seamuskills

Hi there,

With a bit of JS that you put into the console you can do things like that :

$.each($(".bellows__content"), function() {
    var arr = $(this).text().split('\r');
    var strBuilder = "[";
    arr.forEach(elem => {
        var point = elem.split(',')
        strBuilder += "[" + point[0] + ", " + point[1] +"],"
    });
    strBuilder += "]";
    console.log(strBuilder.replace(/.$/,";"))
});

Which gives you a double array like : [[5.5292969, 68.99009051541901],[5.529296899999999, 58.99008968793175],[5.5292969, 48.993633556390485],[5.5292969, 38.9941609771525],[5.5292969, 28.998012414359945],[5.5292969, 19.003545975035802],[11.130794540568527, 14.597656],[21.134214350096226, 14.597656],[31.12165581628418, 14.783071676696776],[40.60570978253174, 17.425324311935427],[46.38971528167724, 25.36039187963867],[46.87949616430664, 35.27697303320313],[42.233416109863285, 43.93639123141479],[33.28850051342773, 47.988494483993534],[23.310764462068438, 48.478516],[16.513672, 51.684997875],[16.513672, 61.69265063299507],[13.826591555682056, 69],[16.513672, 25.511847164076332],[16.513672, 35.5012928727684],[22.777426235977178, 39.23795540986633],[32.541931729736326, 37.720765323486326],[35.49511804496765, 28.908156050628662],[27.58216764868164, 23.938582263183594],[17.58754978739929, 23.800781],[, undefined],;

Change it a bit to fix the last index and to suit it to the programming language of your choice and you are good to go.

See ya.

Shinao avatar Jan 14 '22 19:01 Shinao

Hello!

I implemented a JSON output on https://github.com/Shinao/PathToPoints/pull/7

Working very well, I implemented 2 types of JSON to choose from

KevynTD avatar Jun 25 '24 05:06 KevynTD

I guess sometimes laziness pays off. We get cool new features without lifting a finger. 😄 Thanks again @KevynTD

Shinao avatar Jun 25 '24 09:06 Shinao