splitNode method

dynamic splitNode(
  1. dynamic node,
  2. dynamic width,
  3. dynamic height
)

Implementation

splitNode(node, width, height) {
  node['used'] = true;
  node['down'] = {
    "x": node['x'],
    "y": node['y'] + height,
    'width': node['width'],
    'height': node['height'] - height
  };
  node['right'] = {
    "x": node['x'] + width,
    "y": node['y'],
    'width': node['width'] - width,
    'height': height
  };
  return node;
}