how to handle Trinocular operator?
weituotian opened this issue · 6 comments
hi, i meet som problem in translate Trinocular operator.
offsetPoint.x > 0 && 0 === offsetPoint.y ? a = 0 : 0 === offsetPoint.x && offsetPoint.y < 0 ? a = 270 : offsetPoint.x < 0 && 0 === offsetPoint.y ? a = 180 : offsetPoint.x < 0 && offsetPoint.y < 0 ? a = 180 + r : offsetPoint.x < 0 && offsetPoint.y > 0 ? a = 180 - r : offsetPoint.x > 0 && offsetPoint.y > 0 ? a = r : offsetPoint.x > 0 && offsetPoint.y < 0 && (a = 360 - r)
what i want is
if (0 === offsetPoint.x && offsetPoint.y > 0) {
let a = 90;
} else {
if (offsetPoint.x > 0 && 0 === offsetPoint.y) {
a = 0;
} else {
if (0 === offsetPoint.x && offsetPoint.y < 0) {
a = 270;
} else {
if (offsetPoint.x < 0 && 0 === offsetPoint.y) {
a = 180;
} else {
if (offsetPoint.x < 0 && offsetPoint.y < 0) {
a = 180 + r;
} else {
if (offsetPoint.x < 0 && offsetPoint.y > 0) {
a = 180 - r
} else {
if (offsetPoint.x > 0 && offsetPoint.y > 0) {
a = r;
} else {
if (offsetPoint.x > 0 && offsetPoint.y < 0) {
a = 360 - r
}
}
}
}
}
}
}
}
or
if (0 === offsetPoint.x && offsetPoint.y > 0) {
let a = 90;
} else if (offsetPoint.x > 0 && 0 === offsetPoint.y) {
a = 0;
} else if (0 === offsetPoint.x && offsetPoint.y < 0) {
a = 270;
} else if (offsetPoint.x < 0 && 0 === offsetPoint.y) {
a = 180;
} else if (offsetPoint.x < 0 && offsetPoint.y < 0) {
a = 180 + r;
} else if (offsetPoint.x < 0 && offsetPoint.y > 0) {
a = 180 - r
} else if (offsetPoint.x > 0 && offsetPoint.y > 0) {
a = r;
} else if (offsetPoint.x > 0 && offsetPoint.y < 0) {
a = 360 - r
}
it may so hard to make this, but it is helpful to debundle js. thanks!
Thanks
There is a caveat here:
JStillery should be able to understand the difference between your construct and:
a=(c?b:e);
or similar but more complex situations.
In fact it would become:
a = if (c)
b
else
e;
which is obviously incorrect.
That is why I didn't add it yet.
Any idea? Willing to help?
I can quickly fixed it at its simplest form by checking if the parent node is an ExpressionStatement
Reopening it just in case there's a better and more insightful idea :)
I had the same problem writing my Adobe After Effects script.
This could potentially be done with the proposed do
expression. Although that won't be available in a long time, if at all.