{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "530213e6",
   "metadata": {},
   "source": [
    "# 13-08 · Figury: nowy poziom\n",
    "\n",
    "Praktyka do sekcji [„Mini-projekt – zautomatyzowane figury: nowy poziom”"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b2d5261c",
   "metadata": {},
   "source": [
    "## Cel\n",
    "\n",
    "Zamień rysujące kształty w funkcję wielokrotnego użytku."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "78ee4c51",
   "metadata": {},
   "source": [
    "## Ustawienie (wykonać raz)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "035dbc11",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-17T18:58:55.664401Z",
     "iopub.status.busy": "2026-08-17T18:58:55.664242Z",
     "iopub.status.idle": "2026-08-17T18:58:55.829356Z",
     "shell.execute_reply": "2026-08-17T18:58:55.828880Z"
    }
   },
   "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": "d307d3a8",
   "metadata": {},
   "source": [
    "## Sprawa robocza"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "35f2ba32",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-17T18:58:55.830772Z",
     "iopub.status.busy": "2026-08-17T18:58:55.830638Z",
     "iopub.status.idle": "2026-08-17T18:58:56.729558Z",
     "shell.execute_reply": "2026-08-17T18:58:56.729044Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Квадрат готов.\n"
     ]
    }
   ],
   "source": [
    "def narisovat_figuru(storony, dlina):\n",
    "    ugol = 360 / storony\n",
    "    for _ in range(storony):\n",
    "        artist.forward(dlina)\n",
    "        artist.right(ugol)\n",
    "\n",
    "artist.reset()\n",
    "narisovat_figuru(4, 100)\n",
    "print(\"Квадрат готов.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "aea484d0",
   "metadata": {},
   "source": [
    "## Eksperyment 1 – Wiele kształtów w rzędzie"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "0b1c7856",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-17T18:58:56.730509Z",
     "iopub.status.busy": "2026-08-17T18:58:56.730401Z",
     "iopub.status.idle": "2026-08-17T18:58:58.609804Z",
     "shell.execute_reply": "2026-08-17T18:58:58.609364Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Треугольник готов.\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Восьмиугольник готов.\n"
     ]
    }
   ],
   "source": [
    "artist.reset()\n",
    "narisovat_figuru(3, 100)\n",
    "print(\"Треугольник готов.\")\n",
    "\n",
    "artist.reset()\n",
    "narisovat_figuru(8, 60)\n",
    "print(\"Восьмиугольник готов.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c2c804d0",
   "metadata": {},
   "source": [
    "## Zadanie niezależne od zadania ★★\n",
    "\n",
    "Dodaj x opcji y z domyślnymi wartościami 0, 0."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "a9192a9e",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-17T18:58:58.610862Z",
     "iopub.status.busy": "2026-08-17T18:58:58.610700Z",
     "iopub.status.idle": "2026-08-17T18:59:00.612801Z",
     "shell.execute_reply": "2026-08-17T18:59:00.612316Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Две фигуры в разных точках экрана готовы.\n"
     ]
    }
   ],
   "source": [
    "def narisovat_figuru_v_tochke(storony, dlina, x=0, y=0):\n",
    "    artist.penup()\n",
    "    artist.goto(x, y)\n",
    "    artist.setheading(0)\n",
    "    artist.pendown()\n",
    "    ugol = 360 / storony\n",
    "    for _ in range(storony):\n",
    "        artist.forward(dlina)\n",
    "        artist.right(ugol)\n",
    "\n",
    "artist.reset()\n",
    "narisovat_figuru_v_tochke(4, 60, x=-100, y=0)\n",
    "narisovat_figuru_v_tochke(6, 60, x=100, y=0)\n",
    "print(\"Две фигуры в разных точках экрана готовы.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8c01fdc1",
   "metadata": {},
   "source": [
    "## Ukończenie (wykonaj raz, na samym końcu)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "d2b37301",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-17T18:59:00.613734Z",
     "iopub.status.busy": "2026-08-17T18:59:00.613624Z",
     "iopub.status.idle": "2026-08-17T18:59:00.616497Z",
     "shell.execute_reply": "2026-08-17T18:59:00.616093Z"
    }
   },
   "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
}
