-
Notifications
You must be signed in to change notification settings - Fork 4
Writing Text and TeX content
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>
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.
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)
pSEngine - Made by MecanicaScience - Official Website : https://pSEngine.mecanicascience.fr/
If you want to help on this wiki and you don't have access to it, feel free to open a new issue or comment one, while describing which page you would like to edit, and what modifications you want to do.