Simplest way to translate points in script?

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Fahim, Distinct Sun, Víctor Paredes, erey, Belgarath, slowtiger

Post Reply
User avatar
Posts: 443
Joined: Sat Mar 07, 2015 5:14 pm

Simplest way to translate points in script?

Post by strider2000 » Sat Jul 25, 2015 9:03 am

Just wanting to check if I'm on the right track or if people had a better suggestion.

I'm wanting to create some scripts for Kinetic Typography. It seems that most of the text based scripts I've seen create a layer for each word or even letter. I'm not wanting to do that for 2 reasons:
1) If I have even several paragraphs of text, it seems like it would be overkill to have a layer per word (maybe that's fine, but it just seems like a lot)
2) In animating or positioning the words, it seems easiest to use the transform point tool and drag different words into position on a single layer, rather than having to select a layer for each word, then move the layer

Right now I'm just reading a text file and inserting words as single shapes (ie 1 shape per word) on a layer. I'm wanting to initially position the words like a sentence. I expect I'll need to select the shape by id, then select all the points on a shape and move the points, like below. I know the code works (tested it already), but I was wondering if there's a better way to move a "shape" (Am I reinventing the wheel?)

Code: Select all

function msPlaypen:MoveShape(mesh, x,y)
    local selList = MOHO.SelectedPointList(mesh)
	local v = LM.Vector2:new_local()

	for i, pt in ipairs(selList) do
		pt.fAnimPos:SetValue(0, pt.fPos + v)
Thanks for any suggestions.
My new website (just getting started) | M1 Characters for Moho
Post Reply