{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "11c29350",
   "metadata": {},
   "source": [
    "# 12-22 · Grafika pikselowa na siatce\n",
    "\n",
    "Praktyka do sekcji [„Project: Pixel graphics on a grid”"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4660f4d6",
   "metadata": {},
   "source": [
    "## Cel\n",
    "\n",
    "Zagnieżdżony lista + zagnieżdżona pętla rysują obraz na macierzy 0/1."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "aa236da7",
   "metadata": {},
   "source": [
    "## Ustawienie (wykonać raz)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "561730fa",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-17T16:41:44.393238Z",
     "iopub.status.busy": "2026-08-17T16:41:44.393136Z",
     "iopub.status.idle": "2026-08-17T16:41:44.552325Z",
     "shell.execute_reply": "2026-08-17T16:41:44.551796Z"
    }
   },
   "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": "d12bcffb",
   "metadata": {},
   "source": [
    "## Sprawa robocza"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "56db220e",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-17T16:41:44.553340Z",
     "iopub.status.busy": "2026-08-17T16:41:44.553221Z",
     "iopub.status.idle": "2026-08-17T16:41:57.029081Z",
     "shell.execute_reply": "2026-08-17T16:41:57.028633Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Готово.\n"
     ]
    }
   ],
   "source": [
    "artist.reset()\n",
    "artist.penup()\n",
    "\n",
    "picture = [\n",
    "    [0, 1, 0, 1, 0],\n",
    "    [1, 1, 1, 1, 1],\n",
    "    [1, 1, 1, 1, 1],\n",
    "    [0, 1, 1, 1, 0],\n",
    "    [0, 0, 1, 0, 0],\n",
    "]\n",
    "\n",
    "razmer = 40\n",
    "for row_index, row in enumerate(picture):\n",
    "    for col_index, value in enumerate(row):\n",
    "        if value == 1:\n",
    "            x = -100 + col_index * razmer\n",
    "            y = 100 - row_index * razmer\n",
    "            artist.goto(x, y)\n",
    "            artist.pendown()\n",
    "            artist.fillcolor(\"#DB2777\")\n",
    "            artist.begin_fill()\n",
    "            for _ in range(4):\n",
    "                artist.forward(razmer)\n",
    "                artist.right(90)\n",
    "            artist.end_fill()\n",
    "            artist.penup()\n",
    "\n",
    "print(\"Готово.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8733a7a1",
   "metadata": {},
   "source": [
    "## Ukończenie (wykonaj raz, na samym końcu)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "cc813872",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-17T16:41:57.030156Z",
     "iopub.status.busy": "2026-08-17T16:41:57.030044Z",
     "iopub.status.idle": "2026-08-17T16:41:57.032997Z",
     "shell.execute_reply": "2026-08-17T16:41:57.032496Z"
    }
   },
   "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
}
