{"id":158,"date":"2025-03-27T15:40:00","date_gmt":"2025-03-27T15:40:00","guid":{"rendered":"https:\/\/theroyalscode.com\/students\/a_carpenter\/?p=158"},"modified":"2025-03-27T15:42:34","modified_gmt":"2025-03-27T15:42:34","slug":"free-thursday-3-27-2025","status":"publish","type":"post","link":"https:\/\/theroyalscode.com\/students\/a_carpenter\/2025\/03\/27\/free-thursday-3-27-2025\/","title":{"rendered":"Free Thursday 3\/27\/2025"},"content":{"rendered":"\n<p class=\"has-large-font-size\" style=\"border-width:5px;border-radius:10px\"><strong>Today I did testing with something I&#8217;ve been working on over this past week. I have been working with Python Turtle Graphics and have been trying to make the Sierpisnki triangle with rainbow colors and I finally, finally, finally have found the proper algorithm, so here it is, the code for it alongside an image of the successful      small-scale test<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from turtle import *\nimport time\n\n# Set the color mode to RGB\ncolormode(255)\n\n# Set the background color to black\nbgcolor(0, 0, 0)\n\n# Function to generate rainbow colors\ndef rainbow_color_interpolation(num_colors):\n    colors = &#91;]\n    for i in range(num_colors):\n        # Calculate the hue value\n        hue = i \/ num_colors * 360\n        # Convert HSV to RGB\n        rgb = hsv_to_rgb(hue \/ 360.0, 1.0, 1.0)\n        colors.append((int(rgb&#91;0] * 255), int(rgb&#91;1] * 255), int(rgb&#91;2] * 255)))\n    return colors\n\ndef hsv_to_rgb(h, s, v):\n    if s == 0.0:  # Achromatic (grey)\n        return (v, v, v)\n    i = int(h * 6.0)  # Assume h is &#91;0, 1)\n    f = (h * 6.0) - i\n    p = v * (1.0 - s)\n    q = v * (1.0 - f * s)\n    t = v * (1.0 - (1.0 - f) * s)\n    i = i % 6\n    if i == 0:\n        return (v, t, p)\n    elif i == 1:\n        return (q, v, p)\n    elif i == 2:\n        return (p, v, t)\n    elif i == 3:\n        return (p, q, v)\n    elif i == 4:\n        return (t, p, v)\n    elif i == 5:\n        return (v, p, q)\n\n# Setup turtle\nspeed(0)\nwidth(1)\ncount = 0 \n\ndef draw_triangle(length):\n    global count\n    # Use interpolated colors for the triangle\n    color(rainbow_colors&#91;count % len(rainbow_colors)])\n    count += 1\n    forward(length)\n    right(120)\n    color(rainbow_colors&#91;count % len(rainbow_colors)])\n    count += 1\n    forward(length)\n    right(120)\n\ndef draw_sierpinski(length):\n    draw_triangle(length)\n    if length &gt; 10:\n        draw_sierpinski(length \/\/ 2)\n    draw_triangle(length)\n    if length &gt; 10:\n        draw_sierpinski(length \/\/ 2)\n    draw_triangle(length)\n    if length &gt; 10:\n        draw_sierpinski(length \/\/ 2)\n    draw_triangle(length)\n    if length &gt; 10:\n        draw_sierpinski(length \/\/ 2)\n    draw_triangle(length)\n    if length &gt;= 10:\n        draw_sierpinski(length \/\/ 2)\n    draw_triangle(length)\n\n\n\n\n\n\n# Generate rainbow colors\nnum_colors = 6 # You can adjust this number for more or fewer colors\nrainbow_colors = rainbow_color_interpolation(num_colors)\n\n# Main drawing loop\nwhile True:\n    for color_value in rainbow_colors:\n        color(color_value)  # Set the turtle color\n        draw_sierpinski(120)\n        # Pause for a moment before the next drawing<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"125\" height=\"110\" src=\"https:\/\/theroyalscode.com\/students\/a_carpenter\/wp-content\/uploads\/2025\/03\/FINALLY.png\" alt=\"\" class=\"wp-image-159\" style=\"width:650px;height:auto\"\/><\/figure>\n\n\n\n<p class=\"has-contrast-color has-text-color has-link-color has-large-font-size wp-elements-2efa7287cff8eac501d239fe706cbd21\" style=\"border-width:5px;border-radius:10px\"><strong>And an image from Pennwest\/Edinboro&#8217;s Chaos Game Website (This Website is super cool check it out at <a href=\"https:\/\/prodweb2.cis.pennwest.edu\/sierpinski\/\" target=\"_blank\" rel=\"noreferrer noopener\">prodweb2.cis.pennwest.edu\/sierpinski\/<\/a><\/strong>)<strong>: <\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"498\" height=\"500\" src=\"https:\/\/theroyalscode.com\/students\/a_carpenter\/wp-content\/uploads\/2025\/03\/Sierpisnki_Chaos_Game.png\" alt=\"\" class=\"wp-image-162\" style=\"width:650px;height:auto\" srcset=\"https:\/\/theroyalscode.com\/students\/a_carpenter\/wp-content\/uploads\/2025\/03\/Sierpisnki_Chaos_Game.png 498w, https:\/\/theroyalscode.com\/students\/a_carpenter\/wp-content\/uploads\/2025\/03\/Sierpisnki_Chaos_Game-300x300.png 300w, https:\/\/theroyalscode.com\/students\/a_carpenter\/wp-content\/uploads\/2025\/03\/Sierpisnki_Chaos_Game-150x150.png 150w\" sizes=\"auto, (max-width: 498px) 100vw, 498px\" \/><\/figure>\n\n\n\n<p class=\"has-large-font-size\" style=\"border-width:5px;border-radius:10px\"><strong>As can be seen, the program successfully makes a Sierpinski&#8217;s Triangle despite taking a very long time even for just this small one, I have tried to tweak the numbers to fix this issue, but I haven&#8217;t yet found any values that would make it work properly and make a true Sierpinski triangle as I have found can be made. I will now show a larger scale test with a length increase of 100:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-video\"><video height=\"720\" style=\"aspect-ratio: 1280 \/ 720;\" width=\"1280\" controls src=\"https:\/\/theroyalscode.com\/students\/a_carpenter\/wp-content\/uploads\/2025\/03\/2025-03-27-11-00-45.mkv\"><\/video><\/figure>\n\n\n\n<p class=\"has-large-font-size\" style=\"border-width:5px;border-radius:10px\"><strong>As you can see, it takes a long time for the turtle to do anything because it keeps tracing back over itself because of the way that the function recursion is working, and I can&#8217;t lower the amount of function recursions, or it does not make a proper Sierpinski triangle.<\/strong> <strong>Here is the picture of the completed product of the test with 220 length, which took me over an hour to complete.<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"367\" height=\"306\" src=\"https:\/\/theroyalscode.com\/students\/a_carpenter\/wp-content\/uploads\/2025\/03\/FinallyAGAIN.png\" alt=\"\" class=\"wp-image-167\" style=\"width:650px;height:auto\" srcset=\"https:\/\/theroyalscode.com\/students\/a_carpenter\/wp-content\/uploads\/2025\/03\/FinallyAGAIN.png 367w, https:\/\/theroyalscode.com\/students\/a_carpenter\/wp-content\/uploads\/2025\/03\/FinallyAGAIN-300x250.png 300w\" sizes=\"auto, (max-width: 367px) 100vw, 367px\" \/><\/figure>\n\n\n\n<p class=\"has-large-font-size\" style=\"border-width:5px;border-radius:10px\"><strong>And it completed it, it took from 10:35-11:37 to complete.<\/strong> <strong>Honestly, I tumbled across the number of recursions to make it work but, I am glad it did<\/strong>, <strong>because<\/strong> <strong>now I have a way to make any computer crash just by drawing too big of a triangle which did actually happen to me, I bluescreened off a triangle.<\/strong><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today I did testing with something I&#8217;ve been working on over this past week. I have been working with Python Turtle Graphics and have been trying to make the Sierpisnki triangle with rainbow colors and I finally, finally, finally have found the proper algorithm, so here it is, the code for it alongside an image [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-158","post","type-post","status-publish","format-standard","hentry","category-friday"],"_links":{"self":[{"href":"https:\/\/theroyalscode.com\/students\/a_carpenter\/wp-json\/wp\/v2\/posts\/158","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theroyalscode.com\/students\/a_carpenter\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/theroyalscode.com\/students\/a_carpenter\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/a_carpenter\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/a_carpenter\/wp-json\/wp\/v2\/comments?post=158"}],"version-history":[{"count":7,"href":"https:\/\/theroyalscode.com\/students\/a_carpenter\/wp-json\/wp\/v2\/posts\/158\/revisions"}],"predecessor-version":[{"id":170,"href":"https:\/\/theroyalscode.com\/students\/a_carpenter\/wp-json\/wp\/v2\/posts\/158\/revisions\/170"}],"wp:attachment":[{"href":"https:\/\/theroyalscode.com\/students\/a_carpenter\/wp-json\/wp\/v2\/media?parent=158"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/a_carpenter\/wp-json\/wp\/v2\/categories?post=158"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/a_carpenter\/wp-json\/wp\/v2\/tags?post=158"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}