PennController for IBEX › Forums › Support › Using .before/.after on Canvas › Reply To: Using .before/.after on Canvas
March 6, 2023 at 8:55 am
#9984
Keymaster
Hello,
You can use .before and .after on any element, including Canvas elements themselves or Text elements that you print on a Canvas element. For example, you can do that:
newText("subject", "I "),
newText("verb", "print "),
newText("word", "words "),
newText("ending", "on a line")
,
getText("subject").after(getText("verb").after(getText("word").after(getText("ending")))).print()
Or alternative you could print the next Text elements inside the first one, making sure they all appear as a horizontal sequence (css command):
newText("subject", "I ").css("display", "flex").print(),
newText("verb", "print ").print(getText("subject")),
newText("word", "words ").print(getText("subject")),
newText("ending", "on a line").print(getText("subject"))
Jeremy