#! ruby -Ks
require "rubygems"
require "cairo"
require "Rmagick"
require "uconv"

surface = Cairo::ImageSurface.new(Cairo::FORMAT_ARGB32, 1485, 1050)
c = Cairo::Context.new(surface)
#c.set_source_color("white")
c.set_source_rgb(1,1,1)

c.set_line_width(1)
c.rectangle(0,0,1485,1050)
c.fill

#c.set_source_color("black")
c.set_source_rgb(0,0,0)

c.set_font_size(40)
c.move_to(40,40)
c.select_font_face("mikachan", 0,0)
str=Uconv.sjistou8("2013年 7〜12月カレンダー")
c.show_text(str)

c.move_to(22.5,55)
c.line_to(1485-22.5,55)
c.stroke
c.move_to(22.5,110)
c.line_to(1485-22.5,110)
c.stroke
c.move_to(22.5,1040)
c.line_to(1485-22.5,1040)


c.stroke

(0..6).to_a.each{|i|
c.move_to(22.5+240*i,55)
c.line_to(22.5+240*i,110+930)
c.stroke
}

(0..5).to_a.each{|i|
c.move_to(22.5+240*i+30,110)
c.line_to(22.5+240*i+30,110+930)
c.stroke
}

(0..5).to_a.each{|i|
c.move_to(22.5+240*i+60,110)
c.line_to(22.5+240*i+60,110+930)
c.stroke
}

(0..5).to_a.each{|i|
c.move_to(22.5+240*i+60,110)
c.line_to(22.5+240*i+60,110+930)
c.stroke
}

(1..31).to_a.each{|i|
c.move_to(22.5,110+i*30)
c.line_to(1485-22.5,110+i*30)
c.stroke
}
#January
count=0
%w(7月
8月
9月
10月
11月
12月).each{|tx|
c.set_font_size(40)
c.move_to(22.5+100+240*count,100)
c.select_font_face("mikachan", 0,0)
str=Uconv.sjistou8(tx)
c.show_text(str)
count+=1
}

#July
count=0
(1..31).to_a.each{|day|
c.set_font_size(20)
c.move_to(22.5+8,136+count*30)
c.select_font_face("mikachan", 0,0)
day_s=""
if day.to_s.length==1
day_s=" "+day.to_s
else
day_s=day.to_s
end
str=Uconv.sjistou8(day_s)
c.show_text(str)
count+=1
}
#August
count=0
(1..31).to_a.each{|day|
c.set_font_size(20)
c.move_to(22.5+240*1+8,136+count*30)
c.select_font_face("mikachan", 0,0)
day_s=""
if day.to_s.length==1
day_s=" "+day.to_s
else
day_s=day.to_s
end


str=Uconv.sjistou8(day_s)
c.show_text(str)
count+=1
}

#September
count=0
(1..30).to_a.each{|day|
c.set_font_size(20)
c.move_to(22.5+240*2+8,136+count*30)
c.select_font_face("mikachan", 0,0)
day_s=""
if day.to_s.length==1
day_s=" "+day.to_s
else
day_s=day.to_s
end
str=Uconv.sjistou8(day_s)
c.show_text(str)
count+=1
}

#October
count=0
(1..31).to_a.each{|day|
c.set_font_size(20)
c.move_to(22.5+240*3+8,136+count*30)
c.select_font_face("mikachan", 0,0)
day_s=""
if day.to_s.length==1
day_s=" "+day.to_s
else
day_s=day.to_s
end
str=Uconv.sjistou8(day_s)
c.show_text(str)
count+=1
}

#November
count=0
(1..30).to_a.each{|day|
c.set_font_size(20)
c.move_to(22.5+240*4+8,136+count*30)
c.select_font_face("mikachan", 0,0)
day_s=""
if day.to_s.length==1
day_s=" "+day.to_s
else
day_s=day.to_s
end
str=Uconv.sjistou8(day_s)
c.show_text(str)
count+=1
}
#December
count=0
(1..31).to_a.each{|day|
c.set_font_size(20)
c.move_to(22.5+240*5+8,136+count*30)
c.select_font_face("mikachan", 0,0)
day_s=""
if day.to_s.length==1
day_s=" "+day.to_s
else
day_s=day.to_s
end
str=Uconv.sjistou8(day_s)
c.show_text(str)
count+=1
}


#weekday
#July
defo= Time.local(2013,7,1).wday
count=0
(1..31).to_a.each{|day|
c.set_font_size(20)
c.select_font_face("mikachan", 0,0)
c.move_to(22.5+30+8,136+count*30)

case defo%7
when 1
str=Uconv.sjistou8("月")
c.show_text(str)
when 2
str=Uconv.sjistou8("火")
c.show_text(str)
when 3
str=Uconv.sjistou8("水")
c.show_text(str)
when 4
str=Uconv.sjistou8("木")
c.show_text(str)
when 5
str=Uconv.sjistou8("金")
c.show_text(str)
when 6
#c.set_source_rgb(0,0,1)
c.set_source_rgb(0,0,1)
str=Uconv.sjistou8("土")
c.show_text(str)
when 0
#c.set_source_color("red")
c.set_source_rgb(1,0,0)
str=Uconv.sjistou8("日")
c.show_text(str)
end

count+=1
defo+=1
c.set_source_rgb(0,0,0)

}


#weekday
#August
defo = Time.local(2013,8,1).wday
count=0
(1..31).to_a.each{|day|
c.set_font_size(20)
c.select_font_face("mikachan", 0,0)
c.move_to(22.5+240*1+30+8,136+count*30)

case defo%7
when 1
str=Uconv.sjistou8("月")
c.show_text(str)
when 2
str=Uconv.sjistou8("火")
c.show_text(str)
when 3
str=Uconv.sjistou8("水")
c.show_text(str)
when 4
str=Uconv.sjistou8("木")
c.show_text(str)
when 5
str=Uconv.sjistou8("金")
c.show_text(str)
when 6
c.set_source_rgb(0,0,1)
str=Uconv.sjistou8("土")
c.show_text(str)
when 0
c.set_source_rgb(1,0,0)
str=Uconv.sjistou8("日")
c.show_text(str)
end

count+=1
defo+=1
c.set_source_rgb(0,0,0)

}


#weekday
#September
defo = Time.local(2013,9,1).wday
count=0
(1..30).to_a.each{|day|
c.set_font_size(20)
c.select_font_face("mikachan", 0,0)
c.move_to(22.5+240*2+30+8,136+count*30)

case defo%7
when 1
str=Uconv.sjistou8("月")
c.show_text(str)
when 2
str=Uconv.sjistou8("火")
c.show_text(str)
when 3
str=Uconv.sjistou8("水")
c.show_text(str)
when 4
str=Uconv.sjistou8("木")
c.show_text(str)
when 5
str=Uconv.sjistou8("金")
c.show_text(str)
when 6
c.set_source_rgb(0,0,1)
str=Uconv.sjistou8("土")
c.show_text(str)
when 0
c.set_source_rgb(1,0,0)
str=Uconv.sjistou8("日")
c.show_text(str)
end

count+=1
defo+=1
c.set_source_rgb(0,0,0)

}


#weekday
#October
defo = Time.local(2013,10,1).wday

count=0
(1..31).to_a.each{|day|
c.set_font_size(20)
c.select_font_face("mikachan", 0,0)
c.move_to(22.5+240*3+30+8,136+count*30)

case defo%7
when 1
str=Uconv.sjistou8("月")
c.show_text(str)
when 2
str=Uconv.sjistou8("火")
c.show_text(str)
when 3
str=Uconv.sjistou8("水")
c.show_text(str)
when 4
str=Uconv.sjistou8("木")
c.show_text(str)
when 5
str=Uconv.sjistou8("金")
c.show_text(str)
when 6
c.set_source_rgb(0,0,1)
str=Uconv.sjistou8("土")
c.show_text(str)
when 0
c.set_source_rgb(1,0,0)
str=Uconv.sjistou8("日")
c.show_text(str)
end

count+=1
defo+=1
c.set_source_rgb(0,0,0)

}

#weekday
#November
defo = Time.local(2013,11,1).wday

count=0
(1..30).to_a.each{|day|
c.set_font_size(20)
c.select_font_face("mikachan", 0,0)
c.move_to(22.5+240*4+30+8,136+count*30)

case defo%7
when 1
str=Uconv.sjistou8("月")
c.show_text(str)
when 2
str=Uconv.sjistou8("火")
c.show_text(str)
when 3
str=Uconv.sjistou8("水")
c.show_text(str)
when 4
str=Uconv.sjistou8("木")
c.show_text(str)
when 5
str=Uconv.sjistou8("金")
c.show_text(str)
when 6
c.set_source_rgb(0,0,1)
str=Uconv.sjistou8("土")
c.show_text(str)
when 0
c.set_source_rgb(1,0,0)
str=Uconv.sjistou8("日")
c.show_text(str)
end

count+=1
defo+=1
c.set_source_rgb(0,0,0)

}
#weekday
#December
defo = Time.local(2013,12,1).wday
count=0
(1..31).to_a.each{|day|
c.set_font_size(20)
c.select_font_face("mikachan", 0,0)
c.move_to(22.5+240*5+30+8,136+count*30)

case defo%7
when 1
str=Uconv.sjistou8("月")
c.show_text(str)
when 2
str=Uconv.sjistou8("火")
c.show_text(str)
when 3
str=Uconv.sjistou8("水")
c.show_text(str)
when 4
str=Uconv.sjistou8("木")
c.show_text(str)
when 5
str=Uconv.sjistou8("金")
c.show_text(str)
when 6
c.set_source_rgb(0,0,1)
str=Uconv.sjistou8("土")
c.show_text(str)
when 0
c.set_source_rgb(1,0,0)
str=Uconv.sjistou8("日")
c.show_text(str)
end

count+=1
defo+=1
c.set_source_rgb(0,0,0)

}


surface.write_to_png("calendar2013_7to12.png")
inserted by FC2 system