Skip to content

Instantly share code, notes, and snippets.

@monsieuroeuf
Created March 24, 2023 01:18
Show Gist options
  • Save monsieuroeuf/6a0593ea51916a03530587d4d3904e7c to your computer and use it in GitHub Desktop.
Save monsieuroeuf/6a0593ea51916a03530587d4d3904e7c to your computer and use it in GitHub Desktop.
Change the position of a Text+ node in Fusion depending on the comp's aspect ratio
:local w = tonumber( comp:GetPrefs("Comp.FrameFormat.Width"))
local h = tonumber(comp:GetPrefs("Comp.FrameFormat.Height"))
-- add the colon at the start of first line to allow multiline expression
if (w / h) > 1 then return Point(0.0, 0.0)
elseif (w / h) < 1 then return Point(0.5, 0.5)
else return Point(1, 1)
end
@monsieuroeuf
Copy link
Author

Copy and paste this straight into Fusion to see it in action.

{
	Tools = ordered() {
		Text1_1 = TextPlus {
			CtrlWZoom = false,
			Inputs = {
				GlobalOut = Input { Value = 74, },
				Width = Input { Value = 1080, },
				Height = Input { Value = 1080, },
				UseFrameFormatSettings = Input { Value = 1, },
				["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
				Center = Input {
					Value = { 1, 1 },
					Expression = ":local w = tonumber( comp:GetPrefs(\"Comp.FrameFormat.Width\"))\nlocal h = tonumber(comp:GetPrefs(\"Comp.FrameFormat.Height\"))\n-- print(\"w / h \" .. w / h);\nif (w / h) > 1 then return Point(0.0, 0.0)\n	elseif (w / h) < 1 then return Point(0.5, 0.5)\n	else return Point(1, 1)\nend",
				},
				LayoutRotation = Input { Value = 1, },
				TransformRotation = Input { Value = 1, },
				Softness1 = Input { Value = 1, },
				StyledText = Input { Value = "wow", },
				Font = Input { Value = "Open Sans", },
				Style = Input { Value = "Bold", },
				VerticalJustificationNew = Input { Value = 3, },
				HorizontalJustificationNew = Input { Value = 3, },
			},
			ViewInfo = OperatorInfo { Pos = { 0, 82.5 } },
		}
	},
	ActiveTool = "Text1_1"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment