Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/show_checkers.py
blob: 06ba6519a8d605b59701c462be3d703b55b14a3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# Copyright 2007 Mitchell N. Charity
# Copyright 2009 Walter Bender
#
# This file is part of Ruler.
#
# Ruler is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ruler is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ruler.  If not, see <http://www.gnu.org/licenses/>

import cairo

from math import pi

from util import mm, dimensions_mm, set_background_color


class ScreenOfCircles():

    def __init__(self, font, font_bold, w, h):
        self.font = font
        self.font_bold = font_bold
        self.w = w
        self.h = h

    def draw(self, c, dpi):

        set_background_color(c, self.w, self.h)
        c.set_antialias(cairo.ANTIALIAS_GRAY)

        nw, nh = dimensions_mm(dpi, self.w, self.h)

        def sq(x, y):
            c.rectangle(x, y, mm(dpi, 10), mm(dpi, 10))
            c.fill()
        
        w=nw
        h=nh
        for xm in range(0, w, 20):
            for ym in range(0, h, 20):
                sq(mm(dpi, xm), mm(dpi, ym))
        for xm in range(10, w, 20):
            for ym in range(10, h, 20):
                sq(mm(dpi, xm), mm(dpi, ym))

        c.set_line_width(1)
        c.move_to(mm(dpi, 100), 0)
        c.rel_line_to(0, mm(dpi, 100))
        c.rel_line_to(mm(dpi, -100), 0)
        c.stroke()

        c.set_line_width(3)
        v = 0.5
        c.set_source_rgb(v, v, v)
        c.move_to(mm(dpi, 50), 0)
        c.rel_line_to(0, mm(dpi, 100))
        c.move_to(0, mm(dpi, 50))
        c.rel_line_to(mm(dpi, 100), 0)
        c.stroke()