7 ms·
Someone complained about JSON above, but I think it does a nicer job here: { "path": [ [10, 10], [90, 10], [90, 90], [10, 90], [10, 10
by SquareWheel 6y ago
Someone complained about JSON above, but I think it does a nicer job here:
{
"path": [
[10, 10],
[90, 10],
[90, 90],
[10, 90],
[10, 10]
]
}
No need for the x and y, really. And it's still quite legible on one line.
{"path": [[10, 10], [90, 10], [90, 90], [10, 90], [10, 10]]}
- ognarb 6y agoYou clearly didn't understand how the path element in SVG works. The M, L and other characters contains valuable information. M stand for move, L for trace a line, but you can also have instructions for bezier curve or Z for closing a path. Your json format by removing this information is useless.
- climech 6y agoI believe something like this would work (excuse the comments normally not allowed in JSON): { paths: [ { points: [ [10, 10], // 0 [90, 10], // 1 [90, 90], // 2 [10, 90] // 3 ], lines: [ [0, 1, 2, 3, 0] // connect point 0 to 1 to 2 to (...) ], curves: { 0: [5, 15, 15, 5] // bezier control points for point 0 (x1, y1, x2, y2) } } ] } The downside (other than the bloat) would be when writing the code by hand, you'd have to keep track of the indices in the `points` array.
- mrmonkeyman 6y agoHow is this better?
- jcelerier 6y agoi'd much rather have [ { line: [10, 10] }, { cubic: [ 5, 15, 15, 5 ] }, ... ] or even [ ["line", 10, 10], ["cubic", ...], ... ] - anything as long as there's a way to stream the data (which is not possible with your format as you need to receive the whole object before being able to do anything).
- afiori 6y agothis makes me realize that xml maps relatively well to JSON array whose elements are object with 1 fields (or 2 fields) whose value is again a similar array.
- SquareWheel 6y ago> You clearly didn't understand how the path element in SVG works. No, I didn't. I was working from the parent's code. I don't appreciate your attitude though. There's much nicer ways to correct people online.
- oneeyedpigeon 6y agoWhile there's truth in this, it's irrelevant to their point which was: > No need for the x and y, really