Skip to content

Commit

Permalink
[svg] change padding to fit 50 columns in, ignore calendar.svg from n…
Browse files Browse the repository at this point in the history
…ow on
  • Loading branch information
kronicka committed Jan 16, 2019
1 parent 65fb82b commit a3d0746
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
venv/*
.idea/*
.DS_Store
__pycache__/
__pycache__/
calendar.svg
4 changes: 3 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from typing import Tuple
from utils.input import input_all
from utils.draw import draw_text, draw_units_number
from utils.draw_svg import generate_calendar_svg


# TODO: merge functionality for calculating days, weeks (and, maybe, months and years)
Expand Down Expand Up @@ -81,5 +82,6 @@ def generate_calendar(units: int, unit_type: str = 'weeks'):
if __name__ == '__main__':
inputs = input_all()
weeks = calculate_weeks(*inputs)
generate_calendar(weeks)
# generate_calendar(weeks)
generate_calendar_svg(weeks)

2 changes: 1 addition & 1 deletion utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
CAL_HEIGHT = '594mm'
CAL_SIZE = (CAL_WIDTH, CAL_HEIGHT)
CSS_STYLES = """
.square { fill: white; stroke: black; stroke-width: .1mm; padding: .2mm; }
.square { fill: white; stroke: black; stroke-width: .1mm; padding: .1mm; }
"""
12 changes: 6 additions & 6 deletions utils/draw_svg.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import svgwrite
from constants import CAL_SIZE, CSS_STYLES
from utils.constants import CAL_SIZE, CSS_STYLES


def generate_calendar_svg(units: int, unit_type: str = 'weeks'):
Expand All @@ -16,9 +16,9 @@ def group(classname):
return dwg.add(dwg.g(class_=classname))
squares = group('square')

square_size = (8, 8)
cols = 40
padding = 10
square_size = (5, 5)
cols = 50
padding = 11

if unit_type == 'days':
square_size = (1, 1)
Expand All @@ -32,8 +32,8 @@ def group(classname):
cols *= leftover
cols = int(cols)
for col in range(0, cols):
xc = col * 10 + padding
yc = row * 10 + padding
xc = col * 8 + padding
yc = row * 8 + padding
square = dwg.rect(insert=(xc, yc), size=square_size)
squares.add(square)

Expand Down

0 comments on commit a3d0746

Please sign in to comment.