MCPcopy Index your code
hub / github.com/cifertech/DisplayKit / ensureElementDefaults

Function ensureElementDefaults

app.js:1795–1832  ·  view source on GitHub ↗
(el)

Source from the content-addressed store, hash-verified

1793}
1794
1795function ensureElementDefaults(el) {
1796 if (!el) return;
1797 if (!el.id) el.id = makeId();
1798 if (el.rotation == null) el.rotation = 0;
1799
1800 // Text improvements (backwards compatible)
1801 if (el.textAlign == null) el.textAlign = "left"; // left|center|right
1802 if (el.vAlign == null) el.vAlign = "top"; // top|middle|bottom
1803 if (el.textAutoSize == null) el.textAutoSize = false;
1804 if (el.lineHeight == null) el.lineHeight = 12;
1805
1806 // Path / advanced shape defaults (used by new tools)
1807 if (el.type === "path") {
1808 if (!Array.isArray(el.points)) el.points = [];
1809 if (el.closed == null) el.closed = false;
1810 if (el.strokeWidth == null) el.strokeWidth = 1;
1811 }
1812 if (el.type === "polygon") {
1813 if (el.sides == null) el.sides = 6;
1814 }
1815 if (el.type === "arc" || el.type === "gauge") {
1816 if (el.startAngle == null) el.startAngle = -90;
1817 if (el.endAngle == null) el.endAngle = 90;
1818 if (el.thickness == null) el.thickness = 4;
1819 if (el.minValue == null) el.minValue = 0;
1820 if (el.maxValue == null) el.maxValue = 100;
1821 }
1822
1823 // Grouping / auto-layout placeholders (phase 1)
1824 if (el.groupId == null) el.groupId = null;
1825 if (el.autoLayout == null) el.autoLayout = null;
1826
1827 // Assets: migrate legacy image/icon fields into asset references when possible
1828 if ((el.type === "image" || el.type === "icon") && !el.assetId) {
1829 // If element already has embedded data (rgb565/monoBitmap), keep as-is. Asset manager will allow import later.
1830 el.assetId = null;
1831 }
1832}
1833
1834function ensureAllElementDefaults() {
1835 (screens || []).forEach((scr) => {

Callers 1

ensureAllElementDefaultsFunction · 0.85

Calls 1

makeIdFunction · 0.85

Tested by

no test coverage detected