Объявлять переменную в среде и передавать ее как переменную
Хочу, чтобы не нужно было объявлять переменную, а она объявлялась в среде и передавать ее как переменную.
Вот такой код есть:
function createNewPath(namePath,[...arr],color) {
let namePath = new Path2D()
namePath.rect(arr[0], arr[1], arr[2], arr[3])
namePath.closePath()
ctx.fillStyle = `${color}`;
ctx.fill(namePath)
ctx.stroke(namePath)
}
let contentPath = new Path2D();
createNewPath(contentPath,[0, height - height / 3, width, height - height / 2],"rgba(43, 41, 41, 1)")
let redLine = new Path2D();
createNewPath(redLine,[0, height - height / 3, width, 4],"rgb(255, 0, 0)")