```
1 // pentaflake.pde
2
```**float** X1 **=** 0.125*******sqrt**(10 **+** 2*******sqrt**(5));
3 **float** X2 **=** 0.125*******sqrt**(10 **-** 2*******sqrt**(5));
4 **float** Y1 **=** 0.125*****(**sqrt**(5) **-** 1);
5 **float** Y2 **=** 0.125*****(**sqrt**(5) **+** 1);
6 **float** REDUCE **=** 0.385;
7 **void** **setup**()**{**
8 **size**(500, 500);
9 **smooth**();
10 **fill**(255);
11 **background**(0);
12 **noStroke**();
13 drawPentaflake(width**/**2, height*****0.55, height*****0.55);
14 **}**
15
16 **void** drawPentaflake(**float** cx, **float** cy, **float** sz)**{**
17 if (sz **<** 6)
18 **{**
19 drawPentagon(cx, cy, sz);
20 **noLoop**();
21 **}**
22 **else****{**
23 **float** x0 **=** cx;
24 **float** y0 **=** cy **-** (0.5 ***** sz);
25 **float** x1 **=** cx **-** (X1 ***** sz);
26 **float** y1 **=** cy **-**(Y1 *****sz);
27 **float** x2 **=** cx **-** (X2 ***** sz);
28 **float** y2 **=** cy **+** (Y2 ***** sz);
29 **float** x3 **=** cx **+** (X2 ***** sz);
30 **float** y3 **=** cy **+** (Y2 ***** sz);
31 **float** x4 **=** cx **+** (X1 ***** sz);
32 **float** y4 **=** cy **-** (Y1 ***** sz);
33 drawPentaflake(x0, y0, sz*****REDUCE);
34 drawPentaflake(x1, y1, sz*****REDUCE);
35 drawPentaflake(x2, y2, sz*****REDUCE);
36 drawPentaflake(x3, y3, sz*****REDUCE);
37 drawPentaflake(x4, y4, sz*****REDUCE);
38 **}**
39 **}**
40
41 **void** drawPentagon(**float** cx, **float** cy, **float** sz)**{**
42 **beginShape**();
43 **vertex**(cx, cy **-** (0.5 ***** sz));
44 **vertex**(cx **-** (X1 ***** sz),cy **-**(Y1 *****sz));
45 **vertex**(cx **-** (X2 ***** sz), cy **+** (Y2 ***** sz));
46 **vertex**(cx **+** (X2 ***** sz), cy **+** (Y2 ***** sz));
47 **vertex**(cx **+** (X1 ***** sz), cy **-** (Y1 ***** sz));
48 **endShape**(CLOSE);
49 **}**

## Wednesday, 16 September 2009

### Pentaflake Implemented in Processing

Labels:
java processing,
pentaflake,
pentagon

Subscribe to:
Post Comments (Atom)

## Blog Archive

- June (1)
- May (1)
- April (1)
- January (1)
- June (1)
- February (1)
- October (1)
- August (2)
- July (1)
- May (1)
- April (1)
- March (1)
- February (1)
- December (2)
- November (7)
- October (8)
- September (2)
- August (3)
- July (2)
- June (7)
- May (7)
- April (8)
- March (4)
- February (1)
- January (8)
- December (5)
- November (3)
- October (2)
- September (2)
- August (4)
- July (4)
- June (12)
- May (8)
- April (10)
- March (7)
- February (9)
- January (17)
- December (13)
- November (11)
- October (2)
- September (5)
- August (3)
- July (2)
- June (5)
- May (6)
- February (5)
- January (8)
- December (7)
- November (6)
- October (17)
- September (12)
- August (12)
- July (6)
- June (19)
- May (4)
- March (4)
- February (3)
- January (7)
- December (4)
- November (16)
- October (1)

## About Me

- monkstone
- Pembrokeshire, United Kingdom
- I have developed JRubyArt and propane new versions of ruby-processing for JRuby-9.1.5.0 and processing-3.2.2

## No comments:

## Post a Comment