[patch] Fix for drawVBL "facing", new drawVBL parameters

Notes on testing the latest builds of MapTool

Moderators: dorpond, trevor, Azhrei

Post Reply
Wyrframe
Cave Troll
Posts: 59
Joined: Sun Apr 14, 2013 7:52 pm

[patch] Fix for drawVBL "facing", new drawVBL parameters

Post by Wyrframe »

Fix:
As of rev.5929, "facing" parameter only worked for positive token facings (as from getTokenFacing())

Patch includes updates to all four draw*VBL functions to use following snippet for rotation calculation.

Code: Select all

if (useFacing) {
    r = -(facing + 90);
}

Improvement:
Added proposed independant Scale X/Y parameters and Translate X/Y parameters. Shapes passed to drawVBL are scaled around the origin (0,0), then rotated around specified point (default: midpoint of bounding rectangle of the shape), then translated by the specified amount. This takes vertex processing out of macro-code, and lets it be handled by MapTool instead.

New parameters for all four shape types are:
  • sx, sy: scales the shape by the specified factor, before any rotation is applied. Scaling is relative to the origin (0,0), not to the rotation center (rx,ry).
  • tx, ty: translates the shape by the specified distance, after any rotation is applied.
Possible issue: for rectangle, cross, and circle shapes, if both "scale" and "sx/sy" parameters are provided, they are cumulative.

If the community thinks sx,sy should scale around the rotation center, I can provide an alternate patch with this functionality.
Attachments
tlaj-20130416-VBL_Functions-patch.txt
(6.52 KiB) Downloaded 99 times

User avatar
Azhrei
Site Admin
Posts: 12086
Joined: Mon Jun 12, 2006 1:20 pm
Location: Tampa, FL

Re: [patch] Fix for drawVBL "facing", new drawVBL parameters

Post by Azhrei »

Wyrframe wrote:Possible issue: for rectangle, cross, and circle shapes, if both "scale" and "sx/sy" parameters are provided, they are cumulative.
How about a check at the top of the function that errors out if both scale and one of {sx,sy} are specified?

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

Re: [patch] Fix for drawVBL "facing", new drawVBL parameters

Post by wolph42 »

Azhrei wrote:
Wyrframe wrote:Possible issue: for rectangle, cross, and circle shapes, if both "scale" and "sx/sy" parameters are provided, they are cumulative.
How about a check at the top of the function that errors out if both scale and one of {sx,sy} are specified?
I *really* prefer continued code flow in this case as Its a LOT easier to program. True its also a LOT more difficult to debug, but in this case the good far outweighs the bad. I can now simply create one BIG json object with all keys and depending on the shape, the function grabs the one it needs. Start to error out on certain key combinations and I'll need to add all kinds of checks.

My favourite solution would be 'override' as is the case with r and facing. IRC 'facing' overrides 'r' when both are used.

Post Reply

Return to “Testing”