` 1 `**startshape **test
2
3 **background**{**b** **-**1**}**
4
5 **rule** test{
6 **CIRCLE**{**s** 1 **b** 1 **hue** 360 **sat** 1**}**
7 hexagon{**}**
8 **}**
9
10 **path** hexagon{
11 **MOVETO**{**x** .25 **y** (**sqrt**(3)/4)**}**
12 **LINETO**{**x** .5 **y** 0**}**
13 **LINETO**{**x** .25 **y** (**-****sqrt**(3)/4)**}**
14 **LINETO**{**x** **-**.25 **y** (**-****sqrt**(3)/4)**}**
15 **LINETO**{**x** **-**.5 **y** 0**}**
16 **LINETO**{**x** **-**.25 **y** (**sqrt**(3)/4)**}**
17 **CLOSEPOLY**{**}**
18 **STROKE**{**width** 0.01 **b** **-**1**}**
19 **FILL**{**b** .8 **h** 60 **sat** 1**}**
20 **}**

The use of expressions in the path allow us to define the points of the regular polygon on the unit circle, a further benefit of using path (you can achieve similar result using rule is the ability close the polygon, set the fill/stroke and decide how to join points

*bevel/roundjoin/miterjoin*.

Using the above path for a hexagon (not repeated below) you can create more complex patterns with tiling (the simplest here is just edge to edge, I also intend to try linking squares/triangle)

` 1 `**startshape **tiled
2 **tile** {**s** 20 (10*******sqrt**(3))**}**
3 **background**{**b** **-**.5**}**
4
5 **rule** tiled{
6 20*****{**x** 1**}**{
7 20*****{**y** (**sqrt**(3)/2)**}**{
8 hextile{**}**
9 **}**
10 **}**
11 **}**
12
13 **rule** hextile 1 {
14 hexagon{**h** 220**}**
15 **}**
16
17 **rule** hextile 3 {
18 hexagon{**h** 360**}**
19 **}**
20
21 **rule** hextile 6 {
22 hexagon{**h** 60**}**
23 **}**

** **

** **

In this case there is 10% probability of a blue hexagon, a 30% probability of a red hexagon and a 60% probability of a yellow hexagon (the numbers after the rule name give the probability weighting).

For a neater packing we need to create some new rules:-

` 1 `**startshape **tiled
2
3 **background**{**b** **-**.5**}**
4 **rule** tiled{
5 15*****{**y** (**sqrt**(3)/2)**}**{
6 10*****{**x** 1.5**}**{
7 hextile{**}**
8 hextile{**x** 1.5**}**
9 **}**
10 **}**
11 **}**
12
13 **rule** hextile {
14 hex{**}**
15 hex{**x** .75 **y** (**sqrt**(3)/4)**}**
16 **}**
17
18 **rule** hex{
19 hexagon{**h** 60**}**
20 **}**
21 **rule** hex{
22 hexagon{**h** 220**}**
23 **}**
24 **rule** hex{
25 hexagon{**h** 360**}**
26 **}**

NB: I have omitted hexagon path which remains the same.

## No comments:

## Post a Comment