Copy link to clipboard
Copied
In the following javascript code snippet, I am getting the negative of the desired result. In other words, the results in the alert are selCenterX - 3000. and selCenterY - 3000.
alert(selCenterX,selCenterY);
var distancetoMidpointX = (3000. - selCenterX);
var distancetoMidpointY = (3000. - selCenterY);
alert(distancetoMidpointX,distancetoMidpointY);
Something simple I am sure. Please help.
I can't check right now, but maybe the problem is that you don't specify the units for halfCanvas (your selCenterX and selCenterX are both have type 'px'), those something like:
halfCanvas = new UnitValue( "3000 pixels" )
Copy link to clipboard
Copied
You seem to be using a comma in the alert where it does not quite belong.
Try
alert(distancetoMidpointX+","+distancetoMidpointY);
instead
Copy link to clipboard
Copied
Here is the latest code. Still the same problem - the result is the negative of the correct answer.
alert(selCenterX+","+selCenterY);
var halfCanvas = 3000.
var distancetoMidpointX = (halfCanvas - selCenterX); // assumes a 6k by 6k canvas
var distancetoMidpointY = (halfCanvas - selCenterY);
alert(distancetoMidpointX+","+distancetoMidpointY);
Copy link to clipboard
Copied
This is what the alerts return:
Copy link to clipboard
Copied
I can't check right now, but maybe the problem is that you don't specify the units for halfCanvas (your selCenterX and selCenterX are both have type 'px'), those something like:
halfCanvas = new UnitValue( "3000 pixels" )
Copy link to clipboard
Copied
Excellent. I would never have found this on my own. The solution was not simple to a novice.
Thank you again.
Copy link to clipboard
Copied
I cannot reproduce the issue, please post the code properly.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now