Code
import {rasterize, serialize} from "@mbostock/saving-svg"
function get_paper_dimension(format, orientation) {
if (orientation == "Portrait") {
return {x: format.width, y: format.height}
} else {
return {x: format.height, y: format.width}
}
}
viewof format = Inputs.select(new Map([
["Letter", {width: 215.9, height: 279.4}],
["A4", {width: 210, height: 297}],
]), {label: "Paper Format"})
viewof orientation = Inputs.radio(["Landscape", "Portrait"], {value: "Landscape"})
paper_dimension = get_paper_dimension(format, orientation)
viewof paper = Inputs.form({
x: Inputs.range([1, 1000], {value: paper_dimension.x, step: .01, label: "Width (mm)"}),
y: Inputs.range([1, 1000], {value: paper_dimension.y, step: .01, label: "Height (mm)"}),
colour: Inputs.color({value: "#ffffff", label: "Colour"}),
})