MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / draw

Method draw

examples/commodetto/mini-drag/main.js:92–108  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

90 return this.bounds.contains(x, y);
91 }
92 draw() {
93 let image = this.image;
94 let label = this.label;
95 let x = this.bounds.x;
96 let y = this.bounds.y;
97 let width = this.bounds.w;
98 let height = this.bounds.h;
99 let sx = 0;
100 let sy = (0 == this.state ? 0 : height);
101 let color = (0 == this.state ? black : white);
102 drawBackground();
103 render.drawMasked(image, x, y, sx, sy, width, height, image.alpha, sx, sy);
104 render.drawText(label, font, color,
105 ((width - render.getTextWidth(label, font)) >> 1) + x,
106 ((height - font.height) >> 1) + y
107 );
108 }
109 onTouchBegan(x, y) {
110 this.anchor.x = this.bounds.x - x;
111 this.anchor.y = this.bounds.y - y;

Callers 5

onTouchMovedMethod · 0.95
updateMethod · 0.95
moreMethod · 0.80
main.jsFile · 0.80
moreMethod · 0.80

Calls 4

drawBackgroundFunction · 0.85
drawMaskedMethod · 0.80
drawTextMethod · 0.80
getTextWidthMethod · 0.80

Tested by

no test coverage detected