You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.3 KiB
JavaScript

'use strict';
const canvassed = require("canvassed");
const createRectangle = require("canvassed-rectangle");
const createText = require("canvassed-text");
module.exports = function createPlaceholderRectangle(options = {}) {
let placeholderRectangle = canvassed.createCompositeObject(Object.assign({
type: "placeholderRectangle",
objects: {
rectangle: createRectangle({
width: options.width,
height: options.height,
x: 0,
y: 0,
fillColor: "rgb(205, 205, 205)",
strokeColor: "rgb(74, 74, 74)",
strokeWidth: 1
}),
text: createText({
fontSize: 14,
originX: "center",
originY: "center",
alignment: "center"
})
},
drawOrder: ["rectangle", "text"],
propertyMap: {
fillColor: "rectangle",
strokeColor: "rectangle",
strokeWidth: "rectangle",
textFillColor: "text.fillColor",
textStrokeColor: "text.strokeColor",
textStrokeWidth: "text.strokeWidth",
alignment: "text",
fontSize: "text",
fontFamily: "text",
fontWeight: "text",
lineHeight: "text",
tags: "text",
text: "text",
width: function setWidth(width) {
return {
text: {x: width / 2},
rectangle: {width: width}
}
},
height: function setHeight(height) {
return {
text: {y: height / 2},
rectangle: {height: height}
}
},
}
}, options));
return placeholderRectangle;
}