{ "cells": [ { "cell_type": "markdown", "id": "q2x236nvt0d", "metadata": {}, "source": [ "# KidLisp Cards — Visual Preview\n", "\n", "Tiny koans of KidLisp wisdom. Each program is 2-4 lines and produces a static pattern.\n", "\n", "This notebook renders each card using a minimal Python KidLisp interpreter (PIL-based) so we can see the output instantly and curate the best ones for the card deck." ] }, { "cell_type": "code", "execution_count": null, "id": "er6d68jtzz6", "metadata": {}, "outputs": [], "source": [ "import sys, os; sys.path.insert(0, os.path.join(os.getcwd(), \"notebooks\") if not os.getcwd().endswith(\"notebooks\") else os.getcwd())\n", "from ac import show_card" ] }, { "cell_type": "markdown", "id": "s6ssh45ry6", "metadata": {}, "source": [ "## Lines" ] }, { "cell_type": "code", "execution_count": 4, "id": "7sgh977d8vd", "metadata": {}, "outputs": [ { "ename": "NameError", "evalue": "name 'show_card' is not defined", "output_type": "error", "traceback": [ "\u001b[31m---------------------------------------------------------------------------\u001b[39m", "\u001b[31mNameError\u001b[39m Traceback (most recent call last)", "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[4]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m \u001b[43mshow_card\u001b[49m(\u001b[33m\"\u001b[39m\u001b[33mStarburst\u001b[39m\u001b[33m\"\u001b[39m, \u001b[33m\"\"\"\u001b[39m\u001b[33m(wipe black)\u001b[39m\n\u001b[32m 2\u001b[39m \u001b[33m(ink white)\u001b[39m\n\u001b[32m 3\u001b[39m \u001b[33m(repeat 72 i (line 80 60 (+ 80 (* 55 (cos (* i 0.087)))) (+ 60 (* 55 (sin (* i 0.087))))))\u001b[39m\u001b[33m\"\"\"\u001b[39m)\n\u001b[32m 5\u001b[39m show_card(\u001b[33m\"\u001b[39m\u001b[33mCrosshatch\u001b[39m\u001b[33m\"\u001b[39m, \u001b[33m\"\"\"\u001b[39m\u001b[33m(wipe white)\u001b[39m\n\u001b[32m 6\u001b[39m \u001b[33m(ink 0 0 0 40)\u001b[39m\n\u001b[32m 7\u001b[39m \u001b[33m(repeat 40 i (line (* i 4) 0 (* i 4) 120))\u001b[39m\n\u001b[32m 8\u001b[39m \u001b[33m(repeat 40 i (line 0 (* i 3) 160 (* i 3)))\u001b[39m\u001b[33m\"\"\"\u001b[39m)\n\u001b[32m 10\u001b[39m show_card(\u001b[33m\"\u001b[39m\u001b[33mVanish\u001b[39m\u001b[33m\"\u001b[39m, \u001b[33m\"\"\"\u001b[39m\u001b[33m(wipe navy)\u001b[39m\n\u001b[32m 11\u001b[39m \u001b[33m(ink cyan)\u001b[39m\n\u001b[32m 12\u001b[39m \u001b[33m(repeat 30 i (line 0 (* i 4) 160 60))\u001b[39m\n\u001b[32m 13\u001b[39m \u001b[33m(repeat 30 i (line 160 (* i 4) 0 60))\u001b[39m\u001b[33m\"\"\"\u001b[39m)\n", "\u001b[31mNameError\u001b[39m: name 'show_card' is not defined" ] } ], "source": [ "show_card(\"Starburst\", \"\"\"(wipe black)\n", "(ink white)\n", "(repeat 72 i (line 80 60 (+ 80 (* 55 (cos (* i 0.087)))) (+ 60 (* 55 (sin (* i 0.087))))))\"\"\")\n", "\n", "show_card(\"Crosshatch\", \"\"\"(wipe white)\n", "(ink 0 0 0 40)\n", "(repeat 40 i (line (* i 4) 0 (* i 4) 120))\n", "(repeat 40 i (line 0 (* i 3) 160 (* i 3)))\"\"\")\n", "\n", "show_card(\"Vanish\", \"\"\"(wipe navy)\n", "(ink cyan)\n", "(repeat 30 i (line 0 (* i 4) 160 60))\n", "(repeat 30 i (line 160 (* i 4) 0 60))\"\"\")\n", "\n", "show_card(\"Envelope\", \"\"\"(wipe black)\n", "(ink lime)\n", "(repeat 50 i (line 0 (* i 2.4) (* i 3.2) 0))\n", "(repeat 50 i (line 160 (- 120 (* i 2.4)) (- 160 (* i 3.2)) 120))\"\"\")" ] }, { "cell_type": "markdown", "id": "4ninytc16d8", "metadata": {}, "source": [ "## Circles" ] }, { "cell_type": "code", "execution_count": null, "id": "0tycfrpodz4", "metadata": {}, "outputs": [], "source": [ "show_card(\"Ripple\", \"\"\"(wipe black)\n", "(outline)\n", "(repeat 30 i (ink 0 (* i 8) 255) (circle 80 60 (* i 4)))\"\"\")\n", "\n", "show_card(\"Dots\", \"\"\"(wipe white)\n", "(ink black)\n", "(repeat 10 y (repeat 10 x (circle (+ 12 (* x 16)) (+ 10 (* y 12)) 3)))\"\"\")\n", "\n", "show_card(\"Target\", \"\"\"(wipe white)\n", "(repeat 8 i (if (% i 2) (ink red) (ink white)) (circle 80 60 (- 64 (* i 8))))\"\"\")\n", "\n", "show_card(\"Eclipse\", \"\"\"(wipe navy)\n", "(ink yellow)\n", "(circle 80 60 40)\n", "(ink navy)\n", "(circle 90 55 38)\"\"\")" ] }, { "cell_type": "markdown", "id": "40byx7c911s", "metadata": {}, "source": [ "## Boxes & Composition" ] }, { "cell_type": "code", "execution_count": null, "id": "05w5tk8q077", "metadata": {}, "outputs": [], "source": [ "show_card(\"Mondrian\", \"\"\"(wipe white)\n", "(ink red) (box 5 5 50 40)\n", "(ink blue) (box 60 50 100 65)\n", "(ink yellow) (box 5 50 50 30)\n", "(ink black) (stroke 3) (outline) (box 5 5 155 115)\"\"\")\n", "\n", "show_card(\"Quilt\", \"\"\"(resolution 16 12)\n", "(repeat 12 y (repeat 16 x (ink (* x 16) (* y 20) 128) (box x y 1 1)))\"\"\")\n", "\n", "show_card(\"Nest\", \"\"\"(wipe black)\n", "(repeat 10 i (ink (* i 25) 100 (- 255 (* i 25))) (box (* i 7) (* i 5) (- 160 (* i 14)) (- 120 (* i 10))))\"\"\")\n", "\n", "show_card(\"Bars\", \"\"\"(wipe black)\n", "(repeat 8 i (ink (% (* i 50) 256) (% (* i 80) 256) (% (* i 110) 256)) (box (* i 20) 0 20 120))\"\"\")" ] }, { "cell_type": "markdown", "id": "unkf6grdp8", "metadata": {}, "source": [ "## Math & Curves" ] }, { "cell_type": "code", "execution_count": null, "id": "a8evfobqyxq", "metadata": {}, "outputs": [], "source": [ "show_card(\"Wave\", \"\"\"(wipe white)\n", "(ink navy)\n", "(repeat 160 x (plot x (+ 60 (* 40 (sin (* x 0.05))))))\"\"\")\n", "\n", "show_card(\"Lissajous\", \"\"\"(wipe black)\n", "(ink lime)\n", "(repeat 600 t (plot (+ 80 (* 60 (sin (* t 0.03)))) (+ 60 (* 50 (cos (* t 0.02))))))\"\"\")\n", "\n", "show_card(\"Spiral\", \"\"\"(wipe black)\n", "(ink white)\n", "(repeat 500 t (plot (+ 80 (* (/ t 10) (cos (* t 0.1)))) (+ 60 (* (/ t 10) (sin (* t 0.1))))))\"\"\")\n", "\n", "show_card(\"Honeycomb\", \"\"\"(wipe black)\n", "(repeat 6 y (repeat 8 x (ink (* x 30) (* y 40) 200) (circle (+ 10 (* x 20) (* (% y 2) 10)) (+ 12 (* y 20)) 9)))\"\"\")" ] }, { "cell_type": "markdown", "id": "aqjo63z2r7p", "metadata": {}, "source": [ "## Color & Gradients" ] }, { "cell_type": "code", "execution_count": null, "id": "dxxq5urzy17", "metadata": {}, "outputs": [], "source": [ "show_card(\"Spectrum\", \"\"\"(resolution 160 1)\n", "(repeat 160 x (ink x (* 1.5 (abs (- x 80))) (- 255 x)) (box x 0 1 1))\"\"\", h=1, scale=120)\n", "\n", "show_card(\"Field\", \"\"\"(resolution 32 24)\n", "(repeat 24 y (repeat 32 x (ink (* x 8) (* y 10) 128) (plot x y)))\"\"\", w=32, h=24, scale=15)\n", "\n", "show_card(\"Chevron\", \"\"\"(wipe black)\n", "(repeat 8 i (ink (* i 30) 100 255) (tri 0 (* i 15) 80 (+ 10 (* i 15)) 160 (* i 15)))\"\"\")\n", "\n", "show_card(\"Sierpinski\", \"\"\"(wipe black)\n", "(ink white)\n", "(repeat 128 y (repeat 128 x (if (= 0 (& x y)) (plot (+ 16 x) y))))\"\"\", w=160, h=128, scale=3)" ] }, { "cell_type": "markdown", "id": "ft0wiveuvbc", "metadata": {}, "source": [ "## Dense Patterns (pushing repeat + math)" ] }, { "cell_type": "code", "execution_count": null, "id": "1qwvoo6ztn3", "metadata": {}, "outputs": [], "source": [ "show_card(\"Moire\", \"\"\"(wipe white)\n", "(ink 0 0 0 60)\n", "(repeat 80 i (circle 60 60 (* i 2)))\n", "(repeat 80 i (circle 100 60 (* i 2)))\"\"\")\n", "\n", "show_card(\"Plaid\", \"\"\"(wipe white)\n", "(repeat 16 i (ink 200 0 0 50) (box (* i 10) 0 5 120))\n", "(repeat 12 i (ink 0 0 200 50) (box 0 (* i 10) 160 5))\"\"\")\n", "\n", "show_card(\"Sunflower\", \"\"\"(wipe black)\n", "(repeat 500 i\n", " (ink (* (% i 8) 32) (+ 100 (% (* i 7) 155)) (* (% i 5) 50))\n", " (plot (+ 80 (* (* i 0.1) (cos (* i 2.4)))) (+ 60 (* (* i 0.1) (sin (* i 2.4))))))\"\"\")\n", "\n", "show_card(\"Interference\", \"\"\"(wipe black)\n", "(repeat 120 y (repeat 160 x\n", " (if (= 0 (% (+ (* x x) (* y y)) 17))\n", " (do (ink 255 255 255) (plot x y)))))\"\"\")" ] }, { "cell_type": "markdown", "id": "93747ahdb9h", "metadata": {}, "source": [ "## Minimal Koans (1-2 lines)" ] }, { "cell_type": "code", "execution_count": null, "id": "t94n554r7s", "metadata": {}, "outputs": [], "source": [ "show_card(\"Horizon\", \"\"\"(wipe navy)\n", "(ink gold)\n", "(box 0 70 160 50)\"\"\")\n", "\n", "show_card(\"Pip\", \"\"\"(wipe black)\n", "(ink red)\n", "(circle 80 60 4)\"\"\")\n", "\n", "show_card(\"Cross\", \"\"\"(wipe white)\n", "(ink black)\n", "(box 75 20 10 80)\n", "(box 40 50 80 10)\"\"\")\n", "\n", "show_card(\"Corner\", \"\"\"(wipe black)\n", "(ink cyan)\n", "(line 0 0 160 120)\n", "(ink magenta)\n", "(line 160 0 0 120)\"\"\")" ] }, { "cell_type": "markdown", "id": "buarwrf1xi8", "metadata": {}, "source": [ "## Turtle Graphics (crawl, left, right, goto, face)" ] }, { "cell_type": "code", "execution_count": null, "id": "kk5izjajmv", "metadata": {}, "outputs": [], "source": [ "show_card(\"Square\", \"\"\"(wipe black)\n", "(ink white)\n", "(repeat 4 i (crawl 40) (right 90))\"\"\")\n", "\n", "show_card(\"Star\", \"\"\"(wipe navy)\n", "(ink yellow)\n", "(repeat 5 i (crawl 50) (right 144))\"\"\")\n", "\n", "show_card(\"Spiral Walk\", \"\"\"(wipe black)\n", "(ink cyan)\n", "(repeat 100 i (crawl (* i 0.5)) (right 30))\"\"\")\n", "\n", "show_card(\"Hexagon\", \"\"\"(wipe black)\n", "(ink magenta)\n", "(repeat 6 i (crawl 30) (right 60))\"\"\")" ] }, { "cell_type": "code", "execution_count": null, "id": "0gc4to6khg7k", "metadata": {}, "outputs": [], "source": [ "show_card(\"Snowflake\", \"\"\"(wipe navy)\n", "(ink white)\n", "(repeat 6 i\n", " (repeat 3 j (crawl 20) (right 60) (crawl 20) (left 120))\n", " (right 60))\"\"\")\n", "\n", "show_card(\"Polygon Ring\", \"\"\"(wipe black)\n", "(repeat 36 i\n", " (ink (* i 7) 128 255)\n", " (goto 80 60) (face (* i 10))\n", " (crawl 40) (right 90) (crawl 15) (right 90) (crawl 15))\"\"\")\n", "\n", "show_card(\"Tree\", \"\"\"(wipe black)\n", "(ink green) (goto 80 110) (face 270)\n", "(later branch len\n", " (if (> len 3)\n", " (do (crawl len) (left 30) (branch (* len 0.7))\n", " (right 60) (branch (* len 0.7)) (left 30)\n", " (up) (crawl (- 0 len)) (down))))\n", "(branch 35)\"\"\")\n", "\n", "show_card(\"Zigzag\", \"\"\"(wipe white)\n", "(ink coral) (goto 10 60) (face 0)\n", "(repeat 15 i\n", " (crawl 10) (if (% i 2) (right 120) (left 120)))\"\"\")" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.14" } }, "nbformat": 4, "nbformat_minor": 5 }