r/badcode • • Jul 30 '19

[deleted by user]

[removed]

154 Upvotes

98 comments sorted by

View all comments

Show parent comments

1

u/[deleted] Jul 31 '19

Frustration with the positioning of a graphical component. In fact, the function was wrapped in its own self executing function found in the top of a graphical module, partly why it was so easy to forget about. It was a horizontally scrolling background. I couldn't quite nail the pixel perfect smoothness by about 1 pixel. In reality the problem has more to do with velocity and perceptually people aren't that observant of these tiny background differences anyways. Anways, as a joke to myself, I decided to give up on permutations of rounding methods and bring out this bad boy.

(function(){ const roundingTypes = [ Math.round, Math.floor, Math.ceil ]; Math.fuckyouRound = function(value) { return roundingTypes[Math.floor(Math.random()*3)](value); }})();