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

Function createElementWithDefaults

app.js:2069–2103  ·  view source on GitHub ↗
(type, overrides = {})

Source from the content-addressed store, hash-verified

2067}
2068
2069function createElementWithDefaults(type, overrides = {}) {
2070 const defaultStroke = getContrastingColor(bgColor);
2071 const defaultFill = defaultStroke;
2072 const defaultText = isLightColor(defaultFill) ? "#111827" : "#FFFFFF";
2073 const mode = getCurrentDriverMode();
2074 const isOled = mode === "u8g2";
2075
2076 return {
2077 id: makeId(),
2078 type,
2079 x: 10,
2080 y: 10,
2081 w: isOled ? 48 : 80,
2082 h: isOled ? 16 : 30,
2083 text: "",
2084 textSize: isOled ? 1 : 2,
2085 fillColor: defaultFill,
2086 strokeColor: defaultStroke,
2087 textColor: defaultText,
2088 fillAlpha: 255,
2089 oledFill: true,
2090 value: 50,
2091 actionType: "",
2092 actionTargetScreenId: null,
2093 // Keep `font` aligned with active mode so preview + codegen behave correctly.
2094 font: mode === "tft" ? DEFAULT_TFT_FONT : DEFAULT_U8G2_FONT,
2095 // Seed driver-specific fields too (older projects may rely on these).
2096 tftFont: DEFAULT_TFT_FONT,
2097 u8g2Font: DEFAULT_U8G2_FONT,
2098 iconTintEnabled: false,
2099 iconTintColor: "#ffffff",
2100 rotation: 0,
2101 ...overrides
2102 };
2103}
2104
2105const UI_EXAMPLES = [
2106 {

Callers 3

app.jsFile · 0.85
addIconElementFunction · 0.85
addAssetElementToCanvasFunction · 0.85

Calls 4

getContrastingColorFunction · 0.85
isLightColorFunction · 0.85
getCurrentDriverModeFunction · 0.85
makeIdFunction · 0.85

Tested by

no test coverage detected