You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

154 lines
6.2 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": 56,
"id": "7509b086-30fd-484a-9487-233aba8765f5",
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"<svg baseProfile=\"tiny\" height=\"297mm\" version=\"1.2\" width=\"210mm\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:ev=\"http://www.w3.org/2001/xml-events\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"><defs/><g id=\"helpers\" stroke=\"dodgerblue\" stroke-dasharray=\"5 5\"><line x1=\"0\" x2=\"210mm\" y1=\"0mm\" y2=\"0mm\"/><line x1=\"0\" x2=\"210mm\" y1=\"70mm\" y2=\"70mm\"/><line x1=\"0\" x2=\"210mm\" y1=\"140mm\" y2=\"140mm\"/><line x1=\"0\" x2=\"210mm\" y1=\"210mm\" y2=\"210mm\"/><line x1=\"0\" x2=\"210mm\" y1=\"280mm\" y2=\"280mm\"/><line x1=\"0mm\" x2=\"0mm\" y1=\"0\" y2=\"280mm\"/><line x1=\"70mm\" x2=\"70mm\" y1=\"0\" y2=\"280mm\"/><line x1=\"140mm\" x2=\"140mm\" y1=\"0\" y2=\"280mm\"/><line x1=\"210mm\" x2=\"210mm\" y1=\"0\" y2=\"280mm\"/></g><textArea fill=\"rgb(0%,0%,0%)\" font-size=\"12px\" height=\"70mm\" stroke=\"none\" width=\"70mm\" x=\"0mm\" y=\"0mm\"><tspan>hehe</tspan></textArea><textArea fill=\"rgb(0%,0%,0%)\" font-size=\"12px\" height=\"70mm\" stroke=\"none\" width=\"70mm\" x=\"70mm\" y=\"0mm\"><tspan>hehe</tspan></textArea><textArea fill=\"rgb(0%,0%,0%)\" font-size=\"12px\" height=\"70mm\" stroke=\"none\" width=\"70mm\" x=\"140mm\" y=\"0mm\"><tspan>hehe</tspan></textArea><textArea fill=\"rgb(0%,0%,0%)\" font-size=\"12px\" height=\"70mm\" stroke=\"none\" width=\"70mm\" x=\"0mm\" y=\"70mm\"><tspan>hehe</tspan></textArea><textArea fill=\"rgb(0%,0%,0%)\" font-size=\"12px\" height=\"70mm\" stroke=\"none\" width=\"70mm\" x=\"70mm\" y=\"70mm\"><tspan>hehe</tspan></textArea><textArea fill=\"rgb(0%,0%,0%)\" font-size=\"12px\" height=\"70mm\" stroke=\"none\" width=\"70mm\" x=\"140mm\" y=\"70mm\"><tspan>hehe</tspan></textArea><textArea fill=\"rgb(0%,0%,0%)\" font-size=\"12px\" height=\"70mm\" stroke=\"none\" width=\"70mm\" x=\"0mm\" y=\"140mm\"><tspan>hehe</tspan></textArea><textArea fill=\"rgb(0%,0%,0%)\" font-size=\"12px\" height=\"70mm\" stroke=\"none\" width=\"70mm\" x=\"70mm\" y=\"140mm\"><tspan>hehe</tspan></textArea><textArea fill=\"rgb(0%,0%,0%)\" font-size=\"12px\" height=\"70mm\" stroke=\"none\" width=\"70mm\" x=\"140mm\" y=\"140mm\"><tspan>hehe</tspan></textArea><textArea fill=\"rgb(0%,0%,0%)\" font-size=\"12px\" height=\"70mm\" stroke=\"none\" width=\"70mm\" x=\"0mm\" y=\"210mm\"><tspan>hehe</tspan></textArea><textArea fill=\"rgb(0%,0%,0%)\" font-size=\"12px\" height=\"70mm\" stroke=\"none\" width=\"70mm\" x=\"70mm\" y=\"210mm\"><tspan>hehe</tspan></textArea><textArea fill=\"rgb(0%,0%,0%)\" font-size=\"12px\" height=\"70mm\" stroke=\"none\" width=\"70mm\" x=\"140mm\" y=\"210mm\"><tspan>hehe</tspan></textArea></svg>"
],
"text/plain": [
"<IPython.core.display.SVG object>"
]
},
"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.textArea(\n",
" 'hehe',\n",
" insert=(x * mm,y * mm),\n",
" width=postit_width * mm,\n",
" height=postit_height * 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
}