{ "cells": [ { "cell_type": "code", "execution_count": 58, "id": "7509b086-30fd-484a-9487-233aba8765f5", "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "you are in an empty room with 13 doors that are portals to 13 different worlds.you are in an empty room with 13 doors that are portals to 13 different worlds.you are in an empty room with 13 doors that are portals to 13 different worlds.you are in an empty room with 13 doors that are portals to 13 different worlds.you are in an empty room with 13 doors that are portals to 13 different worlds.you are in an empty room with 13 doors that are portals to 13 different worlds.you are in an empty room with 13 doors that are portals to 13 different worlds.you are in an empty room with 13 doors that are portals to 13 different worlds.you are in an empty room with 13 doors that are portals to 13 different worlds.you are in an empty room with 13 doors that are portals to 13 different worlds.you are in an empty room with 13 doors that are portals to 13 different worlds.you are in an empty room with 13 doors that are portals to 13 different worlds." ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import svgwrite\n", "from svgwrite import cm, mm\n", "from math import floor\n", "from IPython.core.display import SVG, display\n", "import frontmatter\n", "\n", "\n", "debug = True\n", "\n", "# We are using real world sizes in order to match with the post-it placeholders \n", "\n", "width = 210\n", "height = 297\n", "\n", "postit_width = 70\n", "postit_height = 70\n", "\n", "rows = floor(height / postit_height)\n", "columns = floor(width / postit_width)\n", "\n", "\n", "color = svgwrite.rgb(0,0,0, '%')\n", "background = svgwrite.rgb(100,95,95,'%')\n", "\n", "\n", "# setup the SVG\n", "sheet = svgwrite.Drawing('post-it.svg', profile='tiny', size=(width * mm, height * mm))\n", "\n", "\n", "# draw debug helper grid\n", "if debug:\n", " helpers = sheet.add(sheet.g(id='helpers', stroke='dodgerblue')).dasharray([5, 5])\n", "\n", " for row in range(rows + 1):\n", " y = postit_height * row \n", " helpers.add(sheet.line((0, y * mm), (postit_width * columns * mm, y * mm)))\n", "\n", " for col in range(columns + 1):\n", " x = postit_width * col\n", " helpers.add(sheet.line((x * mm, 0), (x * mm, postit_height * rows * mm)))\n", "\n", "\n", "import frontmatter\n", "with open(\"1sentencegames/contents.md\", \"r\") as f:\n", " metadata, content = frontmatter.parse(f.read())\n", " contents = metadata['contents']\n", "\n", " \n", "for row in range(rows):\n", " for col in range(columns):\n", " \n", " x = postit_width * col \n", " y = postit_height * row \n", " \n", " \n", " textArea = sheet.text(\n", " contents[0],\n", " insert=(x * mm,y * mm),\n", " stroke='none',\n", " fill=color,\n", " font_size='12px'\n", " )\n", " \n", " sheet.add(textArea)\n", " \n", " \n", " \n", " \n", "\n", " \n", "\n", "\n", " \n", " \n", "sheet.save()\n", "display(SVG(filename=f'post-it.svg'))" ] }, { "cell_type": "code", "execution_count": 17, "id": "d334c0ec-fbbb-4437-b848-a69871fbf983", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "5 min slow-mo epidemics, visual transmitted\n" ] } ], "source": [ "\n", " \n", " \n" ] }, { "cell_type": "code", "execution_count": null, "id": "72506b55-7151-4407-ab36-0dd5adfc3855", "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.7.3" } }, "nbformat": 4, "nbformat_minor": 5 }