MCPcopy
hub / github.com/KilledByAPixel/LittleJS / drawText

Method drawText

src/engineDraw.js:1330–1344  ·  view source on GitHub ↗

Draw text in world space using the image font * @param {string|number} text * @param {Vector2} pos * @param {Vector2|number} [size] * @param {boolean} [center=true] * @param {Color} [color=WHITE] * @param {boolean} [useWebGL=glEnable] * @param {CanvasRenderi

(text, pos, size=1, center, color, useWebGL, context)

Source from the content-addressed store, hash-verified

1328 * @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context]
1329 */
1330 drawText(text, pos, size=1, center, color, useWebGL, context)
1331 {
1332 ASSERT(isVector2(size) || typeof size === 'number', 'size must be a vec2 or number');
1333
1334 if (typeof size === 'number')
1335 {
1336 // if size is a number, make it a vector
1337 ASSERT(size > 0);
1338 size *= cameraScale;
1339 size = new Vector2(size, size);
1340 }
1341 else
1342 size = size.scale(cameraScale);
1343 this.drawTextScreen(text, worldToScreen(pos), size, center, color, useWebGL, context);
1344 }
1345
1346 /** Draw text in screen space using the image font
1347 * @param {string|number} text

Callers 3

gameRenderFunction · 0.45
gameRenderPostFunction · 0.45
gameRenderPostFunction · 0.45

Calls 5

drawTextScreenMethod · 0.95
isVector2Function · 0.85
worldToScreenFunction · 0.85
ASSERTFunction · 0.70
scaleMethod · 0.45

Tested by

no test coverage detected