A Penrose Tiling
Playing with scripting of the drawing app Intaglio, I made
this nice
picture:
For
the curious, here's a script that will generate a similar
tiling
property
magicRatio
: (1 + (5 ^ 0.5)) / 2
property
invMagicRatio
: 2 / (1 + (5 ^ 0.5))
property
sinPiOverFive
: 0.587785252
property
sinTwoPiOverFive
: 0.951056516
property
cosTwoPiOverFive
: 0.309016994
property
cosPiOverFive
: 0.809016994
to
drawATriangle(pt1,
pt2,
pt3,
width,
fc)
tell
application
"Intaglio"
make
new
path
with
properties
{segments:{move
to,
{x
of
pt1,
y
of
pt1},
line to,
{x
of
pt2,
y
of
pt2},
line to,
{x
of
pt3,
y
of
pt3},
line to,
{x
of
pt1,
y
of
pt1}},
drawing
mode:fill,
stroke
width:2,
fill
color:rgb
& fc,
stroke
color:{rgb,
0.2, 0.2, 1, 0.4}}
end
tell
end
drawATriangle
to
subdivideB(pt1,
pt2,
pt3,
numSubdivisions)
set
delX
to
(x
of
pt3) -
(x
of
pt1)
set
delY
to
(y
of
pt3) -
(y
of
pt1)
set
pt4
to
{x:(x
of
pt3) -
delX *
invMagicRatio,
y:(y
of
pt3) -
delY *
invMagicRatio}
if
numSubdivisions
is
less
than 5
then
set
alpha
to
0.9 -
((numSubdivisions)
* 0.2)
drawATriangle(pt1,
pt2,
pt3,
numSubdivisions,
{0.3, 1, 0.4,
alpha})
-- change the colors here !!
end
if
if
(numSubdivisions
> 1) then
subdivideA(pt2,
pt3,
pt4,
numSubdivisions
- 1)
end
if
if
(numSubdivisions
> 2) then
subdivideB(pt2,
pt4,
pt1,
numSubdivisions
- 2)
end
if
end
subdivideB
to
subdivideA(pt1,
pt2,
pt3,
numSubdivisions)
set
delX
to
(x
of
pt2) -
(x
of
pt1)
set
delY
to
(y
of
pt2) -
(y
of
pt1)
set
pt4
to
{x:(x
of
pt2) -
delX *
invMagicRatio,
y:(y
of
pt2) -
delY *
invMagicRatio}
if
numSubdivisions
is
less
than 5
then
set
alpha
to
0.9 -
((numSubdivisions)
* 0.2)
drawATriangle(pt1,
pt2,
pt3,
numSubdivisions,
{0, 0.4, 1,
alpha})
-- change the colors here !!
end
if
if
(numSubdivisions
> 2) then
subdivideA(pt4,
pt3,
pt1,
numSubdivisions
- 2)
end
if
if
(numSubdivisions
> 1) then
subdivideB(pt2,
pt4,
pt3,
numSubdivisions
- 1)
end
if
end
subdivideA
set
centerX
to
280
set
centerY
to
350
set
len
to
280
-- ptList is the ten outside points of the decagon,
with the first one repeated at the end
set
ptList
to
{{x:len,
y:0},
{x:len
*
cosPiOverFive,
y:len
*
sinPiOverFive},
{x:len
*
cosTwoPiOverFive,
y:len
*
sinTwoPiOverFive},
{x:-len
*
cosTwoPiOverFive,
y:len
*
sinTwoPiOverFive},
{x:-len
*
cosPiOverFive,
y:len
*
sinPiOverFive},
{x:-len,
y:0},
{x:-len
*
cosPiOverFive,
y:-len
*
sinPiOverFive},
{x:-len
*
cosTwoPiOverFive,
y:-len
*
sinTwoPiOverFive},
{x:len
*
cosTwoPiOverFive,
y:-len
*
sinTwoPiOverFive},
{x:len
*
cosPiOverFive,
y:-len
*
sinPiOverFive},
{x:len,
y:0}}
set
a
to
1
repeat
5 times
set
pt1
to
{x:centerX,
y:centerY}
set
pt2
to
{x:centerX
+ (x
of
item
a
of
ptList),
y:centerY
+ (y
of
item
a
of
ptList)}
set
a
to
a +
1
set
pt3
to
{x:centerX
+ (x
of
item
a
of
ptList),
y:centerY
+ (y
of
item
a
of
ptList)}
subdivideA(pt3,
pt1,
pt2,
8)
set
a
to
a +
1
set
pt2
to
{x:centerX
+ (x
of
item
a
of
ptList),
y:centerY
+ (y
of
item
a
of
ptList)}
subdivideA(pt3,
pt1,
pt2,
8)
end
repeat
Posted: Sun - July 22, 2007 at 08:29 PM