<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet href="/feed.xsl" type="text/xsl" ?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en" xml:base="https://chrisburnell.com">
	<title>Chris Burnell · Code Demos</title>
	<subtitle>All of my code demos.</subtitle>
	<id>https://chrisburnell.com/code/</id>
	<link href="https://chrisburnell.com/code.xml" rel="self" />
	<link href="https://chrisburnell.com/code/" rel="alternate" />
	<author>
		<name>Chris Burnell</name>
		<uri>https://chrisburnell.com/</uri>
		<email>me@chrisburnell.com</email>
	</author>
	<logo>https://chrisburnell.com/images/raven.svg</logo>
	<image>https://chrisburnell.com/images/avatar@4x.jpeg</image>
	<updated>2024-06-27T17:40:31+00:00</updated>
	<generator>Eleventy v3.1.0</generator>
	<entry>
		<id>https://chrisburnell.com/code/fibonacci-spiral-navigation/</id>
		<link href="https://chrisburnell.com/code/fibonacci-spiral-navigation/" />
		<title>Fibonacci Spiral Navigation</title>
		<published>2024-06-28T01:40:31+08:00</published>
		<publishedFriendly>28 June 2024</publishedFriendly>
		<updated>2024-06-28T01:40:31+08:00</updated>
		<category term="code" scheme="https://chrisburnell.com/code/" label="Code Demo" />
		<summary>Inspired by a discussion in the 32-Bit Café Discord, I made this Navigation using the paths of a Fibonacci spiral in SVG</summary>
		<content xml:lang="en" type="html">
			&lt;p&gt;Inspired by a discussion in the 32-Bit Café Discord, I made this Navigation using the paths of a Fibonacci spiral in SVG&lt;/p&gt;
				&lt;hr&gt;
			
			
			&lt;p&gt;&lt;c-codepen slug=&quot;gOJyqaj&quot; height=&quot;750&quot;&gt;&lt;/c-codepen&gt;&lt;/p&gt;
			
			
			
			
				&lt;hr&gt;
				&lt;p&gt;Thanks for subscribing and reading this post via RSS!&lt;/p&gt;
				&lt;p&gt;You can read &lt;a href=&quot;https://chrisburnell.com/code/fibonacci-spiral-navigation/&quot;&gt;this post&lt;/a&gt; and others &lt;a href=&quot;https://chrisburnell.com/posts/&quot;&gt;on my website&lt;/a&gt;.&lt;/p&gt;
		</content>
		
		
	</entry>
	<entry>
		<id>https://chrisburnell.com/code/mixing-colours-different-spaces/</id>
		<link href="https://chrisburnell.com/code/mixing-colours-different-spaces/" />
		<title>Mixing Colours in Different Colour Spaces</title>
		<published>2024-03-05T04:58:00+08:00</published>
		<publishedFriendly>5 March 2024</publishedFriendly>
		<updated>2024-03-05T04:58:00+08:00</updated>
		<category term="code" scheme="https://chrisburnell.com/code/" label="Code Demo" />
		<summary>Visualise how different colour spaces will mix two given colours.</summary>
		<content xml:lang="en" type="html">
			&lt;p&gt;Visualise how different colour spaces will mix two given colours.&lt;/p&gt;
				&lt;hr&gt;
			
			
			&lt;p&gt;&lt;c-codepen slug=&quot;PogqpMN&quot; height=&quot;800&quot;&gt;&lt;/c-codepen&gt;&lt;/p&gt;
			
			
			
			
				&lt;hr&gt;
				&lt;p&gt;Thanks for subscribing and reading this post via RSS!&lt;/p&gt;
				&lt;p&gt;You can read &lt;a href=&quot;https://chrisburnell.com/code/mixing-colours-different-spaces/&quot;&gt;this post&lt;/a&gt; and others &lt;a href=&quot;https://chrisburnell.com/posts/&quot;&gt;on my website&lt;/a&gt;.&lt;/p&gt;
		</content>
		
		
	</entry>
	<entry>
		<id>https://chrisburnell.com/code/kaprekars-constant/</id>
		<link href="https://chrisburnell.com/code/kaprekars-constant/" />
		<title>Kaprekar’s Constant</title>
		<published>2024-01-18T17:00:00+08:00</published>
		<publishedFriendly>18 January 2024</publishedFriendly>
		<updated>2024-01-18T17:00:00+08:00</updated>
		<category term="code" scheme="https://chrisburnell.com/code/" label="Code Demo" />
		<summary>I came across an interesting mathematical observation today called Kaprekar’s constant, named after the mathematician, Dattatreya Ramchandra Kaprekar, and built an interactive tool to demonstrate it.</summary>
		<content xml:lang="en" type="html">
			&lt;p&gt;I came across an interesting mathematical observation today called Kaprekar’s constant, named after the mathematician, Dattatreya Ramchandra Kaprekar, and built an interactive tool to demonstrate it.&lt;/p&gt;
				&lt;hr&gt;
			
			
			&lt;blockquote&gt;
    &lt;ol&gt;
        &lt;li&gt;Take any four-digit number, using at least two different digits (leading zeros are allowed).&lt;/li&gt;
        &lt;li&gt;Arrange the digits in descending and then in ascending order to get two four-digit numbers, adding leading zeros if necessary.&lt;/li&gt;
        &lt;li&gt;Subtract the smaller number from the bigger number.&lt;/li&gt;
        &lt;li&gt;Go back to step 2 and repeat.&lt;/li&gt;
    &lt;/ol&gt;
    &lt;cite&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/6174&quot;&gt;Wikipedia&lt;/a&gt;&lt;/cite&gt;
&lt;/blockquote&gt;
&lt;p&gt;Following the above steps always leads you to the same number, Kaprekar’s Constant: 6174.&lt;/p&gt;
&lt;!-- &lt;/textarea&gt; --&gt;
&lt;!-- &#39;&quot;´ --&gt;
&lt;form id=&quot;calculator&quot;&gt;
	&lt;legend&gt;
		&lt;h2&gt;Kaprekar’s Constant&lt;/h2&gt;
	&lt;/legend&gt;
	&lt;fieldset&gt;
		&lt;label for=&quot;start&quot;&gt;Starting number&lt;/label&gt;
		&lt;input id=&quot;start&quot; type=&quot;number&quot; step=&quot;1&quot; min=&quot;1&quot; max=&quot;9999&quot; inputmode=&quot;numeric&quot; pattern=&quot;^[0-9]{4}$&quot; value=&quot;8145&quot;&gt;
	&lt;/fieldset&gt;
	&lt;fieldset&gt;
		&lt;button type=&quot;submit&quot;&gt;Submit&lt;/button&gt;
	&lt;/fieldset&gt;
&lt;/form&gt;
&lt;table id=&quot;output&quot;&gt;
	&lt;tbody&gt;
		&lt;tr&gt;
			&lt;td&gt;8541 - 1458 = 7083&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt;8730 - 0378 = 8352&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt;8532 - 2358 = 6174&lt;/td&gt;
		&lt;/tr&gt;
	&lt;/tbody&gt;
&lt;/table&gt;
			
			
			
			
				&lt;hr&gt;
				&lt;p&gt;Thanks for subscribing and reading this post via RSS!&lt;/p&gt;
				&lt;p&gt;You can read &lt;a href=&quot;https://chrisburnell.com/code/kaprekars-constant/&quot;&gt;this post&lt;/a&gt; and others &lt;a href=&quot;https://chrisburnell.com/posts/&quot;&gt;on my website&lt;/a&gt;.&lt;/p&gt;
		</content>
		
		
	</entry>
	<entry>
		<id>https://chrisburnell.com/code/meteora/</id>
		<link href="https://chrisburnell.com/code/meteora/" />
		<title>Meteora</title>
		<published>2023-06-28T14:13:00+01:00</published>
		<publishedFriendly>28 June 2023</publishedFriendly>
		<updated>2023-06-28T14:13:00+01:00</updated>
		<category term="code" scheme="https://chrisburnell.com/code/" label="Code Demo" />
		<summary>The beloved and renowned Linkin Park album, Meteora, as a spinning CD case.</summary>
		<content xml:lang="en" type="html">
			&lt;p&gt;The beloved and renowned Linkin Park album, Meteora, as a spinning CD case.&lt;/p&gt;
				&lt;hr&gt;
			
			
			&lt;p&gt;&lt;c-codepen slug=&quot;PoxbZQr&quot;&gt;&lt;/c-codepen&gt;&lt;/p&gt;
			
			
			
			
				&lt;hr&gt;
				&lt;p&gt;Thanks for subscribing and reading this post via RSS!&lt;/p&gt;
				&lt;p&gt;You can read &lt;a href=&quot;https://chrisburnell.com/code/meteora/&quot;&gt;this post&lt;/a&gt; and others &lt;a href=&quot;https://chrisburnell.com/posts/&quot;&gt;on my website&lt;/a&gt;.&lt;/p&gt;
		</content>
		
		
	</entry>
	<entry>
		<id>https://chrisburnell.com/code/one-hypotenuse-to-rule-them-all/</id>
		<link href="https://chrisburnell.com/code/one-hypotenuse-to-rule-them-all/" />
		<title>One Hypotenuse to rule them all</title>
		<published>2022-11-01T15:27:00+00:00</published>
		<publishedFriendly>1 November 2022</publishedFriendly>
		<updated>2022-11-01T15:27:00+00:00</updated>
		<category term="code" scheme="https://chrisburnell.com/code/" label="Code Demo" />
		<summary>Here’s a fun little demo of some math I found interesting.</summary>
		<content xml:lang="en" type="html">
			&lt;p&gt;Here’s a fun little demo of some math I found interesting.&lt;/p&gt;
				&lt;hr&gt;
			
			
			&lt;p&gt;If a right triangle has two side-lengths both equal to &lt;var&gt;√2 / 2&lt;/var&gt;, what is the length of its hypotenuse?&lt;/p&gt;
&lt;figure aria-hidden=&quot;true&quot;&gt;
    &lt;div&gt;
        &lt;div&gt;&lt;var&gt;?&lt;/var&gt;&lt;/div&gt;
        &lt;div&gt;√2 / 2&lt;/div&gt;
        &lt;div&gt;√2 / 2&lt;/div&gt;
    &lt;/div&gt;
&lt;/figure&gt;
&lt;p&gt;We’ll build a function to calculate the length of the hypotenuse given the length of the triangle’s other two sides.&lt;/p&gt;
&lt;p&gt;For this, we’ll use a bit of algebra you’re probably quite familiar with:&lt;/p&gt;
&lt;figure&gt;
    &lt;p&gt;Pythagorean Theorum&lt;/p&gt;
    &lt;p&gt;&lt;samp&gt;a² + b² = c²&lt;/samp&gt;&lt;/p&gt;
&lt;/figure&gt;
&lt;p&gt;Where &lt;var&gt;c&lt;/var&gt; represents the hypotenuse, and &lt;var&gt;a&lt;/var&gt; and &lt;var&gt;b&lt;/var&gt; the other two sides.&lt;/p&gt;
&lt;p&gt;Let’s put everything together and calculate this with some JavaScript:&lt;/p&gt;
&lt;pre data-language=&quot;js&quot; data-language-friendly=&quot;js&quot;&gt;&lt;code&gt;&lt;span&gt;const&lt;/span&gt; side &lt;span&gt;=&lt;/span&gt; Math&lt;span&gt;.&lt;/span&gt;&lt;span&gt;sqrt&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;2&lt;/span&gt;&lt;span&gt;)&lt;/span&gt; &lt;span&gt;/&lt;/span&gt; &lt;span&gt;2&lt;/span&gt;
&lt;p&gt;&lt;span&gt;// We’re looking for &lt;code&gt;c&lt;/code&gt; in the equation:&lt;/span&gt;&lt;br&gt;
&lt;span&gt;// a² + b² = c²&lt;/span&gt;&lt;br&gt;
&lt;span&gt;const&lt;/span&gt; &lt;span&gt;calculateHypotenuse&lt;/span&gt; &lt;span&gt;=&lt;/span&gt; &lt;span&gt;(&lt;/span&gt;&lt;span&gt;a&lt;span&gt;,&lt;/span&gt; b&lt;/span&gt;&lt;span&gt;)&lt;/span&gt; &lt;span&gt;=&amp;gt;&lt;/span&gt; &lt;span&gt;{&lt;/span&gt;&lt;br&gt;
&lt;span&gt;// Start with getting the square of the sides,&lt;/span&gt;&lt;br&gt;
&lt;span&gt;// &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;b&lt;/code&gt;&lt;/span&gt;&lt;br&gt;
&lt;span&gt;const&lt;/span&gt; a2 &lt;span&gt;=&lt;/span&gt; Math&lt;span&gt;.&lt;/span&gt;&lt;span&gt;pow&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;a&lt;span&gt;,&lt;/span&gt; &lt;span&gt;2&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;br&gt;
&lt;span&gt;const&lt;/span&gt; b2 &lt;span&gt;=&lt;/span&gt; Math&lt;span&gt;.&lt;/span&gt;&lt;span&gt;pow&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;b&lt;span&gt;,&lt;/span&gt; &lt;span&gt;2&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;// Then, to isolate &lt;code&gt;c&lt;/code&gt;, take the square root of&lt;/span&gt;&lt;br&gt;
&lt;span&gt;// both sides of the equation&lt;/span&gt;&lt;br&gt;
&lt;span&gt;return&lt;/span&gt; Math&lt;span&gt;.&lt;/span&gt;&lt;span&gt;sqrt&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;a2 &lt;span&gt;+&lt;/span&gt; b2&lt;span&gt;)&lt;/span&gt;&lt;br&gt;
&lt;span&gt;}&lt;/span&gt;&lt;/p&gt;
&lt;/code&gt;&lt;p&gt;&lt;code&gt;&lt;span&gt;const&lt;/span&gt; hypotenuse &lt;span&gt;=&lt;/span&gt; &lt;span&gt;calculateHypotenuse&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;side&lt;span&gt;,&lt;/span&gt; side&lt;span&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Which gives us… &lt;var&gt;1&lt;/var&gt;&lt;/p&gt;
&lt;figure aria-hidden=&quot;true&quot;&gt;
    &lt;div&gt;
        &lt;div&gt;&lt;var&gt;1&lt;/var&gt;&lt;/div&gt;
        &lt;div&gt;√2 / 2&lt;/div&gt;
        &lt;div&gt;√2 / 2&lt;/div&gt;
    &lt;/div&gt;
&lt;/figure&gt;
&lt;p&gt;Interesting! 🤔&lt;/p&gt;
			
			
			
			
				&lt;hr&gt;
				&lt;p&gt;Thanks for subscribing and reading this post via RSS!&lt;/p&gt;
				&lt;p&gt;You can read &lt;a href=&quot;https://chrisburnell.com/code/one-hypotenuse-to-rule-them-all/&quot;&gt;this post&lt;/a&gt; and others &lt;a href=&quot;https://chrisburnell.com/posts/&quot;&gt;on my website&lt;/a&gt;.&lt;/p&gt;
		</content>
		
		
	</entry>
	<entry>
		<id>https://chrisburnell.com/code/the-workplace/</id>
		<link href="https://chrisburnell.com/code/the-workplace/" />
		<title>The Workplace</title>
		<published>2022-10-09T15:45:00+01:00</published>
		<publishedFriendly>9 October 2022</publishedFriendly>
		<updated>2022-10-09T15:45:00+01:00</updated>
		<category term="code" scheme="https://chrisburnell.com/code/" label="Code Demo" />
		<summary>Relaxing, back-to-the-basics little pen playing with text effects.</summary>
		<content xml:lang="en" type="html">
			&lt;p&gt;Relaxing, back-to-the-basics little pen playing with text effects.&lt;/p&gt;
				&lt;hr&gt;
			
			
			&lt;p&gt;&lt;c-codepen slug=&quot;vYjXGVJ&quot;&gt;&lt;/c-codepen&gt;&lt;/p&gt;
			
			
			
			
				&lt;hr&gt;
				&lt;p&gt;Thanks for subscribing and reading this post via RSS!&lt;/p&gt;
				&lt;p&gt;You can read &lt;a href=&quot;https://chrisburnell.com/code/the-workplace/&quot;&gt;this post&lt;/a&gt; and others &lt;a href=&quot;https://chrisburnell.com/posts/&quot;&gt;on my website&lt;/a&gt;.&lt;/p&gt;
		</content>
		
		
	</entry>
	<entry>
		<id>https://chrisburnell.com/code/rainbow-hsl/</id>
		<link href="https://chrisburnell.com/code/rainbow-hsl/" />
		<title>Rainbow HSL Underline</title>
		<published>2020-07-30T19:46:00+01:00</published>
		<publishedFriendly>30 July 2020</publishedFriendly>
		<updated>2020-07-30T19:46:00+01:00</updated>
		<category term="code" scheme="https://chrisburnell.com/code/" label="Code Demo" />
		<summary>Thought it would be fun to flex my SCSS loop skills, and actually went for a while loop! Use at your leisure.</summary>
		<content xml:lang="en" type="html">
			
			
			
			&lt;p&gt;&lt;c-codepen slug=&quot;WNrqYLV&quot;&gt;&lt;/c-codepen&gt;&lt;/p&gt;
&lt;p&gt;Thought it would be fun to flex my SCSS loop skills, and actually went for a &lt;code&gt;while&lt;/code&gt; loop! Use at your leisure.&lt;/p&gt;
			
			
			
			
				&lt;hr&gt;
				&lt;p&gt;Thanks for subscribing and reading this post via RSS!&lt;/p&gt;
				&lt;p&gt;You can read &lt;a href=&quot;https://chrisburnell.com/code/rainbow-hsl/&quot;&gt;this post&lt;/a&gt; and others &lt;a href=&quot;https://chrisburnell.com/posts/&quot;&gt;on my website&lt;/a&gt;.&lt;/p&gt;
		</content>
		
		
	</entry>
	<entry>
		<id>https://chrisburnell.com/code/moon-phases/</id>
		<link href="https://chrisburnell.com/code/moon-phases/" />
		<title>Moon Phases</title>
		<published>2019-12-12T00:38:00+00:00</published>
		<publishedFriendly>12 December 2019</publishedFriendly>
		<updated>2019-12-12T00:38:00+00:00</updated>
		<category term="code" scheme="https://chrisburnell.com/code/" label="Code Demo" />
		<summary>In part of building a weather app, I wanted to represent the phases of the moon somehow, and I’m getting values 0–99 from my data, so I needed a solution that worked easily with that in mind.</summary>
		<content xml:lang="en" type="html">
			
			
			
			&lt;p&gt;&lt;c-codepen slug=&quot;MWYeWRZ&quot; height=&quot;750px&quot;&gt;&lt;/c-codepen&gt;&lt;/p&gt;
&lt;p&gt;In part of building a weather app, I wanted to represent the phases of the moon somehow, and I’m getting values 0–99 from my data, so I needed a solution that worked easily with that in mind.&lt;/p&gt;
			
			
			
			
				&lt;hr&gt;
				&lt;p&gt;Thanks for subscribing and reading this post via RSS!&lt;/p&gt;
				&lt;p&gt;You can read &lt;a href=&quot;https://chrisburnell.com/code/moon-phases/&quot;&gt;this post&lt;/a&gt; and others &lt;a href=&quot;https://chrisburnell.com/posts/&quot;&gt;on my website&lt;/a&gt;.&lt;/p&gt;
		</content>
		
		
	</entry>
	<entry>
		<id>https://chrisburnell.com/code/color-transition-demo/</id>
		<link href="https://chrisburnell.com/code/color-transition-demo/" />
		<title>Color Transition Demo</title>
		<published>2019-12-09T18:41:00+00:00</published>
		<publishedFriendly>9 December 2019</publishedFriendly>
		<updated>2019-12-09T18:41:00+00:00</updated>
		<category term="code" scheme="https://chrisburnell.com/code/" label="Code Demo" />
		<summary>A demo to visually see how different duration offsets affect transitioning both background-color and color.</summary>
		<content xml:lang="en" type="html">
			
			
			
			&lt;p&gt;&lt;c-codepen slug=&quot;MWYKQdX&quot; height=&quot;810px&quot;&gt;&lt;/c-codepen&gt;&lt;/p&gt;
&lt;p&gt;A demo to visually see how different duration offsets affect transitioning both background-color and color.&lt;/p&gt;
			
			
			
			
				&lt;hr&gt;
				&lt;p&gt;Thanks for subscribing and reading this post via RSS!&lt;/p&gt;
				&lt;p&gt;You can read &lt;a href=&quot;https://chrisburnell.com/code/color-transition-demo/&quot;&gt;this post&lt;/a&gt; and others &lt;a href=&quot;https://chrisburnell.com/posts/&quot;&gt;on my website&lt;/a&gt;.&lt;/p&gt;
		</content>
		
		
	</entry>
	<entry>
		<id>https://chrisburnell.com/code/doubly-center-aligned/</id>
		<link href="https://chrisburnell.com/code/doubly-center-aligned/" />
		<title>Doubly-Center-Aligned Text</title>
		<published>2018-12-31T18:08:00+00:00</published>
		<publishedFriendly>31 December 2018</publishedFriendly>
		<updated>2018-12-31T18:08:00+00:00</updated>
		<category term="code" scheme="https://chrisburnell.com/code/" label="Code Demo" />
		<summary></summary>
		<content xml:lang="en" type="html">
			
			
			
			&lt;p&gt;&lt;c-codepen slug=&quot;zJLoGK&quot;&gt;&lt;/c-codepen&gt;&lt;/p&gt;
			
			
			
			
				&lt;hr&gt;
				&lt;p&gt;Thanks for subscribing and reading this post via RSS!&lt;/p&gt;
				&lt;p&gt;You can read &lt;a href=&quot;https://chrisburnell.com/code/doubly-center-aligned/&quot;&gt;this post&lt;/a&gt; and others &lt;a href=&quot;https://chrisburnell.com/posts/&quot;&gt;on my website&lt;/a&gt;.&lt;/p&gt;
		</content>
		
		
	</entry>
	
</feed>
