{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "b28493a5",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "from perlin_noise import PerlinNoise\n",
    "import numpy as np\n",
    "from ipycanvas import Canvas\n",
    "\n",
    "noise = PerlinNoise(octaves=7, seed=2000)\n",
    "xpix, ypix = 256, 256\n",
    "pic = np.array([[noise([i/xpix, j/ypix])+1/2 for j in range(xpix)] for i in range(ypix)])\n",
    "\n",
    "def pic_to_map(pic):\n",
    "    pic = np.interp(pic, [0, 1], [0, 255])\n",
    "    pic = np.array([[(el, el, el) for el in row] for row in pic])\n",
    "    canvas = Canvas(width=pic.shape[0]*4, height=pic.shape[1]*4).put_image_data(pic, 0, 0)\n",
    "    return canvas\n",
    "\n",
    "c = pic_to_map(pic)\n",
    "c"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "64790f8b",
   "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.8.16"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
