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.

6.2 KiB

In [56]:
import svgwrite
from svgwrite import cm, mm
from math import floor
from IPython.core.display import SVG, display
import frontmatter


debug = True

# We are using real world sizes in order to match with the post-it placeholders 

width = 210
height = 297

postit_width = 70
postit_height = 70

rows = floor(height / postit_height)
columns = floor(width / postit_width)


color = svgwrite.rgb(0,0,0, '%')
background = svgwrite.rgb(100,95,95,'%')


# setup the SVG
sheet = svgwrite.Drawing('post-it.svg', profile='tiny', size=(width * mm, height * mm))


# draw debug helper grid
if debug:
    helpers = sheet.add(sheet.g(id='helpers', stroke='dodgerblue')).dasharray([5, 5])

    for row in range(rows + 1):
        y = postit_height * row 
        helpers.add(sheet.line((0, y * mm), (postit_width * columns * mm, y * mm)))

    for col in range(columns + 1):
        x = postit_width * col
        helpers.add(sheet.line((x * mm, 0), (x * mm, postit_height * rows * mm)))


import frontmatter
with open("1sentencegames/contents.md", "r") as f:
    metadata, content = frontmatter.parse(f.read())
    contents = metadata['contents']

        
for row in range(rows):
    for col in range(columns):
        
        x = postit_width * col 
        y = postit_height * row  
        
        
        textArea = sheet.textArea(
            'hehe',
            insert=(x * mm,y * mm),
            width=postit_width * mm,
            height=postit_height * mm,
            stroke='none',
            fill=color,
            font_size='12px'
        )
            
        sheet.add(textArea)
        
        
                  
                  

        


    
    
sheet.save()
display(SVG(filename=f'post-it.svg'))
<tspan>hehe</tspan><tspan>hehe</tspan><tspan>hehe</tspan><tspan>hehe</tspan><tspan>hehe</tspan><tspan>hehe</tspan><tspan>hehe</tspan><tspan>hehe</tspan><tspan>hehe</tspan><tspan>hehe</tspan><tspan>hehe</tspan><tspan>hehe</tspan>
In [17]:
    
    
5 min slow-mo epidemics, visual transmitted
In [ ]: