The image above left, is not a rectangular grid arrangement of coloured dots that has been rotated 45º. I tried that approach, and there were inherent issues when trying to align the two grid patterns, not least because the same interval value is used in the for loop constructs, which is of an integer type.
The arrangement (above left) uses a for loop, embedded inside another for loop, with two if constructs, and modulo division, (no rotation!).
In the image above right, the arrangement of coloured dots have been rotated 45º. Otherwise, the code is identical for both. Both use CORNER transform mode, and canvas origin translation to the window’s centre, and variables for number, size, and x, y offsets. Number determines the dot frequency. Both number and size are passed as arguments to the dot (basic shape) primitive, which in this example draws a circle, with its centre represented by x, y values, and size as its diameter.This is not the standard NodeBox primitive used to draw circles.
The dot frequency range extends to double the canvas dimensions. This, together with the transform mode and translation was done to facilitate rotation of the coloured dot arrangement. In this example the dot pattern is rendered using a clip path.
TODO – Create x and y variables for frequency values. Further consider use of range function in for loops – is there an simpler alternative, do I need canvas rotation? Consider primitive object library, and issues for rotation of primitives called from library that rely on rect basic shape element (see post ‘back on track’).
Squares and circles take a single argument for their dimension, whereas rectangles and ellipses require two. If I use a path to define the rectangle or square, there are different code requirements for passing fill and stroke attributes vias the function call.