예제 #1
0
    def draw(self, c, dpi):
        self.c = c
        self.dpi = dpi
        set_background_color(c, self.w, self.h)

        nw, nh = dimensions_mm(dpi, self.w, self.h)
        c.set_antialias(cairo.ANTIALIAS_GRAY)

        self.draw_ruler_pair(c, dpi, mm(dpi, 20))

        # Only calculate offsets if on an OLPC XO-1, 1.5, 1.75
        # Not applicable to XO 3.0
        if self.hw[0:2] == 'xo' and dpi in [200, 201]:
            self.offset_of_xo_side_from_screen = mm(dpi, -38.5)
            c.move_to(self.offset_of_xo_side_from_screen,  mm(dpi, 65))
            self.draw_cm_ruler(c, dpi, 180)
            
            c.save()
            c.move_to(mm(dpi, 20), mm(dpi, 75))
            write(c, _('Use this ruler from the outside edge of the computer.'),
                  self.font, mm(dpi, 4))
            c.restore()

            offset_of_molding_from_screen = mm(dpi, -0.4)
            c.move_to(offset_of_molding_from_screen,  mm(dpi, 95))
            self.draw_cm_ruler(c, dpi, 150)
            self.draw_custom_ruler(self.custom_unit_in_mm, int(nw / 10 * 10))

        else:
            self.offset_of_xo_side_from_screen = mm(dpi, int(nw / 20))
            c.move_to(self.offset_of_xo_side_from_screen,  mm(dpi, 65))
            self.draw_cm_ruler(c, dpi, int(nw / 11 * 10))
            self.draw_custom_ruler(self.custom_unit_in_mm, int(nw / 11 * 10))
예제 #2
0
    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()
예제 #3
0
 def draw(self, c, dpi):
     set_background_color(c, self.w, self.h)
     nw, nh = dimensions_mm(dpi, self.w, self.h)
     c.set_antialias(cairo.ANTIALIAS_GRAY)
     draw_numbers(self, c, dpi, nw, nh)
     draw_grid(c, dpi, 10, 2, nw, nh)
     draw_grid(c, dpi, 100, 3.5, nw, nh)
예제 #4
0
 def draw(self, c, dpi):
     set_background_color(c, self.w, self.h)
     nw, nh = dimensions_mm(dpi, self.w, self.h)
     draw_numbers(self, c, dpi, nw, nh, 10, "mm")
     draw_grid(c, dpi, 1, 1, nw, nh)
     draw_grid(c, dpi, 10, 2, nw, nh)
     draw_grid(c, dpi, 100, 3.5, nw, nh)
예제 #5
0
    def draw(self, c, dpi):
        self.c = c
        self.dpi = dpi
        set_background_color(c, self.w, self.h)

        nw, nh = dimensions_mm(dpi, self.w, self.h)
        c.set_antialias(cairo.ANTIALIAS_GRAY)

        self.draw_ruler_pair(c, dpi, mm(dpi, 20))

        # Only calculate offsets if on an OLPC XO-1, 1.5, 1.75
        # Not applicable to XO 3.0
        if self.hw[0:2] == 'xo' and dpi in [200, 201]:
            self.offset_of_xo_side_from_screen = mm(dpi, -38.5)
            c.move_to(self.offset_of_xo_side_from_screen,  mm(dpi, 65))
            self.draw_cm_ruler(c, dpi, 180)
            
            c.save()
            c.move_to(mm(dpi, 20), mm(dpi, 75))
            write(c, _('Use this ruler from the outside edge of the computer.'),
                  self.font, mm(dpi, 4))
            c.restore()

            offset_of_molding_from_screen = mm(dpi, -0.4)
            c.move_to(offset_of_molding_from_screen,  mm(dpi, 95))
            self.draw_cm_ruler(c, dpi, 150)
            self.draw_custom_ruler(self.custom_unit_in_mm, int(nw / 10 * 10))

        else:
            self.offset_of_xo_side_from_screen = mm(dpi, 0)
            c.move_to(self.offset_of_xo_side_from_screen,  mm(dpi, 65))
            self.draw_cm_ruler(c, dpi, int(nw / 10 * 10))
            self.draw_custom_ruler(self.custom_unit_in_mm, int(nw / 10 * 10))
예제 #6
0
    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()
예제 #7
0
    def draw(self, c, dpi):
        set_background_color(c, self.w, self.h)

        nw, nh = dimensions_mm(dpi, self.w, self.h)
        c.set_antialias(cairo.ANTIALIAS_GRAY)

        self.draw_ruler_pair(c, dpi, mm(dpi, 20))

        # only calculate offsets if on an OLPC XO-1
        if self.hw[0:2] == 'XO':
            offset_of_xo_side_from_screen = mm(dpi, -38.5) #XXX needs checking
            c.move_to(offset_of_xo_side_from_screen,  mm(dpi, 65))
            self.draw_cm_ruler(c, dpi, 180)
            
            c.save()
            c.move_to(mm(dpi, 20), mm(dpi, 75))
            write(c, _('Use this ruler from the outside edge of the computer.'),
                  self.font, mm(dpi, 4))
            c.restore()

            offset_of_molding_from_screen = mm(dpi, -0.4) #XXX +- 0.2 ??
            c.move_to(offset_of_molding_from_screen,  mm(dpi, 95))
            self.draw_cm_ruler(c, dpi, 150)

        else:
            offset_of_xo_side_from_screen = mm(dpi, 0)
            c.move_to(offset_of_xo_side_from_screen,  mm(dpi, 65))
            self.draw_cm_ruler(c, dpi, int(nw / 10 * 10))
예제 #8
0
    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)
        if self.hw[0:2] == 'xo':
            scale = 1.
        else:
            scale = 200./nh

        ox = mm(dpi, 0)
        oy = mm(dpi, 99 * scale)
        d = mm(dpi, 90 * scale)

        def xy(angle, m=d):
            return cos(-angle) * m + ox, sin(-angle) * m + oy

        def ray(angle, r0=0, r1=d):
            c.move_to(*xy(angle, r0))
            c.line_to(*xy(angle, r1))

        lw = 6
        c.set_line_width(lw)
        c.move_to(ox, oy + lw / 2)
        c.line_to(*xy(pi / 2))
        ray(0)
        c.stroke()

        c.save()
        c.set_line_width(3)
        c.set_dash([mm(dpi, 5)])
        ray(pi / 4)
        c.stroke()
        c.restore()

        c.set_line_width(4)
        for a in range(10, 81, 10):
            ray(d2r(a), mm(dpi, 10 * scale), mm(dpi, 85 * scale))
        c.stroke()
        c.set_line_width(2)
        for a in range(10, 81, 10):
            ray(d2r(a), mm(dpi, 3 * scale), mm(dpi, 20 * scale))
        c.stroke()

        c.set_line_width(2)
        for a in range(1, 90, 1):
            ray(d2r(a), mm(dpi, 70 * scale), mm(dpi, 80 * scale))
        c.stroke()
        c.set_line_width(2)
        for a in range(0, 90, 5):
            ray(d2r(a), mm(dpi, 20 * scale), mm(dpi, 81 * scale))
        c.stroke()
예제 #9
0
    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)
        if self.hw[0:2] == 'xo':
            scale = 1.
        else:
            scale = 200. / nh

        ox = mm(dpi, 0)
        oy = mm(dpi, 99 * scale)
        d = mm(dpi, 90 * scale)

        def xy(angle, m=d):
            return cos(-angle) * m + ox, sin(-angle) * m + oy

        def ray(angle, r0=0, r1=d):
            c.move_to(*xy(angle, r0))
            c.line_to(*xy(angle, r1))

        lw = 6
        c.set_line_width(lw)
        c.move_to(ox, oy + lw / 2)
        c.line_to(*xy(pi / 2))
        ray(0)
        c.stroke()

        c.save()
        c.set_line_width(3)
        c.set_dash([mm(dpi, 5)])
        ray(pi / 4)
        c.stroke()
        c.restore()

        c.set_line_width(4)
        for a in range(10, 81, 10):
            ray(d2r(a), mm(dpi, 10 * scale), mm(dpi, 85 * scale))
        c.stroke()
        c.set_line_width(2)
        for a in range(10, 81, 10):
            ray(d2r(a), mm(dpi, 3 * scale), mm(dpi, 20 * scale))
        c.stroke()

        c.set_line_width(2)
        for a in range(1, 90, 1):
            ray(d2r(a), mm(dpi, 70 * scale), mm(dpi, 80 * scale))
        c.stroke()
        c.set_line_width(2)
        for a in range(0, 90, 5):
            ray(d2r(a), mm(dpi, 20 * scale), mm(dpi, 81 * scale))
        c.stroke()
예제 #10
0
    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)
        if self.hw[0:2] == 'xo':
            scale = 1.
        else:
            scale = 200./nh

        ox = mm(dpi, nw / 2)
        oy = mm(dpi, nh / 2)
        d = mm(dpi, 44 * scale)

        def xy(angle, m=d):
            return cos(-angle) * m + ox, sin(-angle) * m + oy

        def ray(angle, r0=0, r1=d):
            c.move_to(*xy(angle, r0))
            c.line_to(*xy(angle, r1))

        def annulus(a0, a1, r0, r1):
            c.move_to(*xy(a0, r0))
            c.arc_to(ox, oy, r0, a0, a1)
            c.rel_line_to(*xy(a1, r1))
            c.arc_to(ox, oy, r1, a1, a0)
            c.close_path()

        def rays(step, r0=0, r1=d, w=1):
            c.save()
            c.set_line_width(w)
            for a in range(0, 360, step):
                ray(d2r(a), r0, r1)
            c.stroke()
            c.restore()

        rays(1, mm(dpi, 35 * scale), w=2, r1=mm(dpi, 43 * scale))
        rays(5, mm(dpi, 10 * scale), w=2)
        rays(10, mm(dpi, 10 * scale), w=4)
#        rays(10, mm(dpi, 3), mm(dpi, 20), w=2)
        c.save()
        #c.set_dash([mm(dpi, 5)])
        set_color(c, 'dark gray')
        rays(45, 0, mm(dpi, 45 * scale), w=6)
        c.restore()
        rays(90, 0, mm(dpi, 45 * scale), w=6)
예제 #11
0
    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)
        if self.hw[0:2] == 'xo':
            scale = 1.
        else:
            scale = 200. / nh

        ox = mm(dpi, nw / 2)
        oy = mm(dpi, nh / 2)
        d = mm(dpi, 44 * scale)

        def xy(angle, m=d):
            return cos(-angle) * m + ox, sin(-angle) * m + oy

        def ray(angle, r0=0, r1=d):
            c.move_to(*xy(angle, r0))
            c.line_to(*xy(angle, r1))

        def annulus(a0, a1, r0, r1):
            c.move_to(*xy(a0, r0))
            c.arc_to(ox, oy, r0, a0, a1)
            c.rel_line_to(*xy(a1, r1))
            c.arc_to(ox, oy, r1, a1, a0)
            c.close_path()

        def rays(step, r0=0, r1=d, w=1):
            c.save()
            c.set_line_width(w)
            for a in range(0, 360, step):
                ray(d2r(a), r0, r1)
            c.stroke()
            c.restore()

        rays(1, mm(dpi, 35 * scale), w=2, r1=mm(dpi, 43 * scale))
        rays(5, mm(dpi, 10 * scale), w=2)
        rays(10, mm(dpi, 10 * scale), w=4)
        #        rays(10, mm(dpi, 3), mm(dpi, 20), w=2)
        c.save()
        #c.set_dash([mm(dpi, 5)])
        set_color(c, 'dark gray')
        rays(45, 0, mm(dpi, 45 * scale), w=6)
        c.restore()
        rays(90, 0, mm(dpi, 45 * scale), w=6)