Esempio n. 1
0
    def clip_to_rect_helper(self, desired, scale, clip_rects):
        """ desired -- 2D array with a single channels expected byte pattern.
            scale -- used in scale_ctm() to change the ctm.
            clip_args -- passed in as *clip_args to clip_to_rect.
        """
        shp = tuple(transpose(desired.shape))
        gc = GraphicsContextArray(shp, pix_format="rgb24")
        gc.scale_ctm(scale, scale)

        # clear background to white values (255, 255, 255)
        gc.clear((1.0, 1.0, 1.0))

        if isinstance(clip_rects, tuple):
            gc.clip_to_rect(*clip_rects)
        else:
            for rect in clip_rects:
                gc.clip_to_rect(*rect)

        gc.rect(0, 0, 4, 4)

        # These settings allow the fastest path.
        gc.set_fill_color((0.0, 0.0, 0.0))  # black
        gc.fill_path()

        # test a single color channel
        actual = gc.bmp_array[:, :, 0]
        self.assertRavelEqual(desired, actual)
Esempio n. 2
0
    def clip_to_rect_helper(self, desired, scale, clip_rects):
        """ desired -- 2D array with a single channels expected byte pattern.
            scale -- used in scale_ctm() to change the ctm.
            clip_args -- passed in as *clip_args to clip_to_rect.
        """
        shp = tuple(transpose(desired.shape))
        gc = GraphicsContextArray(shp, pix_format="rgb24")
        gc.scale_ctm(scale, scale)

        # clear background to white values (255, 255, 255)
        gc.clear((1.0, 1.0, 1.0))

        if isinstance(clip_rects, tuple):
            gc.clip_to_rect(*clip_rects)
        else:
            for rect in clip_rects:
                gc.clip_to_rect(*rect)

        gc.rect(0, 0, 4, 4)

        # These settings allow the fastest path.
        gc.set_fill_color((0.0, 0.0, 0.0)) # black
        gc.fill_path()

        # test a single color channel
        actual = gc.bmp_array[:,:,0]
        self.assertRavelEqual(desired, actual)
Esempio n. 3
0
    def successive_clip_helper(self, desired, scale, clip_rect1, clip_rect2):
        """ desired -- 2D array with a single channels expected byte pattern.
            scale -- used in scale_ctm() to change the ctm.
            clip_rect1 -- 1st clipping path.
            clip_rect2 -- 2nd clipping path.
        """
        shp = tuple(transpose(desired.shape))
        gc = GraphicsContextArray(shp, pix_format="rgb24")
        gc.scale_ctm(scale, scale)

        # clear background to white values (255, 255, 255)
        gc.clear((1.0, 1.0, 1.0))

        gc.clip_to_rect(*clip_rect1)
        gc.clip_to_rect(*clip_rect2)

        gc.rect(0, 0, 4, 4)

        # These settings allow the fastest path.
        gc.set_fill_color((0.0, 0.0, 0.0))  # black
        gc.fill_path()

        # test a single color channel
        actual = gc.bmp_array[:, :, 0]
        self.assertRavelEqual(desired, actual)
Esempio n. 4
0
    def successive_clip_helper(self, desired, scale,
                               clip_rect1, clip_rect2):
        """ desired -- 2D array with a single channels expected byte pattern.
            scale -- used in scale_ctm() to change the ctm.
            clip_rect1 -- 1st clipping path.
            clip_rect2 -- 2nd clipping path.
        """
        shp = tuple(transpose(desired.shape))
        gc = GraphicsContextArray(shp, pix_format="rgb24")
        gc.scale_ctm(scale, scale)

        # clear background to white values (255, 255, 255)
        gc.clear((1.0, 1.0, 1.0))

        gc.clip_to_rect(*clip_rect1)
        gc.clip_to_rect(*clip_rect2)

        gc.rect(0, 0, 4, 4)

        # These settings allow the fastest path.
        gc. set_fill_color((0.0, 0.0, 0.0)) # black
        gc.fill_path()

        # test a single color channel
        actual = gc.bmp_array[:,:,0]
        self.assertRavelEqual(desired, actual)