JSFiddle - React, Tailwind, and code Playground

by Sahil Kashyap

JavaScript

function transformToGestures(input) {
  const result = {
    name: "alpha",
    gestures: input.polylines.map(polyline => 
      polyline.map(([X, Y], index) => ({
        X,
        Y,
        ID: 0 // You can set this to `index` if you want unique IDs
      }))
    )
  };

  return [result];
}

// Example usage
const input = {
    "rects": [
        [
            35,
            0,
            115,
            150
        ],
        [
            35,
            0,
            81,
            150
        ],
        [
            35,
            0,
            81,
            109
        ],
        [
            35,
            27,
            81,
            82
        ],
        [
            35,
            27,
            60,
            82
        ],
        [
            35,
            27,
            4,
            82
        ],
        [
            35,
            68,
            4,
            41
        ],
        [
            35,
            88,
            4,
            21
        ],
        [
            35,
            98,
            4,
            11
        ],
        [
            35,
            103,
            4,
            6
        ],
        [
            39,
            27,
            56,
            82
        ],
        [
            39,
            27,
            56,
            51
        ],
        [
            51,
            27,
            44,
            51
        ],
        [
            51,
            27,
            23,
            51
        ],
        [
            51,
            27,
            23,
            26
        ],
        [
            60,
            27,
            14,
            26
        ],
        [
            60,
            27,
            14,
            13
        ],
        [
            65,
            27,
            9,
            13
        ],
        [
            65,
            27,
            9,
            6
        ],
        [
            65,
            33,
            9,
     ...