I am trying to create a stripe pattern in javascript (p5.js), where the odd stripes are one width and the even are another. If they were the same width, my code to create the pattern would be as follows: but if I were to introduce a barSize1 and barSize2 to create an alternating pattern of bars of different heights (say
Tag: modulo
JavaScript % (modulo) gives a negative result for negative numbers
According to Google Calculator (-13) % 64 is 51. According to Javascript (see this JSBin) it is -13. How do I fix this? Answer Taken from this article: The JavaScript Modulo Bug