Delete '.ipynb_checkpoints/pieces-background-checkpoint.ipynb'

master^2
km0 2 years ago
parent a9fb29e88f
commit a68cfe18c2

@ -1,95 +0,0 @@
{
"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
}
Loading…
Cancel
Save