Ripples

Ripples is what I call the brownish graphics pattern seen at the head of this blog. The Ripples graphic is based on the formula for a circle (z = y2 + x2). The actual formula is:

IntegerResult = (OffSetY + (Y * Param1)2) + (OffSetX + (X * Param1)2)

where X and Y are pixel coordinates. Param1 has a value of 1 so that we get a circular (not an oval) pattern. OffSetY and OffSetX are the number of pixels to shift the pattern (not the whole picture) horizontally and vertically. OffSetY and OffSetX are both zero in this case. Each pixel is calculated one at a time, left to right, top to bottom.  Given the default values for OffSetX, OffSetY, and Param1, we can rewrite the formula as:

IntegerResult = Y2 + X2

So the only purpose of the formula is to determine if a given X,Y pixel gets a color and, if so, what that color it will be. The modulo value of IntegerResult determines the color of the pixel at coordinates X,Y like this: Each pixel color is assigned for prime numbers 2, 3, 5 etc, whichever is first evenly divisible into the IntegerResult. In this case, if IntegerResult is divisible by 2 then the current X,Y pixel is assigned the color black. If the IntegerResult is divisible by 3 (but not 2)  then the current X,Y pixel is assigned the color brown. If the IntegerResult is divisible by 5 (but not 2 or 3) then the current X,Y pixel is assigned the color dark green. If the IntegerResult is not evenly divisible by 2, 3, or 5 then the X,Y pixel is assigned the background color, which in this case is a brick red.

Leave a Reply

Your email address will not be published. Required fields are marked *