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

Function drawText

src/engineDraw.js:889–899  ·  view source on GitHub ↗

Draw text on main canvas in world space * Automatically splits new lines into rows * @param {string|number} text * @param {Vector2} pos * @param {number} [size] * @param {Color} [color=WHITE] * @param {number} [lineWidth] * @param {Color} [lineColor=BLACK] * @param {CanvasText

(text, pos, size=1, color=WHITE, lineWidth=0, lineColor=BLACK, textAlign='center', font=fontDefault, fontStyle='', maxWidth, angle=0, context=drawContext)

Source from the content-addressed store, hash-verified

887 * @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=drawContext]
888 * @memberof Draw */
889function drawText(text, pos, size=1, color=WHITE, lineWidth=0, lineColor=BLACK, textAlign='center', font=fontDefault, fontStyle='', maxWidth, angle=0, context=drawContext)
890{
891 // convert to screen space
892 pos = worldToScreen(pos);
893 size *= cameraScale;
894 lineWidth *= cameraScale;
895 angle -= cameraAngle;
896 angle *= -1;
897
898 drawTextScreen(text, pos, size, color, lineWidth, lineColor, textAlign, font, fontStyle, maxWidth, angle, context);
899}
900
901/** Draw text in screen space
902 * Automatically splits new lines into rows

Callers

nothing calls this directly

Calls 2

worldToScreenFunction · 0.85
drawTextScreenFunction · 0.85

Tested by

no test coverage detected