<?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>Code Exchange (new posts)</title>
		<link>http://kogics.wikidot.com/forum/c-109808/code-exchange</link>
		<description>Posts in the forum category &quot;Code Exchange&quot; - Show your code. Learn from code written by others.</description>
				<copyright></copyright>
		<lastBuildDate>Sun, 19 Jul 2026 21:42:54 +0000</lastBuildDate>
		
					<item>
				<guid>http://kogics.wikidot.com/forum/t-14392493#post-5228475</guid>
				<title>Penrose tilings: </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>Penrose tilings: </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>Penrose tilings: </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>Penrose tilings: </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: 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>
					<item>
				<guid>http://kogics.wikidot.com/forum/t-982922#post-3780170</guid>
				<title>Beginning on Kojo: </title>
				<link>http://kogics.wikidot.com/forum/t-982922/beginning-on-kojo#post-3780170</link>
				<description></description>
				<pubDate>Wed, 25 Apr 2018 09:16:15 +0000</pubDate>
				<wikidot:authorName>jackyworne</wikidot:authorName>				<wikidot:authorUserId>3988235</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>PSD conversion plays a vital role in building a handsome WordPress based site. We have tried to give you the basic ideas to have to regard in mind when you convert any PSD to WordPress theme. Hopefully you will like it. If you liked this blog please feel free to share it with your dearest ones.<br /> <a href="https://psdtowpservice.com">PSD to Wordpress Expert</a></p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://kogics.wikidot.com/forum/t-982922#post-2087826</guid>
				<title>Beginning on Kojo: </title>
				<link>http://kogics.wikidot.com/forum/t-982922/beginning-on-kojo#post-2087826</link>
				<description></description>
				<pubDate>Wed, 13 Aug 2014 09:47:04 +0000</pubDate>
				<wikidot:authorName>lalitp</wikidot:authorName>				<wikidot:authorUserId>66813</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Let's exchange notes, Abhijeet.<br /> pant dot lalit at gmail</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://kogics.wikidot.com/forum/t-982922#post-2087812</guid>
				<title>Beginning on Kojo: </title>
				<link>http://kogics.wikidot.com/forum/t-982922/beginning-on-kojo#post-2087812</link>
				<description></description>
				<pubDate>Wed, 13 Aug 2014 09:25:50 +0000</pubDate>
				<wikidot:authorName>Abhijeet Ramdhave</wikidot:authorName>								<content:encoded>
					<![CDATA[
						 <p>I am into Business Computing by accident. Visual modelling is my area of interest. I have attempted to create some of the visual tools in the past like &quot;Table in word editor&quot;, Org. chart rendering, Perspective Drawing and Simulation, Lego (just 2 days of effort with handful of commands), etc.</p> <p>All of it remained till POC sometimes done in Java canvas, sometimes in html5 canvas. I wish I could spend more time to create professional visualization libraries.</p> <p>With this tool, may be I can spend some time building more serious visual illustrations.</p> <p>I could share some POCs of html5 canvas on your personal email.</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://kogics.wikidot.com/forum/t-982922#post-2087702</guid>
				<title>Beginning on Kojo: </title>
				<link>http://kogics.wikidot.com/forum/t-982922/beginning-on-kojo#post-2087702</link>
				<description></description>
				<pubDate>Wed, 13 Aug 2014 05:12:49 +0000</pubDate>
				<wikidot:authorName>lalitp</wikidot:authorName>				<wikidot:authorUserId>66813</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Thanks, Abhijeet.</p> <blockquote> <p>Looks like it may prove to be a good simulation tool for teaching Engineering subjects</p> </blockquote> <p>I have tried to make Kojo powerful enough to support this. I'll be very interested in hearing about any efforts you make in this area.</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://kogics.wikidot.com/forum/t-982922#post-2087699</guid>
				<title>Beginning on Kojo: </title>
				<link>http://kogics.wikidot.com/forum/t-982922/beginning-on-kojo#post-2087699</link>
				<description></description>
				<pubDate>Wed, 13 Aug 2014 05:07:07 +0000</pubDate>
				<wikidot:authorName>Abhijeet Ramdhave</wikidot:authorName>								<content:encoded>
					<![CDATA[
						 <p>Hi Lalit,</p> <p>This is a great platform you have created. Great work buddy!<br /> I am planning to explore it further in my free time.<br /> Looks like it may prove to be a good simulation tool for teaching Engineering subjects like Engineering Drawing, Structural Mechanics, etc.</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://kogics.wikidot.com/forum/t-982922#post-2087696</guid>
				<title>Beginning on Kojo: Re: Beginning on Kojo</title>
				<link>http://kogics.wikidot.com/forum/t-982922/beginning-on-kojo#post-2087696</link>
				<description></description>
				<pubDate>Wed, 13 Aug 2014 04:53:30 +0000</pubDate>
				<wikidot:authorName>lalitp</wikidot:authorName>				<wikidot:authorUserId>66813</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Great start! Keep sharing (here or on the code exchange).</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://kogics.wikidot.com/forum/t-982922#post-2087693</guid>
				<title>Beginning on Kojo: Beginning on Kojo</title>
				<link>http://kogics.wikidot.com/forum/t-982922/beginning-on-kojo#post-2087693</link>
				<description></description>
				<pubDate>Wed, 13 Aug 2014 04:41:34 +0000</pubDate>
				<wikidot:authorName>Abhijeet Ramdhave</wikidot:authorName>								<content:encoded>
					<![CDATA[
						 <p><strong>Star</strong></p> <div class="code"> <pre><code>clear() setBackground(black) setPenColor(red) setFillColor(blue) for (i &lt;- 1 to 5) { forward(200) right(144) }</code></pre></div> <p><strong>Kojo Design</strong></p> <div class="code"> <pre><code>clear() setBackground(black) setPenColor(red) setFillColor(blue) for (i &lt;- 1 to 12) { for (i &lt;- 1 to 4) { forward(50) right(90) } penUp() right(180 - 180 * 10 / 12) forward(50) penDown() }</code></pre></div> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://kogics.wikidot.com/forum/t-261332#post-1800703</guid>
				<title>PhiLho&#039;s code: </title>
				<link>http://kogics.wikidot.com/forum/t-261332/philho-s-code#post-1800703</link>
				<description></description>
				<pubDate>Thu, 20 Jun 2013 10:15:29 +0000</pubDate>
				<wikidot:authorName>praba</wikidot:authorName>								<content:encoded>
					<![CDATA[
						 <p>i don't get anything&#8230;..</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://kogics.wikidot.com/forum/t-261332#post-860061</guid>
				<title>PhiLho&#039;s code: Re: PhiLho&#039;s code</title>
				<link>http://kogics.wikidot.com/forum/t-261332/philho-s-code#post-860061</link>
				<description></description>
				<pubDate>Sun, 29 Aug 2010 15:23:42 +0000</pubDate>
				<wikidot:authorName>lalitp</wikidot:authorName>				<wikidot:authorUserId>66813</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <blockquote> <p>Suggestion: make overrides of setXxxColor to accept directly 0xAABBCC or 0xAABBCCDD or r, g, b or a, r, g, b</p> </blockquote> <p>Or maybe overload the color method (It's good to have the input type of setXxxColor be a color)</p> <blockquote> <p>Accepting some HSB color (via conversion function?) would be useful too.</p> </blockquote> <p>I'll need to play with that. Staging has all of this stuff, btw&#8230;</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://kogics.wikidot.com/forum/t-261332#post-860031</guid>
				<title>PhiLho&#039;s code: Re: PhiLho&#039;s code</title>
				<link>http://kogics.wikidot.com/forum/t-261332/philho-s-code#post-860031</link>
				<description></description>
				<pubDate>Sun, 29 Aug 2010 14:16:34 +0000</pubDate>
				<wikidot:authorName>lalitp</wikidot:authorName>				<wikidot:authorUserId>66813</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Very cool!</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://kogics.wikidot.com/forum/t-261332#post-860007</guid>
				<title>PhiLho&#039;s code: Re: PhiLho&#039;s code</title>
				<link>http://kogics.wikidot.com/forum/t-261332/philho-s-code#post-860007</link>
				<description></description>
				<pubDate>Sun, 29 Aug 2010 13:35:10 +0000</pubDate>
				<wikidot:authorName>PhiLho</wikidot:authorName>				<wikidot:authorUserId>551317</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>I understood it was an odd meeting of circumstances, or, as you wrote, an edge case.</p> <blockquote> <p>In line-by-line mode, it just stops at the first problem, and never gets to the internal repeat</p> </blockquote> <p>Yes, silly me, the code above has no var in it!</p> <p>Contributor Agreement - will do</p> <blockquote> <p>Just create a Color with an alpha value e.g. setFillColor(new Color(0, 0, 255, 128))</p> </blockquote> <p>Ah, tried color() with four parameters, not quite the same thing.<br /> Suggestion: make overrides of setXxxColor to accept directly 0xAABBCC or 0xAABBCCDD or r, g, b or a, r, g, b<br /> Works well in Processing and simplifies the coding.<br /> Accepting some HSB color (via conversion function?) would be useful too.</p> <blockquote> <p>Just do number.toHexString</p> </blockquote> <p>Thanks! I expected something that simple&#8230; ^_^</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://kogics.wikidot.com/forum/t-261332#post-860004</guid>
				<title>PhiLho&#039;s code: Re: PhiLho&#039;s code</title>
				<link>http://kogics.wikidot.com/forum/t-261332/philho-s-code#post-860004</link>
				<description></description>
				<pubDate>Sun, 29 Aug 2010 13:26:22 +0000</pubDate>
				<wikidot:authorName>PhiLho</wikidot:authorName>				<wikidot:authorUserId>551317</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Today is Sunday, I have some free time. ^_^<br /> Level up! To recursive functions, and beyond. Kojo fits well with geometrical fractals, so here is the Sierpinski square:</p> <div class="code"> <pre><code>clear invisible setAnimationDelay(4) setPenColor(blue) setPenThickness(1) setFillColor(color(0x77FFAA)) def relativeJumpTo(dx: Int, dy: Int) = jumpTo(position.x + dx, position.y + dy) def doSquare(size: Int): Unit = { val diag = size * 0.707 // sqrt(2)/2 penUp setHeading(45) forward(diag) penDown setHeading(-90) repeat(4) { forward(size); right } penUp setHeading(-135) forward(diag) } def doSquares(level: Int, size: Int): Unit = { if (level == 0) { doSquare(size) return } val s = size / 3 for (i &lt;- -1 until 2) { for (j &lt;- -1 until 2) { if (!(i == 0 &amp; j == 0)) { relativeJumpTo(s * i, s * j) doSquares(level -1, s) relativeJumpTo(-s * i, -s * j) } } } } //doSquare(500) doSquares(3, 500)</code></pre></div> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://kogics.wikidot.com/forum/t-261332#post-859997</guid>
				<title>PhiLho&#039;s code: Re: PhiLho&#039;s code</title>
				<link>http://kogics.wikidot.com/forum/t-261332/philho-s-code#post-859997</link>
				<description></description>
				<pubDate>Sun, 29 Aug 2010 13:14:56 +0000</pubDate>
				<wikidot:authorName>lalitp</wikidot:authorName>				<wikidot:authorUserId>66813</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <blockquote> <p>Ah, this is quite unexpected, first time I meet a language enforcing the brace style! ;-)</p> </blockquote> <p>Just to clarify, this is more of a scala interpreter thing (when it is fed input a line at a time) than a Scala thing. If you use the Scala compiler to compile code of this nature, it will work fine.</p> <p>One more thing in the mix here is the use of a 'var' in your script. If you don't use vars, Kojo is able to submit the whole script (in one batch, not line by line) to the interpreter, and things work fine.</p> <blockquote> <p>I suppose the rule applies to current scope, since the internal repeat is OK.</p> </blockquote> <p>In line-by-line mode, it just stops at the first problem, and never gets to the internal repeat</p> <blockquote> <p>Note: I place all my code under the zlib/libpng license, but small experiments like the one above are just put<br /> in public domain: if you find something of interest, feel free to add it to Kojo examples.</p> </blockquote> <p>Cool.<br /> Now is probably a good time to tell you that if you wish to contribute more substantial code to Kojo, I will request you to sign the <a href="http://wiki.kogics.net/forum/t-231811/contributor-license-agreement">Contributor Agreement</a>.</p> <blockquote> <p>What about transparency? Is it possible in Kojo or just not yet?</p> </blockquote> <p>Just create a Color with an alpha value e.g. setFillColor(new Color(0, 0, 255, 128))<br /> For Staging, you can also use the rgba color maker.</p> <blockquote> <p>And is there a convenient shortcut in Scala to display a number in hexa or do we have to use something like Message.format() or similar?</p> </blockquote> <p>I missed out on this yesterday. Just do number.toHexString</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://kogics.wikidot.com/forum/t-261332#post-859925</guid>
				<title>PhiLho&#039;s code: Re: PhiLho&#039;s code</title>
				<link>http://kogics.wikidot.com/forum/t-261332/philho-s-code#post-859925</link>
				<description></description>
				<pubDate>Sun, 29 Aug 2010 11:16:21 +0000</pubDate>
				<wikidot:authorName>PhiLho</wikidot:authorName>				<wikidot:authorUserId>551317</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Today's code is a little variant of the previous one, with some def to spice it up&#8230; ^_^</p> <div class="code"> <pre><code>val ROUND = 360.0 val REPEAT_NB = 7 val ANGLE = ROUND / REPEAT_NB val PENTA_ANGLE = ROUND / 5 val SIDE_LENGTH = 150 clear setAnimationDelay(42) setPenThickness(11) for (n &lt;- 0 until REPEAT_NB) { jumpTo(0, 0) setHeading(n * ANGLE) setPenColor(getColor(n)) repeat (3) { forward(SIDE_LENGTH) turn(PENTA_ANGLE) } forward(SIDE_LENGTH / 4) } penUp; home; penDown def lerp(start: Double, stop: Double, amount: Double): Double = { start + (stop - start) * amount } def getColor(n: Int): Color = { val amount = n.toDouble / REPEAT_NB color(0x80, lerp(0xF0, 0x80, amount).toInt, lerp(0x80, 0xF0, amount).toInt) }</code></pre></div> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://kogics.wikidot.com/forum/t-261332#post-859909</guid>
				<title>PhiLho&#039;s code: Re: PhiLho&#039;s code</title>
				<link>http://kogics.wikidot.com/forum/t-261332/philho-s-code#post-859909</link>
				<description></description>
				<pubDate>Sun, 29 Aug 2010 10:32:31 +0000</pubDate>
				<wikidot:authorName>PhiLho</wikidot:authorName>				<wikidot:authorUserId>551317</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Ah, this is quite unexpected, first time I meet a language enforcing the brace style! ;-)<br /> I understand it is a combination of unfortunate mix, Scala's line ending interpretation, repeat being a method and not a keyword, the interpreter mode, etc.<br /> I suppose the rule applies to current scope, since the internal repeat is OK.</p> <p>Note: I place all my code under the zlib/libpng license, but small experiments like the one above are just put in public domain: if you find something of interest, feel free to add it to Kojo examples.<br /> I updated the code above to have better contrast on the first three pentagons.</p> <p>What about transparency? Is it possible in Kojo or just not yet?<br /> And is there a convenient shortcut in Scala to display a number in hexa or do we have to use something like Message.format() or similar?</p> 
				 	]]>
				</content:encoded>							</item>
				</channel>
</rss>