MCPcopy Index your code
hub / github.com/KilledByAPixel/LittleJS / drawText

Method drawText

plugins/uiSystem.js:425–443  ·  view source on GitHub ↗

Draw text to the UI context * @param {string} text * @param {Vector2} pos * @param {Vector2} size * @param {Color} [color=uiSystem.defaultColor] * @param {number} [lineWidth=uiSystem.defaultLineWidth] * @param {Color} [lineColor=uiSystem.defaultLineColor] * @

(text, pos, size, color=uiSystem.defaultColor, lineWidth=uiSystem.defaultLineWidth, lineColor=uiSystem.defaultLineColor, align='center', font=uiSystem.defaultFont, fontStyle='', applyMaxWidth=true, textShadow=undefined, shadowColor=BLACK, shadowBlur=0, shadowOffset=vec2())

Source from the content-addressed store, hash-verified

423 * @param {number} [shadowBlur]
424 * @param {Color} [shadowOffset] */
425 drawText(text, pos, size, color=uiSystem.defaultColor, lineWidth=uiSystem.defaultLineWidth, lineColor=uiSystem.defaultLineColor, align='center', font=uiSystem.defaultFont, fontStyle='', applyMaxWidth=true, textShadow=undefined, shadowColor=BLACK, shadowBlur=0, shadowOffset=vec2())
426 {
427 const context = uiSystem.uiContext;
428 if (shadowColor.a > 0)
429 {
430 if (textShadow)
431 drawTextScreen(text, pos.add(textShadow), size.y, shadowColor, lineWidth, lineColor, align, font, fontStyle, applyMaxWidth ? size.x : undefined, 0, context);
432 if (shadowBlur || shadowOffset.x || shadowOffset.y)
433 {
434 // setup shadow
435 context.shadowColor = shadowColor.toString();
436 context.shadowBlur = shadowBlur;
437 context.shadowOffsetX = shadowOffset.x;
438 context.shadowOffsetY = shadowOffset.y;
439 }
440 }
441 drawTextScreen(text, pos, size.y, color, lineWidth, lineColor, align, font, fontStyle, applyMaxWidth ? size.x : undefined, 0, context);
442 context.shadowColor = '#0000';
443 }
444
445 /**
446 * @callback DragAndDropCallback - Callback for drag and drop events

Callers 5

renderMethod · 0.45
renderMethod · 0.45
renderMethod · 0.45
renderMethod · 0.45
renderMethod · 0.45

Calls 4

vec2Function · 0.85
drawTextScreenFunction · 0.85
addMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected