<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Adnan Baysal on Medium]]></title>
        <description><![CDATA[Stories by Adnan Baysal on Medium]]></description>
        <link>https://medium.com/@adbaysal?source=rss-af91e24bad83------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*QbyhBxlrznRSo4mu.jpg</url>
            <title>Stories by Adnan Baysal on Medium</title>
            <link>https://medium.com/@adbaysal?source=rss-af91e24bad83------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 00:41:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@adbaysal/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Exploring Truchet Tiles]]></title>
            <link>https://medium.com/@adbaysal/exploring-truchet-tiles-da61f02981a0?source=rss-af91e24bad83------2</link>
            <guid isPermaLink="false">https://medium.com/p/da61f02981a0</guid>
            <category><![CDATA[visualization]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[some]]></category>
            <category><![CDATA[tiling]]></category>
            <category><![CDATA[mathematics]]></category>
            <dc:creator><![CDATA[Adnan Baysal]]></dc:creator>
            <pubDate>Wed, 07 Aug 2024 20:14:02 GMT</pubDate>
            <atom:updated>2024-08-17T12:26:21.368Z</atom:updated>
            <content:encoded><![CDATA[<h3>Exploring Truchet Tiles and Beyond</h3><h3>Overview</h3><p>This article explores the fascinating world of Truchet tiling and its variations. New methods are introduced to enrich Truchet tiling and to create visually interesting results. Finally, an open source Python implementation of the proposed methods is given.</p><h3>What are Truchet Tiles</h3><p>In 1704, <a href="https://en.wikipedia.org/wiki/S%C3%A9bastien_Truchet">Sébastien Truchet</a> described a single tile which has 4 different rotations and can be used to create different patterns:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/318/0*BfJm5waETrXQC0fh.png" /><figcaption>Truchet tiles and its 4 different rotations. Image source: <a href="https://en.wikipedia.org/wiki/Truchet_tiles">Wikipedia</a></figcaption></figure><p>Using only this single type of tile, we can create beautiful patterns such as the following images:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XDgJkOZ0YbfEsXunXoYKrA.png" /><figcaption>Two special arrangements of Truchet Tiles with visually appealing structures. Image source:<a href="https://en.wikipedia.org/wiki/Truchet_tiles"> Wikipedi</a>a</figcaption></figure><p>On the other hand, random arrangements create (subjectively) not so interesting patterns:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xrXqzRJKLNlvoGykhN2iuQ.png" /><figcaption>A random Truchet tiling. Image source: <a href="https://en.wikipedia.org/wiki/Truchet_tiles">Wikipedia</a></figcaption></figure><p>So, Truchet tiling comes at a cost that one needs to be careful about how to arrange them to get an image with a structure.</p><h3>Smith Tiles</h3><p>In 1987, <a href="https://en.wikipedia.org/wiki/Cyril_Stanley_Smith">Cyril Stanley Smith</a> introduced a variation of Truchet tiles by incorporating two quarter circles in a square tile. This single tile has 2 different rotations:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CoXxeaU5smCE5hyO2_ijtQ.png" /><figcaption>Smith variation of Truchet Tiles (Smith tiles for short). Image source: <a href="https://en.wikipedia.org/wiki/Truchet_tiles">Wikipedia</a></figcaption></figure><p>With Smith variation (let’s call it Smith tiles), even random arrangements create patterns with interesting properties:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/962/1*q5mHJS00KFo_AQruHVOACQ.png" /><figcaption>A random arrangement of Smith tiles. Image source: <a href="https://en.wikipedia.org/wiki/Truchet_tiles">Wikipedia</a></figcaption></figure><p>First apparent property of Smith variant is it creates only closed regions except edges. There is a second property that is not exactly satisfied, but it seems almost true: the “width” of each closed region is about the same. This property is violated since the lines connecting the middle points of the sides of the square tile are circular but not straight.</p><h3>Smith Tiles with Straight Lines</h3><p>Using straight lines instead of quarter circles in Smith tiles gives the following rotations:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E_DGahQ3GYyUNCPWX5GMog.png" /><figcaption>Using straight lines instead of quarter circles in Smith tiles.</figcaption></figure><p>Let’s see this variation in action in a random arrangement:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*rwgRyQ19X2FobLaZZB_tvQ.jpeg" /><figcaption>A random arrangement of modified Smith tiles.</figcaption></figure><p>By this simple change, the fact that all closed regions have the same width becomes clearly visible. Personally, I find this variation more beautiful and interesting. From now on, I’ll only use this variation with different arrangements and some other tweaks that produce fascinating results.</p><h3>Systematic Arrangements of Tiles</h3><p>Instead of randomly arranging the tiles, we can use mathematical formulae to select which rotation of the tile to use at any position in the tiling area. Since there are two different tile rotations, a rectangular arrangement of the tiles corresponds to an <em>n</em> x <em>m</em> matrix (<em>n</em> rows, <em>m</em> columns) with entries 0 or 1. Rows will be enumerated from top to bottom with integers from 0 to <em>n</em> — 1, and columns from left to right with integers from 0 to <em>m</em> — 1. For simplicity, we’ll only show square matrices, that is <em>n</em> = <em>m</em>. So we need a function mapping a tuple of integers (<em>i</em>, <em>j</em>) in the range [0, <em>n</em> — 1] into the set {0, 1}. Here (<em>i</em>, <em>j</em>) is the coordinate of the matrix entry. This tiling process is a visualization of that function. Now let’s try to visualize a few generic functions:</p><h3>XOR function</h3><p>Every non-negative integer has a base 2 representation where digits (or bits) are 0 or 1. This is called the binary representation. Computers store numbers in this format. For example, decimal 13 is represented as 1101 in binary. Each digit of a binary number (which is 0 or 1) is called a bit (short for binary digit). There are 3 well known and basic (group) operations on bits: AND, OR and XOR. XOR of two bits is 0 when the numbers are the same, and 1 otherwise. Only XOR is balanced among these three operations, meaning for all possible input tuples to XOR, half of them output 0 and half of them output 1. This is important to make the output of tiling balanced. So let’s define our function as follows:</p><p>For input (<em>i</em>, <em>j</em>) in the valid range, convert both numbers to binary, and XOR all the bits together. For example, if <em>i</em> = 13 = (1101) and <em>j </em>= 9 = (1001), then:</p><p>XOR (1101, 1001) = 1 ⊕ 1 ⊕ 0 ⊕ 1 ⊕ 1 ⊕ 0 ⊕ 0 ⊕ 1 = 1</p><p>Here ⊕ is the XOR operation between two bits and XOR is the function we want to visualize with tiles. A 4 x 4 matrix will have the following entries using the XOR function:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/242/1*QuCsgWj-ZJGd--jOSfQKbQ.jpeg" /></figure><p>Visualizing this matrix with our tiles gives the following tiling:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*ZlbJC2mA-sZAIA-VhG4h-w.jpeg" /><figcaption>Tiling with XOR, 4x4.</figcaption></figure><p>Not so interesting, right? It’s because the matrix is too small to show the beautiful patterns that emerge on larger scales. So let’s try the 16 x 16 matrix:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*MjYZcg20gsj02AscXzmgMA.jpeg" /><figcaption>Tiling with XOR, 16x16.</figcaption></figure><p>This is already promising. So let’s continue with 32 x 32:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/1*Ew_zJ57nYIMQEl07ZRuYnw.jpeg" /><figcaption>Tiling with XOR, 32x32.</figcaption></figure><p>In this image, there are some simple patterns that repeat itself (such as the one that looks like a plus sign), but at the same time, these simple patterns are arranged in a non-periodic but structured way. Arrangement of simple patterns gets deeper with scale. The following is the 64 x 64 tiling with XOR:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pIsfr7hAj2742BhKy5lCQA.jpeg" /><figcaption>Tiling with XOR, 64x64.</figcaption></figure><h3>Abusing XOR</h3><p>Taking advantage of the fact that XOR is a very generic function with this balanced output property, we can compose it with other functions, and visualize the composition function with tiling. One method is to use a function <em>f</em> that takes a tuple of integers, and returns another integer (all non-negative). The output of that function can be given as input to XOR to produce a bit for the coordinate (<em>i</em>, <em>j</em>).</p><p>If <em>f</em> is addition for example, we use XOR(i + j) for the values at matrix coordinates. The resulting tiling is not so interesting because it lacks the depth the original XOR has:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*AXMX2P71yOSIxgdLR0kExA.jpeg" /><figcaption>Tiling with XOR on addition, 16x16.</figcaption></figure><p>Now let’s try our luck with multiplication:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*MAVAP6fpgXkHLHoe6yfv2w.jpeg" /><figcaption>Tiling with XOR on multiplication, 16x16.</figcaption></figure><p>This is not as impressive as XOR, nevertheless it has some beauty. Let’s see two more functions that produce a symmetric tiling along the main diagonal: XOR(<em>i</em> AND <em>j</em>) and XOR(<em>i</em> OR <em>j</em>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*NhwP5-7xCowLlIOoQrnTvQ.jpeg" /><figcaption>Tiling with XOR on AND, 16x16.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*Fea_2juH0DflPUVyJTgWvg.jpeg" /><figcaption>Tiling with XOR on OR, 16x16.</figcaption></figure><p>Here, AND and OR are bitwise operations, that is, they operate over each bit position individually. These tilings are nice as well, but not as much as the XOR tiling alone. Let’s also see an asymmetric tiling: XOR on <em>i^j </em>(<em>i</em> to the power <em>j</em>):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mlkjDLT2pgk6ZGCpnHJhcA.jpeg" /><figcaption>Tiling with XOR on <em>i</em> to the power <em>j</em>, 32x32.</figcaption></figure><p>It does not show too much structure, but interestingly such a simply defined function returns surprisingly random looking tiling. This tiling can be made symmetric along the main diagonal by using XOR on <em>i</em>^<em>j</em> + <em>j</em>^<em>i</em>.</p><h3>Adding some contrast to the tiling</h3><p>Upon inspecting all these tilings with straight lines, it seems like we can color adjacent closed regions using only two colors. For Smith variant this is done, for example, in <a href="https://link.springer.com/article/10.1007/BF02838881">a 2006 paper by E. A. Lord and S. Ranganathan</a>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*O_osAddxdNMaiq4vQ9U-_g.png" /><figcaption>A random tiling with Smith tiling colored with 2 colors. Image source: <a href="https://www.researchgate.net/figure/The-appearance-of-a-random-tiling-by-the-tiles-shown-in-Figure-4_fig3_227098904">researchgate.net</a></figcaption></figure><p>For simplicity, let’s use black and white. The coloring helps discriminate adjacent regions, but it also comes at a cost. If we want to do this tiling physically, we’ll need two different tiles to decorate with coloring: one with internal area between diagonal lines filled with black (call it color 0) and another one with area out of diagonal lines filled with black (color 1):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/128/1*ruqcnYcPqUMX8d_IBg6ezQ.jpeg" /><figcaption>Color 0 tile.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/128/1*kjS0ZwwndWmL-OGwbO9bCg.jpeg" /><figcaption>Color 1 tile</figcaption></figure><p>Counting the rotated versions, we get four different options for each coordinate of the tiling matrix. A random arrangement of these four tile rotations does not have the closed regions property. This is because black filled portions do not match if the tile color is not correctly selected. Luckily, there is a simple algorithm to choose which color to use at any coordinate:</p><p>For any tile, if its neighbor has the same rotation with that tile, use the inverse of its neighbor’s color, otherwise use the same color. A neighbor is one of the tiles above, below, left or right of that tile. Which neighbour is chosen to compare does not affect the result, but the choice of the initial tile and its color does. We can start coloring from the top left tile of the matrix with any color. Then we can proceed horizontally until the end of the row and compare each tile to its left neighbor at every step. When starting a new row, we can compare it with the neighbor above. This way, all the tiles can be colored.</p><p>Now that we have an algorithm to color our tilings, let’s see a result on a random tiling. Since we are free to select any color for the top left tile, we’ll show the resulting images for both initial color choices, for the same tiling matrix:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*MWJrNzC4kmIyA3Yaz3z6jQ.jpeg" /><figcaption>Random tiling, starting with color 0 at the top left</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*T7WH1n9rRLNPrRGk8AONKQ.jpeg" /><figcaption>The same random tiling, starting with color 1 at the top left</figcaption></figure><p>It is clearly visible from the images that changing the initial color inverts the coloring of the whole image. We can use this to select the version we prefer. For random tilings it may not have much affect, but for the function based tilings we demonstrated so far, we may prefer one over the other. The coloring procedure shown here gives empirical evidence that this tiling method is indeed 2-colorable.</p><p>Below is a selection of colored versions of the function based tilings:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dJIghzOy3qYOlptTCGto8A.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5ORI88IR_naNy5HXR-03MA.jpeg" /><figcaption>First image: 32x32 XOR tiling starting with color 0 at the top left. Second image: The same tiling starting with color 1 at the top left.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F2aENKlYdfZPDJxEl-d3xg.jpeg" /><figcaption>64x64 XOR tiling starting with color 0 at top left.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tYsWCu6m9Uaz3zZ2ltDCZg.jpeg" /><figcaption>32x32 XOR(i x j) tiling starting with color 0 at the top left.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dYpgmMqRHrPbWy_2RczNGg.jpeg" /><figcaption>32x32 XOR on i to the power j tiling starting with color 0 at the top left.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9Pe-9QkweN8SVqLQgbMlrQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n3XspixzyPBZQ68bv8cVJw.jpeg" /><figcaption>First: 32x32 XOR(i AND j) tiling starting with color 0 at the top left. Second: 32x32 XOR(i OR j) tiling starting with color 0 at the top left.</figcaption></figure><h3>Getting rid of angles</h3><p>There is one more tweak to refine the final tiling image. We can make angled lines vertical and horizontal. To make the symmetry axis vertical, we need to rotate the tiling 45 degrees clock-wise around its center. To make it suitable for displays, we also need to crop the image. This reduces the total area to its half, because in the end, we’ll be displaying the following square area of a tiling of <em>n</em> x <em>n</em> matrix:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*KQvxoJx8ksvD4BXBORLFHA.jpeg" /><figcaption>Area to be displayed after 45 degree rotation of the original square tiling.</figcaption></figure><p>In the original angled tiling, when the size of the tile is increased, the top left part always stays the same. On the other hand, when we rotate the tiling and crop the maximal square area, we lose this scaling property. Without further ado, let’s see what we get for different sizes and functions. For all images in this section, we cropped the final image further to remove the half width parts at all edges. This reduces the size of each axis by one tile.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YD1d_0Vnfnmku8sufE-I9g.png" /><figcaption>15x15 upright random tiling made from 32x32 angled random tiling.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oA12DL3FDOoppWVh-dEShg.png" /><figcaption>15x15 upright XOR tiling made from 32x32 angled XOR tiling.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m74MqjkLtFavGkfMhgsEpg.png" /><figcaption>31x31 upright XOR tiling.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zOAF2otlugSEZwI0WnFb5g.png" /><figcaption>15x15 upright XOR of (i x j) tiling.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7phaewTrNTmuy1lWZOTGKA.png" /><figcaption>31x31 upright XOR of (i x j) tiling.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7NSEt7wQ0mWIrseDDr8hoQ.png" /><figcaption>15x15 upright XOR of (i AND j) tiling.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MsXGeopjdP3bwv3C3ZSbHw.png" /><figcaption>31x31 upright XOR of (i AND j) tiling.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DMti5AK0oM2nUiC5VUxFfg.png" /><figcaption>15x15 upright XOR of (i OR j) tiling.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JFxLDqIeIkG72oCdBkK2qQ.png" /><figcaption>31x31 upright XOR(i OR j) tiling.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XQ7IJob_Ciw90B9gvebsXA.png" /><figcaption>15x15 upright XOR of (i^j) tiling (i^j: i to the power j).</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9w6uXbN1aEMui4ndBO8BIw.png" /><figcaption>31x31 upright XOR of (i^j) tiling.</figcaption></figure><h3>Source Code</h3><p>A pygame based Python code to generate these tilings can be found <a href="https://github.com/adnanbaysal/truchet-tiles">here</a>. Feel free to use the code for any purpose, at your own risk.</p><h3>Summary</h3><p>We explored new modifications of the Smith variant of Truchet tiles and showed some beautiful tilings using these modifications. We used straight lines in the Smith variant instead of quarter circles, which resulted in more structured images. We visualized some mathematical functions with this tiling. We showed a method to apply 2-coloring on the resulting tiling which increases the contrast greatly. Lastly, we made the resulting angled images upright by rotating and cropping.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=da61f02981a0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>