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

Function renderElements

app.js:3681–4323  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3679}
3680
3681function renderElements() {
3682 const scale = parseFloat(preview.dataset.scale || "1");
3683 preview.innerHTML = "";
3684 preview.style.position = "relative";
3685
3686 const isOLED = driverMode === "u8g2";
3687
3688 // Resolve asset references (assetId) into element preview/code fields.
3689 // This keeps old projects working while enabling the Assets Manager.
3690 const assetById = new Map((assets || []).filter(Boolean).map((a) => [a.id, a]));
3691 elements.forEach((el) => {
3692 if (!el || !el.assetId) return;
3693 const a = assetById.get(el.assetId);
3694 if (!a) return;
3695 if (el.type === "image") {
3696 if (a.dataUrl) el.previewUrl = a.dataUrl;
3697 if (a.rgb565) el.rgb565 = a.rgb565;
3698 if (a.width && a.height) {
3699 el.imageWidth = a.width;
3700 el.imageHeight = a.height;
3701 }
3702 } else if (el.type === "icon") {
3703 if (a.dataUrl) el.iconSrc = a.dataUrl;
3704 if (a.rgb565) el.rgb565 = a.rgb565;
3705 if (a.monoBitmap) el.monoBitmap = a.monoBitmap;
3706 if (a.width && a.height) {
3707 el.imageWidth = a.width;
3708 el.imageHeight = a.height;
3709 }
3710 }
3711 });
3712
3713 // OLED mode: draw everything into a 1:1 canvas and scale it up pixelated.
3714 let oledCanvasOk = false;
3715 if (isOLED) {
3716 const canvas = document.createElement("canvas");
3717 canvas.id = "oledCanvas";
3718 canvas.width = dispWidth;
3719 canvas.height = dispHeight;
3720 canvas.style.position = "absolute";
3721 canvas.style.left = "0";
3722 canvas.style.top = "0";
3723 canvas.style.width = dispWidth * scale + "px";
3724 canvas.style.height = dispHeight * scale + "px";
3725 canvas.style.pointerEvents = "none";
3726 // Keep the OLED canvas above the background and below interaction overlays/icons
3727 canvas.style.zIndex = "4";
3728 canvas.style.imageRendering = "pixelated";
3729 canvas.style.imageRendering = "-moz-crisp-edges";
3730 canvas.style.imageRendering = "crisp-edges";
3731 preview.appendChild(canvas);
3732
3733 const ctx = canvas.getContext("2d", { willReadFrequently: true });
3734 if (ctx) {
3735 try {
3736 ctx.imageSmoothingEnabled = false;
3737 ctx.clearRect(0, 0, dispWidth, dispHeight);
3738

Callers 15

zoomToSelectionFunction · 0.85
app.jsFile · 0.85
setZoomFunction · 0.85
applyStateSnapshotFunction · 0.85
addIconElementFunction · 0.85
setActiveScreenFunction · 0.85
initScreensFunction · 0.85
addAssetElementToCanvasFunction · 0.85
getCachedOledImageFunction · 0.85
onResizeMoveFunction · 0.85
onRotMoveFunction · 0.85

Calls 14

convertToOLEDColorFunction · 0.85
drawOledCircleFunction · 0.85
drawOledLineFunction · 0.85
elementHasTextFunction · 0.85
drawOledThresholdedTextFunction · 0.85
getPathOverlayFunction · 0.85
hexToRgbFunction · 0.85
getPreviewFontFamilyFunction · 0.85
getPreviewTftFontStyleFunction · 0.85
enableDragFunction · 0.85
addResizeHandlesFunction · 0.85

Tested by

no test coverage detected