{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "22a54670",
   "metadata": {},
   "source": [
    "# Image files"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "c137500c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "PyNSN 0.11.10\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 18088 characters]",
      "text/plain": [
       "<PIL.Image.Image image mode=RGBA size=400x400>"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import pynsn as nsn\n",
    "from pynsn.image import pil_image\n",
    "\n",
    "euro_array = nsn.RectangleArray(target_area_radius=200, min_dist_between_objects=1)\n",
    "# adding eurostar pictures 12 times\n",
    "for x in np.linspace(start=0, stop=2*np.pi, num=12+1):\n",
    "    if x < 2*np.pi:\n",
    "        pos = np.sin(x)*140, np.cos(x)*140\n",
    "        pict = nsn.Rectangle(xy=pos, size=(40, 40), \n",
    "                             attribute=nsn.PictureFile(\"eurostar.png\"))\n",
    "        euro_array.add(pict)\n",
    "\n",
    "# showing\n",
    "euro_col = nsn.ImageColours(target_area=\"#003399\", background=\"#003399\")\n",
    "pil_image.create(euro_array, euro_col)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "ba62657d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 32468 characters]",
      "text/plain": [
       "<PIL.Image.Image image mode=RGBA size=400x400>"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "euro_array.mod_shuffle_positions()\n",
    "pil_image.create(euro_array, euro_col)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "6f268f46",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 23576 characters]",
      "text/plain": [
       "<PIL.Image.Image image mode=RGBA size=400x400>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "factory = nsn.NSNFactory(target_area_radius=200, \n",
    "                         min_dist_between_objects=1)\n",
    "factory.set_appearance_rectangle(width=(10, 20, 30, 40), \n",
    "                                 proportion=1,\n",
    "                                 attributes=nsn.PictureFile(\"eurostar.png\"))\n",
    "euro_array = factory.create_random_array(n_objects=12)\n",
    "pil_image.create(euro_array, euro_col)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "76c796dc",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "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.10.12"
  },
  "vscode": {
   "interpreter": {
    "hash": "916dbcbb3f70747c44a77c7bcd40155683ae19c65e1c03b4aa3499c5328201f1"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
