'use strict'; const canvassed = require("canvassed"); module.exports = function createRectangle(options = {}) { let rectangle = canvassed.createObject(Object.assign({ type: "rectangle", cacheBustingProperties: ["fillColor", "strokeColor", "strokeWidth"], sizeBustingProperties: ["width", "height"], requiredProperties: ["width", "height"], fillColor: "black", strokeColor: "red", strokeWidth: 0, onRender: function onRender(context) { context.fillStyle = this.fillColor; context.fillRect(0, 0, this.width, this.height); if (this.strokeWidth > 0) { let offsetX = this.strokeWidth / 2; let offsetY = this.strokeWidth / 2; let adjustedWidth = this.width - this.strokeWidth; let adjustedHeight = this.height - this.strokeWidth; context.strokeStyle = this.strokeColor; context.lineWidth = this.strokeWidth; context.strokeRect(offsetX, offsetY, adjustedWidth, adjustedHeight); } }, onRecalculateSize: function onRecalculateSize() { return { width: this.width, height: this.height } } }, options)); return rectangle; }