MCPcopy Index your code
hub / github.com/microsoft/SandDance / draw

Function draw

docs/app/js/sanddance-app.js:122974–123007  ·  view source on GitHub ↗
(context49, scene, bounds16)

Source from the content-addressed store, hash-verified

122972 return bounds15;
122973}
122974function draw(context49, scene, bounds16) {
122975 visit(scene, (item)=>{
122976 var opacity = item.opacity == null ? 1 : item.opacity, p, x43, y42, i, lh, tl5, str;
122977 if (bounds16 && !bounds16.intersects(item.bounds) || opacity === 0 || item.fontSize <= 0 || item.text == null || item.text.length === 0) return;
122978 context49.font = font(item);
122979 context49.textAlign = item.align || "left";
122980 p = anchorPoint(item);
122981 x43 = p.x1, y42 = p.y1;
122982 if (item.angle) {
122983 context49.save();
122984 context49.translate(x43, y42);
122985 context49.rotate(item.angle * DegToRad);
122986 x43 = y42 = 0; // reset x, y
122987 }
122988 x43 += item.dx || 0;
122989 y42 += (item.dy || 0) + offset(item);
122990 tl5 = textLines(item);
122991 blend(context49, item);
122992 if ((0, _vegaUtil.isArray)(tl5)) {
122993 lh = lineHeight(item);
122994 for(i = 0; i < tl5.length; ++i){
122995 str = textValue(item, tl5[i]);
122996 if (item.fill && fill(context49, item, opacity)) context49.fillText(str, x43, y42);
122997 if (item.stroke && stroke(context49, item, opacity)) context49.strokeText(str, x43, y42);
122998 y42 += lh;
122999 }
123000 } else {
123001 str = textValue(item, tl5);
123002 if (item.fill && fill(context49, item, opacity)) context49.fillText(str, x43, y42);
123003 if (item.stroke && stroke(context49, item, opacity)) context49.strokeText(str, x43, y42);
123004 }
123005 if (item.angle) context49.restore();
123006 });
123007}
123008function hit(context, item, x, y, gx, gy) {
123009 if (item.fontSize <= 0) return false;
123010 if (!item.angle) return true; // bounds sufficient if no rotation

Callers 1

markBitmapsFunction · 0.70

Calls 15

restoreMethod · 0.80
visitFunction · 0.70
fontFunction · 0.70
anchorPointFunction · 0.70
offsetFunction · 0.70
textLinesFunction · 0.70
blendFunction · 0.70
lineHeightFunction · 0.70
textValueFunction · 0.70
fillFunction · 0.70
strokeFunction · 0.70
clipFunction · 0.70

Tested by

no test coverage detected