MCPcopy Create free account
hub / github.com/microsoft/SandDance / draw$3

Function draw$3

docs/app/js/sanddance-app.js:122686–122716  ·  view source on GitHub ↗
(context43, scene, bounds10)

Source from the content-addressed store, hash-verified

122684 return bounds9.set(x35, y34, x35 + w8, y34 + h13);
122685}
122686function draw$3(context43, scene, bounds10) {
122687 visit(scene, (item)=>{
122688 if (bounds10 && !bounds10.intersects(item.bounds)) return; // bounds check
122689 const img = getImage(item, this);
122690 let w9 = imageWidth(item, img);
122691 let h14 = imageHeight(item, img);
122692 if (w9 === 0 || h14 === 0) return; // early exit
122693 let x36 = (item.x || 0) - imageXOffset(item.align, w9), y35 = (item.y || 0) - imageYOffset(item.baseline, h14), opacity, ar0, ar1, t;
122694 if (item.aspect !== false) {
122695 ar0 = img.width / img.height;
122696 ar1 = item.width / item.height;
122697 if (ar0 === ar0 && ar1 === ar1 && ar0 !== ar1) {
122698 if (ar1 < ar0) {
122699 t = w9 / ar0;
122700 y35 += (h14 - t) / 2;
122701 h14 = t;
122702 } else {
122703 t = h14 * ar0;
122704 x36 += (w9 - t) / 2;
122705 w9 = t;
122706 }
122707 }
122708 }
122709 if (img.complete || img.toDataURL) {
122710 blend(context43, item);
122711 context43.globalAlpha = (opacity = item.opacity) != null ? opacity : 1;
122712 context43.imageSmoothingEnabled = item.smooth !== false;
122713 context43.drawImage(img, x36, y35, w9, h14);
122714 }
122715 });
122716}
122717var image = {
122718 type: "image",
122719 tag: "image",

Callers

nothing calls this directly

Calls 7

visitFunction · 0.70
getImageFunction · 0.70
imageWidthFunction · 0.70
imageHeightFunction · 0.70
imageXOffsetFunction · 0.70
imageYOffsetFunction · 0.70
blendFunction · 0.70

Tested by

no test coverage detected