function updateCanvasRec(property, event, form, p, mainName, change) {
var item = getSelectedHidden(p);
if (item.length === 1) item = item[0];
const newLength = parseFloat(event.target.value);
const mainItem = mainKids(p)[mainName];
var points = (i) => {
return item.segments[i].point;
};
if (property === "h") {
var heightVec = points(0).subtract(points(1));
var midPointLeft = points(0).add(points(1)).divide(2);
var midPointRight = points(2).add(points(3)).divide(2);
var halfVec = heightVec.multiply(newLength / heightVec.length).divide(2);
item.segments[0].point = midPointLeft.add(halfVec);
item.segments[1].point = midPointLeft.subtract(halfVec);
item.segments[2].point = midPointRight.subtract(halfVec);
item.segments[3].point = midPointRight.add(halfVec);
} else if (property === "w") {
var widthVec = points(0).subtract(points(3));
var midPointTop = points(1).add(points(2)).divide(2);
var midPointBot = points(0).add(points(3)).divide(2);
var halfVec = widthVec.multiply(newLength / widthVec.length).divide(2);
item.segments[0].point = midPointBot.subtract(halfVec);
item.segments[1].point = midPointTop.subtract(halfVec);
item.segments[2].point = midPointTop.add(halfVec);
item.segments[3].point = midPointBot.add(halfVec);
}
if (change === "slider") {
form.querySelector(`#${property}`).value = newLength;
} else if (change === "input") {
form.querySelector(`#${property}Value`).value = newLength.toFixed(2);
}
mainItem.segments.forEach((seg, index) => {
seg.point = canvasPoint(points(index), canvasValues.gridScale, p);
});
}