예제 #1
0
파일: test_fract4d.py 프로젝트: asa-Q/HL
    def testFractWorker(self):
        xsize = 8
        ysize = 8
        im = image.T(xsize, ysize)

        cmap = fract4dc.cmap_create([(1.0, 255, 255, 255, 255)])

        fract4dc.cmap_set_solid(cmap, 0, 0, 0, 0, 255)
        fract4dc.cmap_set_solid(cmap, 1, 0, 0, 0, 255)

        (fw, ff, site, handle, pfunc) = self.makeWorkerAndFunc(im._img, cmap)

        im.clear()
        fate_buf = im.fate_buffer()
        buf = im.image_buffer()

        # draw 1 pixel, check it's set properly
        fract4dc.fw_pixel(fw, 0, 0, 1, 1)
        self.assertPixelIs(im, 0, 0, [im.OUT] + [im.UNKNOWN] * 3)

        fract4dc.fw_pixel(fw, 0, 4, 1, 1)
        self.assertPixelIs(im, 0, 4, [im.IN] + [im.UNKNOWN] * 3)

        # draw it again, check no change.
        fract4dc.fw_pixel(fw, 0, 0, 1, 1)
        self.assertPixelIs(im, 0, 0, [im.OUT] + [im.UNKNOWN] * 3)

        # draw & antialias another pixel
        fract4dc.fw_pixel(fw, 2, 2, 1, 1)
        fract4dc.fw_pixel_aa(fw, 2, 2)
        self.assertPixelIs(im, 2, 2, [im.OUT, im.OUT, im.IN, im.OUT])

        # change cmap, draw same pixel again, check color changes
        cmap = fract4dc.cmap_create(
            [(1.0, 79, 88, 41, 255)])
        fract4dc.cmap_set_solid(cmap, 1, 100, 101, 102, 255)

        (fw, ff, site, handle, pfunc) = self.makeWorkerAndFunc(im._img, cmap)

        fract4dc.fw_pixel(fw, 0, 0, 1, 1)
        self.assertPixelIs(im, 0, 0, [im.OUT] + [im.UNKNOWN] * 3, [79, 88, 41])

        # redraw antialiased pixel
        fract4dc.fw_pixel_aa(fw, 2, 2)
        self.assertPixelIs(
            im, 2, 2, [im.OUT, im.OUT, im.IN, im.OUT],
            [79, 88, 41], [100, 101, 102])

        # draw large block overlapping existing pixels
        fract4dc.fw_pixel(fw, 0, 0, 4, 4)
        self.assertPixelIs(
            im, 0, 0, [im.OUT, im.UNKNOWN, im.UNKNOWN, im.UNKNOWN],
            [79, 88, 41], [100, 101, 102])

        self.assertPixelIs(
            im, 3, 1, [im.UNKNOWN] * 4,
            [79, 88, 41], [100, 101, 102], im.OUT)
예제 #2
0
    def testFractWorker(self):
        xsize = 8
        ysize = 8
        im = image.T(xsize,ysize)
        
        cmap = fract4dc.cmap_create([(1.0, 255, 255, 255, 255)])

        fract4dc.cmap_set_solid(cmap,0,0,0,0,255)
        fract4dc.cmap_set_solid(cmap,1,0,0,0,255)
        
        (fw,ff,site,handle,pfunc) = self.makeWorkerAndFunc(im._img,cmap)

        im.clear()
        fate_buf = im.fate_buffer()
        buf = im.image_buffer() 
        
        # draw 1 pixel, check it's set properly
        fract4dc.fw_pixel(fw,0,0,1,1)
        self.assertPixelIs(im,0,0,[im.OUT]+[im.UNKNOWN]*3)

        fract4dc.fw_pixel(fw,0,4,1,1)
        self.assertPixelIs(im,0,4,[im.IN]+[im.UNKNOWN]*3)
        
        # draw it again, check no change.
        fract4dc.fw_pixel(fw,0,0,1,1)
        self.assertPixelIs(im,0,0,[im.OUT]+[im.UNKNOWN]*3)

        # draw & antialias another pixel
        fract4dc.fw_pixel(fw,2,2,1,1)
        fract4dc.fw_pixel_aa(fw,2,2)
        self.assertPixelIs(im,2,2,[im.OUT, im.OUT, im.IN, im.OUT])

        # change cmap, draw same pixel again, check color changes
        cmap = fract4dc.cmap_create(
            [(1.0, 79, 88, 41, 255)])
        fract4dc.cmap_set_solid(cmap,1,100,101,102,255)
        
        (fw,ff,site,handle,pfunc) = self.makeWorkerAndFunc(im._img,cmap)

        fract4dc.fw_pixel(fw,0,0,1,1)
        self.assertPixelIs(im,0,0,[im.OUT]+[im.UNKNOWN]*3, [79,88,41])

        # redraw antialiased pixel
        fract4dc.fw_pixel_aa(fw,2,2)
        self.assertPixelIs(
            im,2,2, [im.OUT, im.OUT, im.IN, im.OUT],
            [79,88,41], [100,101,102])

        # draw large block overlapping existing pixels
        fract4dc.fw_pixel(fw,0,0,4,4)
        self.assertPixelIs(
            im,0,0, [im.OUT, im.UNKNOWN, im.UNKNOWN, im.UNKNOWN],
            [79,88,41], [100,101,102])

        self.assertPixelIs(
            im,3,1, [im.UNKNOWN]*4,
            [79,88,41], [100,101,102], im.OUT)