Created
January 2, 2016 15:33
-
-
Save jikkenyametatta/0bf85e2cebfb68be28f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
@author: jojida jonjirou | |
""" | |
import numpy as np | |
import calendar | |
from reportlab.pdfgen import canvas | |
from reportlab.pdfbase import pdfmetrics | |
from reportlab.pdfbase.cidfonts import UnicodeCIDFont | |
from reportlab.lib.units import cm | |
def drawClock(pdfFile,x,y,daystr): | |
radius = 2.6 | |
pdfFile.setLineWidth(0.3) | |
pdfFile.setStrokeColorRGB(0.2,0.2,0.2) | |
pdfFile.setFillColorRGB(0.2,0.2,0.2) | |
pdfFile.setFont("Helvetica",10) | |
pdfFile.circle(x*cm,y*cm,radius*cm,stroke=1,fill=0) | |
pdfFile.drawString((x-1.5)*cm,(y+3.5)*cm,"{0}".format(daystr)) | |
for time in range(0, 24): | |
theta = -2.0*np.pi*time/24.0 + np.pi/2.0 | |
xx = x + radius*np.cos(theta) | |
yy = y + radius*np.sin(theta) | |
pdfFile.line(x*cm,y*cm,xx*cm,yy*cm) | |
xxx = xx + 0.4*np.cos(theta) - 0.25 | |
yyy = yy + 0.4*np.sin(theta) - 0.15 | |
pdfFile.drawString(xxx*cm,yyy*cm,"{0: 2d}".format(time)) | |
pdfFile.setFillColorRGB(1,1,1) | |
pdfFile.circle(x*cm,y*cm,radius*0.9*cm,stroke=0,fill=1) | |
pdfFile.circle(x*cm,y*cm,radius*0.05*cm,stroke=1,fill=0) | |
if __name__ == "__main__": | |
pdfFile = canvas.Canvas("./jojidatecyo.pdf") | |
pdfFile.saveState() | |
pdfFile.setAuthor("jojida jonjirou") | |
pdfFile.setTitle("tecyou") | |
pdfFile.setSubject("tecyou") | |
pdfFile.setPageCompression(0) | |
#MIHIRAKI B5 | |
pdfFile.setPageSize((25.7*cm,18.2*cm)) | |
#layout | |
cx = [] | |
for i in range(4): | |
cx.append(i*6.2 + 3.1) | |
cy = [] | |
for i in range(2): | |
cy.append(i*8.5 + 3.5) | |
year = 2016 | |
month = 1 | |
c1 = calendar.Calendar() | |
for ele in c1.itermonthdays2(year, month): | |
print '(%2d,%2d)' % (ele[0], ele[1]), | |
i = ele[1] | |
ix = int(i%4) | |
iy = int(1-i/4) | |
dayOfTheWeek = ["Mon","Tue","Wed","Thu","Fri","Sat","Sun"] | |
date = "{0}/{1:02d}/{2:02d} ({3})".format(year,month,ele[0],dayOfTheWeek[i]) | |
if ele[0] == 0: | |
date="" | |
drawClock(pdfFile,cx[ix],cy[iy],date) | |
if i == 6: | |
pdfFile.setFillColorRGB(0.2,0.2,0.2) | |
pdfmetrics.registerFont(UnicodeCIDFont("HeiseiKakuGo-W5")) | |
pdfFile.setFont("HeiseiKakuGo-W5",12) | |
pdfFile.drawString(19*cm,7*cm,"今週見たAVとその感想") | |
pdfFile.showPage() | |
pdfFile.save() | |
# pdfFile.restoreState() | |
pdfFile.save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment