-
Can I simplify this expression?
Hi!
Ok, I connected my Source Text to my Text scale.To the scale, I applied this:
x = Math.abs(Math.sin(time)*100);
y = 100;
[x, y]Until here, no problem.
But my source text had a lot of numbers after the dot, like: 84,14709848…So I applied Math.round(transform.scale[0]) to round it.
But I wanted to simplify to 84,1 (84,14709848…) and not to 84 (example).
So I did this:
scale = transform.scale[0];
round = Math.round(scale);
d = (scale – round)*10;
dII = .1*Math.round (d);
fin = round + dII;fin
So, scale was the scale of my layer, and in “round” I rounded it (example: 84,14709848 to 84). In “d” I simply subtract scale and round (84,14709848… – 84 = 0,14709848…), to leave only the numbers after the decimal point and I multiplied them by 10 to give them and integer number (so 0,14709848… became 1,4709848…). In “dII” I round my 1,4709848… to 1 and I divided it by 10 (multiply by 0.1) so it became 0.1. So in “fin” I did the round (value in integers) plus the dII (the number with one number after the decimal point) to round 84,14709848 to 84,1.
And to round 84,14709848 to 84,14 I used this:
scale = transform.scale[0];
scale2 = scale*10
round = Math.round(scale2);
d = (scale2 – round)*10;
dII = .1*Math.round (d);
fin = (round + dII)*.1;fin
So, I have and impression that I can simplify this a lot. Is it possible or am I crazy?
Thank you,
Gustavo.