{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "137674b9",
   "metadata": {},
   "source": [
    "# 12-04 · Spirale!\n",
    "\n",
    "Praktyka do sekcji [„Projekt 12-4”](/pl/chapters/rozdzial-12/12-04-spirali.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4aa3f317",
   "metadata": {},
   "source": [
    "## Cel\n",
    "\n",
    "Narysuj wszystkie pięć wersji spirali."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "955c5acb",
   "metadata": {},
   "source": [
    "## Ustawienie (wykonać raz)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "29483bc7",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-17T16:39:13.409890Z",
     "iopub.status.busy": "2026-08-17T16:39:13.409720Z",
     "iopub.status.idle": "2026-08-17T16:39:13.580163Z",
     "shell.execute_reply": "2026-08-17T16:39:13.579628Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Окно Turtle готово.\n"
     ]
    }
   ],
   "source": [
    "import turtle\n",
    "\n",
    "screen = turtle.Screen()\n",
    "artist = turtle.Turtle()\n",
    "artist.speed(0)\n",
    "print(\"Окно Turtle готово.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9f520287",
   "metadata": {},
   "source": [
    "## Kwadratowa spirala"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "dba969cd",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-17T16:39:13.581144Z",
     "iopub.status.busy": "2026-08-17T16:39:13.581032Z",
     "iopub.status.idle": "2026-08-17T16:39:26.360560Z",
     "shell.execute_reply": "2026-08-17T16:39:26.360164Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Квадратная спираль готова.\n"
     ]
    }
   ],
   "source": [
    "artist.reset()\n",
    "dlina = 5\n",
    "for _ in range(60):\n",
    "    artist.forward(dlina)\n",
    "    artist.right(90)\n",
    "    dlina += 3\n",
    "print(\"Квадратная спираль готова.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c2fb8aaf",
   "metadata": {},
   "source": [
    "## Losowa spirala"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "ad92c875",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-17T16:39:26.361788Z",
     "iopub.status.busy": "2026-08-17T16:39:26.361679Z",
     "iopub.status.idle": "2026-08-17T16:39:38.908048Z",
     "shell.execute_reply": "2026-08-17T16:39:38.907507Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Случайная спираль готова.\n"
     ]
    }
   ],
   "source": [
    "import random\n",
    "\n",
    "artist.reset()\n",
    "dlina = 5\n",
    "for _ in range(60):\n",
    "    artist.forward(dlina)\n",
    "    artist.right(random.randint(80, 100))\n",
    "    dlina += 3\n",
    "print(\"Случайная спираль готова.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "94c6960a",
   "metadata": {},
   "source": [
    "## Trójkątna spirala"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "c8e3b42c",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-17T16:39:38.909035Z",
     "iopub.status.busy": "2026-08-17T16:39:38.908913Z",
     "iopub.status.idle": "2026-08-17T16:39:53.608386Z",
     "shell.execute_reply": "2026-08-17T16:39:53.607983Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Треугольная спираль готова.\n"
     ]
    }
   ],
   "source": [
    "artist.reset()\n",
    "dlina = 5\n",
    "for _ in range(60):\n",
    "    artist.forward(dlina)\n",
    "    artist.right(120)\n",
    "    dlina += 3\n",
    "print(\"Треугольная спираль готова.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2f7ac806",
   "metadata": {},
   "source": [
    "## Gwiezdna Spirala"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "fdf0a54a",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-17T16:39:53.609426Z",
     "iopub.status.busy": "2026-08-17T16:39:53.609320Z",
     "iopub.status.idle": "2026-08-17T16:40:22.304822Z",
     "shell.execute_reply": "2026-08-17T16:40:22.304263Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Звёздная спираль готова.\n"
     ]
    }
   ],
   "source": [
    "artist.reset()\n",
    "dlina = 5\n",
    "for _ in range(100):\n",
    "    artist.forward(dlina)\n",
    "    artist.right(144)\n",
    "    dlina += 2\n",
    "print(\"Звёздная спираль готова.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "841f60bc",
   "metadata": {},
   "source": [
    "## Spiralna kołowa"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "c91f96a6",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-17T16:40:22.305761Z",
     "iopub.status.busy": "2026-08-17T16:40:22.305637Z",
     "iopub.status.idle": "2026-08-17T16:40:48.680534Z",
     "shell.execute_reply": "2026-08-17T16:40:48.680038Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Круговая спираль готова.\n"
     ]
    }
   ],
   "source": [
    "artist.reset()\n",
    "radius = 5\n",
    "for _ in range(60):\n",
    "    artist.circle(radius, 90)\n",
    "    radius += 3\n",
    "print(\"Круговая спираль готова.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "82261f96",
   "metadata": {},
   "source": [
    "## Ukończenie (wykonaj raz, na samym końcu)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "55726cdf",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-17T16:40:48.681488Z",
     "iopub.status.busy": "2026-08-17T16:40:48.681379Z",
     "iopub.status.idle": "2026-08-17T16:40:48.684202Z",
     "shell.execute_reply": "2026-08-17T16:40:48.683813Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Окно Turtle закрыто.\n"
     ]
    }
   ],
   "source": [
    "screen.bye()\n",
    "print(\"Окно Turtle закрыто.\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Cartesian Python 3.14",
   "language": "python",
   "name": "cartesian-python314"
  },
  "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.14.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
