Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible to get this formatting? #6

Open
wrybread opened this issue Mar 14, 2019 · 2 comments
Open

Possible to get this formatting? #6

wrybread opened this issue Mar 14, 2019 · 2 comments

Comments

@wrybread
Copy link

I'm using this calendar as a model:

http://gizmoware.net/tides/clamming/model.pdf

This is my current progress:

http://gizmoware.net/tides/clamming/2019.pdf

The main thing I can't figure out is how to add "inner padding" between the calendars. What I mean by that is separating the calendars with some space, but with only a single line between the calendars (as in model.pdf) as opposed to each calendar drawing a border. I think that looks a lot cleaner design wise.

I also can't figure out how to add a little padding above and below the month name.

I'm fine with modifying the code to achieve this. Currently I'm editing layouts/classic.py to remove the boxes around the day names, and layouts/_base.py to get the different colors for different holiday types (in my case that's different levels of low tide to indicate how good the clamming will be on that day).

@geotz
Copy link
Owner

geotz commented Mar 17, 2019

Hello,

I've managed to get something close to your model which I believe with your design (fonts, colors etc.) will look much better. I have disabled the boxes around month & day names, it suffices to pass argument stroke_rgba=None to the draw_box routine, but you've already figured that out. For the month box itself it is a bit more tricky:
First, I am cheating a little bit: if the box has no fill (fill_rgba=None), which is the case for the whole month box frame, then I draw the whole border. I the box has fill (which is the case for each day cell), then I draw only the top side -- this accumulates into horizontal lines.
For the whole month box, I draw the frame with global --padding=0 (command-line argument), so that they become adjoint tiles.
For the interior, I am adding a bit of a border so that the horizontal lines do not touch the frame.
I send you the patch to see which parts of the code I have modified, as well as a sample of the final result.
If you need extra border only around month name, you can apply the same technique to shrink the rect as I did for the interior of the month frame.

lightweight-patch.txt
lightweight.pdf

@wrybread
Copy link
Author

wrybread commented Mar 19, 2019

Thank you so much, works perfectly. A small change that I think is a fix. In classic.py, I changed this line:
rect2 = (rect2[0]+offset[0]/2.0, rect2[1]+offset[1]/2.0, rect2[2], rect2[3])

To:
rect2 = (rect2[0]+offset[0], rect2[1]+offset[1], rect2[2], rect2[3])

Otherwise the centering wasn't working for me. This gets more apparent if you change the amount of inner padding to some number other than 2 as in your patch.

And if anyone wants to add an "--inner_padding" CLI option, here's my changes. I'm glad to post as a diff file, but my files are already heavily modified so just posting notes for now:

In classic.py, change:

grid = GLayout(rect_from_origin(rect), 7, 7)

To:

        if self.options.inner_padding:
            pad = mm_to_dots(self.options.inner_padding); # compute padding from mm to our coordinate system
            rect2 = rect_pad(rect, (pad,)*4) # shrink month rect by pad
            offset = (rect2[0]-rect[0],rect2[1]-rect[1]) # get offset of new top-left corner wrt prev rect
            rect2 = rect_from_origin(rect2); # move new rect to origin (for grid computation)
            rect2 = (rect2[0]+offset[0], rect2[1]+offset[1], rect2[2], rect2[3])             
            grid = GLayout(rect2, 7, 7)
        else:
            grid = GLayout(rect_from_origin(rect), 7, 7)

And in /layouts/_base.py add this line below the line with "--padding":

    parser.add_option("--inner_padding", type="float", default=None,
                      help="set some padding inside of the month boundaries. Experimental.")

To produce my calendar I'm then running:

callirhoe.py --cols=3 --padding=0 --inner_padding=8 --no-shadow --dpi=120 --paper=700:800 2019.pdf

Here's my old calendar without this patch:

http://gizmoware.net/tides/clamming/2019-old.pdf

And here's with the patch:

http://gizmoware.net/tides/clamming/2019.pdf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants