Skip to content

Writing Text and TeX content

xam4lor edited this page Jun 10, 2020 · 2 revisions

Presentation

pSEngine uses MathJax 3.0 to load and render Text and TeX text.

That's why, in order to use these options, you'll first need to import the MathJax library using the following line:

  <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js"></script>

TeX class

To create a new pSText object, you need to call the following constructor:

  let yourTeXObject = new pSText(
    text         // your TeX String (like "\\text{hi} + \\alpha")
    pos,         // The central position of your Text sent as a new Vector (default (0, 0))
    textSize,    // Size of the text (default 1)
    color,       // Color of the Text (default "white")
    showHitbox   // true : displays hitbox (used for debugging)
  );

Then, just call yourTeXObject.draw() to draw your pSText String to the canvas.


Change Text properties after creation

To change the text, position and color of your pSText object after if it was created, you will need to call the following functions:

  • setText(newTeXString) to change the text
  • setPosition(x, y) to change the x and y coordinates
  • setColor(color) that update the color of your text

Warning: If you don't call these functions and try directly to change for example pSText.text value, you will get an error.


Previous (Custom pSObjects) - Back to wiki home - Next (How animations works)

Clone this wiki locally