<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wikidot="http://www.wikidot.com/rss-namespace">

	<channel>
		<title>Penrose tilings</title>
		<link>http://kogics.wikidot.com/forum/t-14392493/penrose-tilings</link>
		<description>Posts in the discussion thread &quot;Penrose tilings&quot;</description>
				<copyright></copyright>
		<lastBuildDate>Sun, 19 Jul 2026 22:29:46 +0000</lastBuildDate>
		
					<item>
				<guid>http://kogics.wikidot.com/forum/t-14392493#post-5228475</guid>
				<title>(no title)</title>
				<link>http://kogics.wikidot.com/forum/t-14392493/penrose-tilings#post-5228475</link>
				<description></description>
				<pubDate>Fri, 11 Mar 2022 05:11:51 +0000</pubDate>
				<wikidot:authorName>Kevin</wikidot:authorName>								<content:encoded>
					<![CDATA[
						 <p>Nice work!</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://kogics.wikidot.com/forum/t-14392493#post-5163672</guid>
				<title>(no title)</title>
				<link>http://kogics.wikidot.com/forum/t-14392493/penrose-tilings#post-5163672</link>
				<description></description>
				<pubDate>Sat, 25 Dec 2021 03:40:51 +0000</pubDate>
				<wikidot:authorName>Joost Winter</wikidot:authorName>								<content:encoded>
					<![CDATA[
						 <p>After the P1 and P3 tilings, I now also have a program for P2 tilings, that is, the kite and dart type. This little program draws them together in a sun pattern (which is composed of five darts).</p> <p>I hope this code here will be a bit easier on the eye. :) I also added some comments to make it more readable.</p> <div class="code"> <pre><code>/* Penrose tilings of the P2 type. There are two functions in this program that call themselves and each other recursively: halfKite and halfDart. Note that each function draws an equilateral triangle from the top, and that both functions always exit with the turtle having the same heading as when they entered. */ val Phi = (1 + math.sqrt(5)) / 2 // The golden ratio var kiteColor = green var dartColor = blue def halfKite(depth: Int, length: Double, mirrored: Int): Unit = { if(depth == 0) { // Base case: setFillColor(kiteColor) right(mirrored * 162) forward(length) right(mirrored * 108) forward(length / Phi) right(mirrored * 108) hop(length) left(mirrored * 18) } else { // Recursive case: we draw a half kite by means of // drawing two smaller half kites and a half dart. // // Move the turtle to the right position for the // half dart... right(mirrored * 162) hop(length / (Phi + 1)) left(mirrored * 54) // And draw it! halfDart(depth - 1, length / (Phi + 1), mirrored) right(mirrored * 54) hop(length / Phi) left(mirrored * 54) halfKite(depth - 1, length / Phi, mirrored) right(mirrored * 36) // Note that this half kite is mirrored with // respect to the larger one it is a part of. halfKite(depth - 1, length / Phi, -mirrored) left(mirrored * 162) hop(length) right(mirrored * 18) } } def halfDart(depth: Int, length: Double, mirrored: Int): Unit = { // As in the case of the half kite, we again // distinguish between a base case and a recursive // case. The recursive half dart is composed of one // half kite (mirrored) and a half dart (not mirrored). if(depth == 0) { setFillColor(dartColor) right(mirrored * 126) forward(length) right(mirrored * 144) forward(length * Phi) right(mirrored * 144) hop(length) left(mirrored * 54) } else { left(mirrored * 126) hop(length) right(mirrored * 18) halfKite(depth - 1, length, -mirrored) left(mirrored * 162) hop(length) right(mirrored * 126) halfDart(depth - 1, length / Phi, mirrored) right(mirrored * 126) hop(length / Phi) right(mirrored * 18) } } // The sun pattern can be drawn by drawing 10 half kites, // half of which are mirrored. def sun(depth: Int, length: Double): Unit = { repeat(5) { halfKite(depth, length, -1) right(36) halfKite(depth, length, 1) right(36) } } // Some scripting to call the sun function six times, // with a depth ranging from 1 to 6. // // After each call, a spin is given to the color of // both kite and dart. toggleFullScreenCanvas() repeatFor(1 to 6) { i =&gt; cleari() setBackground(black) setPenColor(black) setPenThickness(6 - i) setSpeed(superFast) right(18) sun(i, 300) kiteColor = kiteColor.spin(60) dartColor = dartColor.spin(60) Thread.sleep(2500) } toggleFullScreenCanvas()</code></pre></div> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://kogics.wikidot.com/forum/t-14392493#post-5163671</guid>
				<title>(no title)</title>
				<link>http://kogics.wikidot.com/forum/t-14392493/penrose-tilings#post-5163671</link>
				<description></description>
				<pubDate>Sat, 25 Dec 2021 03:38:22 +0000</pubDate>
				<wikidot:authorName>Joost Winter</wikidot:authorName>								<content:encoded>
					<![CDATA[
						 <p>After the P1 and P3 tilings, I have now also coded the P2 tilings, the kite and dart type.</p> <p>I think the program below should be easy to understand, well, at least considering that Penrose tilings are not the simplest recursive programs imaginable. But Kojo allows for doing this in a way that it is, algorithmically, completely transparent without the code 'getting in the way' at all.</p> <div class="code"> <pre><code>/* Penrose tilings of the P2 type. There are two functions in this program that call themselves and each other recursively: halfKite and halfDart. Note that each function draws an equilateral triangle from the top, and that both functions always exit with the turtle having the same heading as when they entered. */ val Phi = (1 + math.sqrt(5)) / 2 // The golden ratio var kiteColor = green var dartColor = blue def halfKite(depth: Int, length: Double, mirrored: Int): Unit = { if(depth == 0) { // Base case: setFillColor(kiteColor) right(mirrored * 162) forward(length) right(mirrored * 108) forward(length / Phi) right(mirrored * 108) hop(length) left(mirrored * 18) } else { // Recursive case: we draw a half kite by means of // drawing two smaller half kites and a half dart. // // Move the turtle to the right position for the // half dart... right(mirrored * 162) hop(length / (Phi + 1)) left(mirrored * 54) // And draw it! halfDart(depth - 1, length / (Phi + 1), mirrored) right(mirrored * 54) hop(length / Phi) left(mirrored * 54) halfKite(depth - 1, length / Phi, mirrored) right(mirrored * 36) // Note that this half kite is mirrored with // respect to the larger one it is a part of. halfKite(depth - 1, length / Phi, -mirrored) left(mirrored * 162) hop(length) right(mirrored * 18) } } def halfDart(depth: Int, length: Double, mirrored: Int): Unit = { // As in the case of the half kite, we again // distinguish between a base case and a recursive // case. The recursive half dart is composed of one // half kite (mirrored) and a half dart (not mirrored). if(depth == 0) { setFillColor(dartColor) right(mirrored * 126) forward(length) right(mirrored * 144) forward(length * Phi) right(mirrored * 144) hop(length) left(mirrored * 54) } else { left(mirrored * 126) hop(length) right(mirrored * 18) halfKite(depth - 1, length, -mirrored) left(mirrored * 162) hop(length) right(mirrored * 126) halfDart(depth - 1, length / Phi, mirrored) right(mirrored * 126) hop(length / Phi) right(mirrored * 18) } } // The sun pattern can be drawn by drawing 10 half kites, // half of which are mirrored. def sun(depth: Int, length: Double): Unit = { repeat(5) { halfKite(depth, length, -1) right(36) halfKite(depth, length, 1) right(36) } } // Some scripting to call the sun function six times, // with a depth ranging from 1 to 6. // // After each call, a spin is given to the color of // both kite and dart. toggleFullScreenCanvas() repeatFor(1 to 6) { i =&gt; cleari() setBackground(black) setPenColor(black) setPenThickness(6 - i) setSpeed(superFast) right(18) sun(i, 300) kiteColor = kiteColor.spin(60) dartColor = dartColor.spin(60) Thread.sleep(2500) } toggleFullScreenCanvas()</code></pre></div> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://kogics.wikidot.com/forum/t-14392493#post-5163515</guid>
				<title>(no title)</title>
				<link>http://kogics.wikidot.com/forum/t-14392493/penrose-tilings#post-5163515</link>
				<description></description>
				<pubDate>Fri, 24 Dec 2021 20:10:43 +0000</pubDate>
				<wikidot:authorName>Joost Winter</wikidot:authorName>								<content:encoded>
					<![CDATA[
						 <p>After a few more days of Kojo coding, I managed to also create the original P1 set of tiles.</p> <p>I made a little demo out of it, called Roger.</p> <p>You can download the demo here (my apologies, the source code is still much less elegant than it ought to be): <a href="http://joostwinter.net/crazywizardsoftware/roger/">http://joostwinter.net/crazywizardsoftware/roger/</a></p> <p>&#8230;or alternately watch the video on Youtube: <a href="https://www.youtube.com/watch?v=FrruqBlXbcM">https://www.youtube.com/watch?v=FrruqBlXbcM</a></p> <p>Enjoy!</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://kogics.wikidot.com/forum/t-14392493#post-5161158</guid>
				<title>Penrose tilings</title>
				<link>http://kogics.wikidot.com/forum/t-14392493/penrose-tilings#post-5161158</link>
				<description></description>
				<pubDate>Tue, 21 Dec 2021 15:46:26 +0000</pubDate>
				<wikidot:authorName>Joost Winter</wikidot:authorName>								<content:encoded>
					<![CDATA[
						 <p>Congratulations to the devs for this awesome project! I am just getting started in Kojo and wrote a little small program to draw some rhombus-type Penrose tilings. So this here is really my first program using Kojo (and in fact, also my first program ever in Scala):</p> <div class="code"> <pre><code>var baseOne = 2 * math.sin(math.Pi * 54 / 180) var baseTwo = 2 * math.sin(math.Pi * 18 / 180) def triangleOne(depth: Int, length: Double, mirrored: Int): Unit = { if(depth == 0) { setFillColor(cm.green) forward(length) right(mirrored * 72) forward(length) right(mirrored * 144) hop(length * baseOne) right(mirrored * 144) } else { right(mirrored * 36) hop(length) left(mirrored * 144) triangleOne(depth - 1, length / baseOne, -mirrored) hop(length / baseOne) right(180) triangleTwo(depth - 1, length / baseOne, -mirrored) hop(length / baseOne) right(-mirrored * 36) hop(length / baseOne) right(180) triangleOne(depth - 1, length / baseOne, mirrored) hop(length * baseOne) right(mirrored * 144) } } def triangleTwo(depth: Int, length: Double, mirrored: Int): Unit = { if(depth == 0) { setFillColor(cm.blue) forward(length) right(mirrored * 144) forward(length) right(mirrored * 108) hop(length * baseTwo) right(mirrored * 108) } else { hop(length * baseTwo * baseTwo) right(mirrored * 108) triangleTwo(depth - 1, length * baseTwo, mirrored) hop(length * baseTwo) right(mirrored * 180) triangleOne(depth - 1, length * baseTwo, mirrored) left(mirrored * 36) hop(length * baseTwo) right(mirrored * 108) } } def decagon(depth: Int, length: Double) { clear() setBackground(cm.black) setSpeed(superFast) invisible() setPenColor(cm.black) left(90) hop(length) right(180) repeat(5) { triangleTwo(depth, length, 1) triangleTwo(depth, length, -1) right(72) hop(length * baseTwo) left(36) hop(length * baseTwo) left(108) } } clear() toggleFullScreenCanvas() var depth = 0 repeat(7) { decagon(depth, 400) depth = depth + 1 Thread.sleep(3000) }</code></pre></div> <img src="http://joostwinter.net/penrose.png" alt="penrose.png" class="image" /> <p>My compliments to the Kojo devs for creating an environment that makes it surprisingly easy to do things like this&#8230;</p> 
				 	]]>
				</content:encoded>							</item>
				</channel>
</rss>