We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello,
I would like to make a variable go up to a max number by a certain increment each time and then make it go back down to 0 by the same increment, and repeat. variable % maxNumber just floors the number at 0. I would like the number to be maxNumber - (variable % maxNumber) after variable > maxNumber until variable > maxNumber * 2, then I just want variable to be floored again to start the process over. I could use a "sin" function, but I don't like the way it curves. I also would rather not use "if" or "while" statements because it feels like cheating. I'm complicating this too much in my head, does anybody know how to do this?
Any help would be appreciated, thanks!
-Gav
Answers
Hey, thanks for the answer! I seem to have miscommunicated my question. That code you gave me floors the number at 0 every time it hits 256. Is there a way to make the number start descending once it gets to the max instead of flooring it?
Does it have to be completely logic free? GoToLoop's example uses the ternary conditional operator, which acts like a mini if statement for assigning a value to a variable, which is good but may be what you were asking not to include.
Damnit. I give up.
Here's my implementation using cosine :P I know you didn't want to use it so I'll think of something else. Perhaps some Calculus could get this done?
branchless fx
Holy jesus nice example T_D!
... I hope we can all appreciate if statements a little bit more.
2
&3
.2
is bilinear and3
is bicubic smoothing.3
, which is the best smoothing algorithm for the default renderer JAVA2D, is already the default smoothing value btW. :>A more generic version that works for floats and negative values too.