a fresh start

Screen shot 2014-09-11 at 02.56.12  Screen shot 2014-09-11 at 11.50.53

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.

 

sixteen squares

Screen shot 2014-09-02 at 21.48.43  Screen shot 2014-09-03 at 12.38.44

Both images, which are repeatable, are generated using a different seed value.

The code uses the NodeBox builtin random  command together with seed and randint from the Python random module. There are numerous calls to random in this script:

The first call is to the NodeBox builtin, using integer arguments 0, 1 to return a value used as a boolean flag.  This is used to turn of the draw mode in those instances where the random call returns a ‘0’ (zero).

The next random call is made to the Python module randint, which returns an integer value between 115 and 195 and which is used to define the size of the squares.

The next call, returns an integer value between -5 and +5. This value is used to rotate each of the squares about its centre.

A last call is made to return a values between 0.55 and 0.6. This value is used to define the hue argument in the fill colour tuple argument.

An earlier example (not shown) includes an if construct to further filter some square, but here the boolean switch is sufficient to render some, but not all colour fills.

 

 

broken hachure

Screen shot 2014-09-02 at 09.58.54  Screen shot 2014-09-02 at 09.59.02

In this first hachure test, we began by positioning the canvas origin to the canvas centre. We then drew 100 vertical lines of random length, but not longer than 300 px using a for loop. To apply rotation, requires setting the transform mode to CORNER. However, when we come to place the randomised hachure inside a clip path, the required transform mode is CENTER.

Screen shot 2014-09-02 at 10.11.41  Screen shot 2014-09-02 at 10.11.51

There are two approaches shown, above left describes individual hachures for the top left and centre square shapes, whereas, above right describes uses a clip path (inside a for loop) together with a single hachure, large enough to fill the whole canvas surface.