Change TextPlus color in Lua

Ask software engineering and SDK questions for developers working on Mac OS X, Windows or Linux.
  • Author
  • Message
Offline

mrzinch

  • Posts: 2
  • Joined: Sun May 21, 2023 5:33 am
  • Real Name: Ryan Esch

Change TextPlus color in Lua

PostMon May 22, 2023 7:34 pm

I have created a TextPlus object. I cannot figure out how to change the text color.
Code: Select all
local test = comp:AddTool("TextPlus")
test.StyledText = "Hello"
test.FontSize = 0.05

I have tried many things, eg.
Code: Select all
test.TextProperties = {
    TopLeftRed = 0.192,
    TopLeftGreen = 0.467,
    TopLeftBlue = 0.451
}
test.TextColor  ={ Red = 0.192, Green = 0.467, Blue = 0.451 }
test.Color, etc. etc.


Is it possible?
Offline
User avatar

roger.magnusson

  • Posts: 3384
  • Joined: Wed Sep 23, 2015 4:58 pm

Re: Change TextPlus color in Lua

PostTue May 23, 2023 7:18 pm

Code: Select all
local test = comp:AddTool("TextPlus")
test.StyledText = "Hello"
test.Size = 0.05
test.Red1 = 1
test.Green1 = 1
test.Blue1 = 0.5

If you hover over the GUI elements in the Inspector, you can see the name of the variable you need to use in the status bar in the bottom left of the Fusion window.
Offline

mrzinch

  • Posts: 2
  • Joined: Sun May 21, 2023 5:33 am
  • Real Name: Ryan Esch

Re: Change TextPlus color in Lua

PostWed May 31, 2023 3:41 am

roger.magnusson wrote:
Code: Select all
local test = comp:AddTool("TextPlus")
test.StyledText = "Hello"
test.Size = 0.05
test.Red1 = 1
test.Green1 = 1
test.Blue1 = 0.5

If you hover over the GUI elements in the Inspector, you can see the name of the variable you need to use in the status bar in the bottom left of the Fusion window.


Thank you so much, Roger. That trick works for many fields, but does not work for Color. Hovering over the Color / Color popup does not show anything in the bottom left field.

I have a similar issue. I'd like to move the text. It appears that test.CenterZ is valid, however test.CenterX and test.CenterY are not. That kind of makes sense since the fusion window shows "Center" for both X and Y. However, I do not know what is valid for these.
Offline
User avatar

roger.magnusson

  • Posts: 3384
  • Joined: Wed Sep 23, 2015 4:58 pm

Re: Change TextPlus color in Lua

PostWed May 31, 2023 5:57 pm

Hovering over the fields works for the individual color fields.

Use Center to set X and Y with a Lua table. CenterZ is just a single value.
Code: Select all
Text1.Center = { 0.5, 0.2 }
Text1.CenterZ = 1

Note that you can also specify which frame you want to change by indexing the property.
Code: Select all
Text1.Center[0] = { 0.5, 0.2 }
Text1.CenterZ[0] = 1

Return to Software Developers

Who is online

Users browsing this forum: No registered users and 10 guests