Determining the center of a token

Discuss macro implementations, ask for macro help (to share your creations, see User Creations, probably either Campaign Frameworks or Drop-in Resources).

Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice

Post Reply
xavram
Dragon
Posts: 891
Joined: Tue Apr 20, 2010 8:22 pm

Determining the center of a token

Post by xavram »

Well, I thought I could find the center of my token (which is 75 wide by 150 tall) by simply doing...

[h: centerX = getTokenX(1,selectedToken)+(37.5)]
[h: centerY = getTokenY(1,selectedToken)+(75)]


However, if I'm finding that, based on the rotation of the token, this doesn't return the same coordinates each time!

Is there an easy way to determine this, without busting out the sin and cos functions?

xavram
Dragon
Posts: 891
Joined: Tue Apr 20, 2010 8:22 pm

Re: Determining the center of a token

Post by xavram »

Ignore this...something else was throwing my math off...long day.

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Determining the center of a token

Post by wolph42 »

suggestion:

Code: Select all

[h,token(selectedToken): centerX = (getTokenX(1)+getTokenWidth())/2]
[h,token(selectedToken): centerY = (getTokenY(1)+getTokenHeight())/2]
 

xavram
Dragon
Posts: 891
Joined: Tue Apr 20, 2010 8:22 pm

Re: Determining the center of a token

Post by xavram »

I actually call the getWidth/Height earlier in the macro, my sample was just to simplify.

Is there some performance gain from the syntax you use?


Post Reply

Return to “Macros”