commit 6f6915f006d594e448cf590f0337da98bd9ccfce Author: kamo Date: Sun Feb 27 15:52:56 2022 +0000 first test diff --git a/.ipynb_checkpoints/katamari_retro-checkpoint.png b/.ipynb_checkpoints/katamari_retro-checkpoint.png new file mode 100644 index 0000000..61b4618 Binary files /dev/null and b/.ipynb_checkpoints/katamari_retro-checkpoint.png differ diff --git a/.ipynb_checkpoints/pieces-background-checkpoint.ipynb b/.ipynb_checkpoints/pieces-background-checkpoint.ipynb new file mode 100644 index 0000000..b48353b --- /dev/null +++ b/.ipynb_checkpoints/pieces-background-checkpoint.ipynb @@ -0,0 +1,95 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 22, + "id": "7b187c4c-1c53-494d-a30f-fa0431cd4665", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Done!\n" + ] + } + ], + "source": [ + "# generate random ID for the pieces\n", + "from shortuuid import uuid\n", + "\n", + "# to draw the background\n", + "from wand.image import Image\n", + "from wand.drawing import Drawing\n", + "\n", + "# rows and columns for the puzzle\n", + "rows = 10\n", + "columns = 15\n", + "\n", + "# resolution for the print\n", + "dpi = 300\n", + "\n", + "# width and height in cm\n", + "image_width = 15\n", + "image_height = 10\n", + "\n", + "# name of the puzzle to be more legible?\n", + "name = 'katamari'\n", + "\n", + "\n", + "# width and height in pixel\n", + "width = int(dpi / 2.54 * image_width)\n", + "height = int(dpi / 2.54 * image_height)\n", + "\n", + "# piece sizes in pixel\n", + "piece_width = width / rows\n", + "piece_height = height / columns\n", + "\n", + "\n", + "pieces = {}\n", + "\n", + "with Image(width = width, height = height) as img:\n", + " draw = Drawing()\n", + " draw.font_size = 9\n", + " draw.text_alignment = 'center'\n", + " \n", + " for y in range(columns):\n", + " for x in range(rows):\n", + " \n", + " # generate a random ID for each piece \n", + " ID = uuid()[:4]\n", + " \n", + " # write the id in the center of each piece\n", + " draw.text(int(x * piece_width + piece_width/2), int(y*piece_height + piece_height/2), f'{name}\\n{ID}')\n", + " \n", + " # store the id and the position in the pieces dictionary\n", + " pieces[ID] = (x,y)\n", + " \n", + " draw(img)\n", + " img.save(filename=f'{name}_retro.png')\n", + " print('Done!')\n" + ] + } + ], + "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.7.3" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/katamari_retro.png b/katamari_retro.png new file mode 100644 index 0000000..61b4618 Binary files /dev/null and b/katamari_retro.png differ diff --git a/pieces-background.ipynb b/pieces-background.ipynb new file mode 100644 index 0000000..b48353b --- /dev/null +++ b/pieces-background.ipynb @@ -0,0 +1,95 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 22, + "id": "7b187c4c-1c53-494d-a30f-fa0431cd4665", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Done!\n" + ] + } + ], + "source": [ + "# generate random ID for the pieces\n", + "from shortuuid import uuid\n", + "\n", + "# to draw the background\n", + "from wand.image import Image\n", + "from wand.drawing import Drawing\n", + "\n", + "# rows and columns for the puzzle\n", + "rows = 10\n", + "columns = 15\n", + "\n", + "# resolution for the print\n", + "dpi = 300\n", + "\n", + "# width and height in cm\n", + "image_width = 15\n", + "image_height = 10\n", + "\n", + "# name of the puzzle to be more legible?\n", + "name = 'katamari'\n", + "\n", + "\n", + "# width and height in pixel\n", + "width = int(dpi / 2.54 * image_width)\n", + "height = int(dpi / 2.54 * image_height)\n", + "\n", + "# piece sizes in pixel\n", + "piece_width = width / rows\n", + "piece_height = height / columns\n", + "\n", + "\n", + "pieces = {}\n", + "\n", + "with Image(width = width, height = height) as img:\n", + " draw = Drawing()\n", + " draw.font_size = 9\n", + " draw.text_alignment = 'center'\n", + " \n", + " for y in range(columns):\n", + " for x in range(rows):\n", + " \n", + " # generate a random ID for each piece \n", + " ID = uuid()[:4]\n", + " \n", + " # write the id in the center of each piece\n", + " draw.text(int(x * piece_width + piece_width/2), int(y*piece_height + piece_height/2), f'{name}\\n{ID}')\n", + " \n", + " # store the id and the position in the pieces dictionary\n", + " pieces[ID] = (x,y)\n", + " \n", + " draw(img)\n", + " img.save(filename=f'{name}_retro.png')\n", + " print('Done!')\n" + ] + } + ], + "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.7.3" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}