Published
Edited
Oct 26, 2018
1 fork
12 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function placeFrames() {
let placed = []
for (let frame of frames) {
let picked
for (let cell of sorted_grid) {
let temp_place = Object.assign({}, frame, { x:cell.x, y: cell.y })
let open = checkOpen(temp_place, placed)
if (open) { picked = temp_place; break; }
}
if (picked) {
if (tuning) {
picked = fineTume(picked, placed)
}
placed.push(picked)
}
}
return placed
}
Insert cell
function fineTume(picked, placed) {
let to_center = {x: picked.x - wall_center.x, y: picked.y - wall_center.y}
function tune(attempt, adjust, centerCheck) {
if (checkOpen(attempt, placed)) {
picked = attempt
if (centerCheck(attempt) !== 0) {
let adjusted = adjust(attempt)
tune(adjusted, adjust, centerCheck)
}
}
}
function yCenterCheck(frame) { return frame.y - wall_center.y }
function xCenterCheck(frame) { return frame.x - wall_center.x }
if (to_center.y < 0) {
function adjust(attempt) { return Object.assign({}, attempt, {y: attempt.y + tuner}) }
tune(picked, adjust, yCenterCheck)
}
if (to_center.y > 0) {
function adjust(attempt) { return Object.assign({}, attempt, {y: attempt.y - tuner}) }
function centerCheck(attempt) { return attempt.y - wall_center.y }
tune(picked, adjust, yCenterCheck)
}
if (to_center.x < 0) {
function adjust(attempt) { return Object.assign({}, attempt, {x: attempt.x + tuner}) }
function centerCheck(attempt) { return attempt.x - wall_center.x }
tune(picked, adjust, xCenterCheck)
}
if (to_center.x > 0) {
function adjust(attempt) { return Object.assign({}, attempt, {x: attempt.x - tuner}) }
function centerCheck(attempt) { return attempt.x - wall_center.x }
tune(picked, adjust, xCenterCheck)
}
return picked
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more