<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>fractals | Learn C Games Programming Blog</title>
	<atom:link href="https://learncgames.com/tag/fractals/feed/" rel="self" type="application/rss+xml" />
	<link>https://learncgames.com</link>
	<description>A blog about C, programming games and my ebook(s).</description>
	<lastBuildDate>Mon, 15 Feb 2021 20:04:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://learncgames.com/wp-content/uploads/2020/03/cropped-favicon-32x32.png</url>
	<title>fractals | Learn C Games Programming Blog</title>
	<link>https://learncgames.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">181446779</site>	<item>
		<title>Some Pretty fractals in C + SDL2</title>
		<link>https://learncgames.com/some-pretty-fractals-in-c-sdl2/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=some-pretty-fractals-in-c-sdl2</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Wed, 17 Feb 2021 00:00:17 +0000</pubDate>
				<category><![CDATA[C]]></category>
		<category><![CDATA[Source code]]></category>
		<category><![CDATA[fractals]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=2693</guid>

					<description><![CDATA[<p>If you&#8217;ve ever wanted to draw fractals in C, here&#8217;s some code for you. These come from Misha on his(her?) GitHub page.  There are three as you can see. Each has their own program &#8211; barnsley.c, sierpinski.c and y-fractal.c. All three programs create an SDL2 window then display the image. Note that this was coded [&#8230;]</p>
The post <a href="https://learncgames.com/some-pretty-fractals-in-c-sdl2/">Some Pretty fractals in C + SDL2</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<div class='__iawmlf-post-loop-links' style='display:none;' data-iawmlf-post-links='[{&quot;id&quot;:169,&quot;href&quot;:&quot;https:\/\/en.wikipedia.org\/wiki\/Fractal&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20260202132608\/https:\/\/en.wikipedia.org\/wiki\/Fractal&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 12:22:59&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-12 22:35:47&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-18 23:29:24&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-24 13:54:49&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-07 12:12:50&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-12 08:10:08&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-17 18:47:37&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-23 14:05:56&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-27 21:41:33&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-01 04:48:36&quot;,&quot;http_code&quot;:429}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-01 04:48:36&quot;,&quot;http_code&quot;:429},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:170,&quot;href&quot;:&quot;https:\/\/github.com\/mikh86\/sdl-fractals&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20201205110601\/https:\/\/github.com\/mikh86\/sdl-fractals&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 12:23:02&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-02-12 22:35:47&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-02-18 23:29:24&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-02-24 13:54:49&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-03-07 12:12:47&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-03-12 08:10:08&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-03-17 18:47:41&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-03-23 14:05:58&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-03-27 21:41:33&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-04-01 04:48:36&quot;,&quot;http_code&quot;:404}],&quot;broken&quot;:true,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-01 04:48:36&quot;,&quot;http_code&quot;:404},&quot;process&quot;:&quot;done&quot;}]'></div>
<figure id="attachment_2694" aria-describedby="caption-attachment-2694" style="width: 300px" class="wp-caption alignleft"><img fetchpriority="high" decoding="async" class="size-medium wp-image-2694" src="https://learncgames.com/wp-content/uploads/2021/02/fractals-300x286.png" alt="Fractals" width="300" height="286" srcset="https://learncgames.com/wp-content/uploads/2021/02/fractals-300x286.png 300w, https://learncgames.com/wp-content/uploads/2021/02/fractals.png 696w" sizes="(max-width: 300px) 100vw, 300px" /><figcaption id="caption-attachment-2694" class="wp-caption-text">Code by Misha</figcaption></figure>
<p>If you&#8217;ve ever wanted to draw <a title="Link to fractal on Wikipedia" href="https://en.wikipedia.org/wiki/Fractal" target="_blank" rel="noopener">fractals</a> in C, here&#8217;s some code for you. These come from Misha on his(<em>her?</em>) <a title="Link to sdl-fractals on GitHub" href="https://github.com/mikh86/sdl-fractals" target="_blank" rel="nofollow noopener">GitHub</a> page.  There are three as you can see. Each has their own program &#8211; barnsley.c, sierpinski.c and y-fractal.c. All three programs create an SDL2 window then display the image.</p>
<p>Note that this was coded for Linux. I modified the programs so they would run on Windows and the screenshot was done from my machine. I know these images are on the GitHub page.</p>
<p>If you want to compile and run, then on all three programs change the SDL include from</p>
<pre>#include &lt;SDL2/SDL.h&gt;</pre>
<p>to</p>
<pre>#include "SDL.h"</pre>
<p>Also with the barnsley.c you need to give initial values to mx and my in the <strong>renderFractals()</strong> function (lines 88 and 89) and change these two lines: (<em>114 and 115</em>). No other changes are needed to let them compile.</p>
<pre><code class="language-c" data-line="">
mx_c = mx - win_w / 2;
my_c = my - win_h / 2;
</code>  to<code class="language-c" data-line="">
mx_c = mx - WIDTH / 2;
my_c = my - HEIGHT / 2;</code></pre>The post <a href="https://learncgames.com/some-pretty-fractals-in-c-sdl2/">Some Pretty fractals in C + SDL2</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2693</post-id>	</item>
	</channel>
</rss>
