Beispiel #1
0
 def _init_alpha_checks(self):
     """Initialize the alpha check backgrounds"""
     # Real: checkerboard pattern, rendered via Cairo
     assert tiledsurface.N % gui.style.ALPHA_CHECK_SIZE == 0
     N = tiledsurface.N
     size = gui.style.ALPHA_CHECK_SIZE
     nchecks = int(N / size)
     cairo_surf = cairo.ImageSurface(cairo.FORMAT_ARGB32, N, N)
     cr = cairo.Context(cairo_surf)
     render_checks(cr, size, nchecks)
     cairo_surf.flush()
     # Real: MyPaint background surface for layers-but-no-bg rendering
     pattern = cairo.SurfacePattern(cairo_surf)
     pattern.set_extend(cairo.EXTEND_REPEAT)
     self._real_alpha_check_pattern = pattern
     # Fake: faster rendering, but ugly
     tile = empty((N, N, 4), dtype='uint16')
     f = 1 << 15
     col1 = [int(f * c) for c in gui.style.ALPHA_CHECK_COLOR_1] + [f]
     col2 = [int(f * c) for c in gui.style.ALPHA_CHECK_COLOR_2] + [f]
     tile[:] = col1
     for i in xrange(nchecks):
         for j in xrange(nchecks):
             if (i+j) % 2 == 0:
                 continue
             tile[i*size:(i+1)*size, j*size:(j+1)*size] = col2
     self._fake_alpha_check_tile = tile
Beispiel #2
0
 def _init_alpha_check_bg(self):
     """Initialize the alpha check surface used for no-bg renderings"""
     # Checkerboard pattern, rendered via Cairo
     assert tiledsurface.N % _ALPHA_CHECK_SIZE == 0
     N = tiledsurface.N
     size = _ALPHA_CHECK_SIZE
     nchecks = int(N / size)
     cairo_surf = cairo.ImageSurface(cairo.FORMAT_ARGB32, N, N)
     cr = cairo.Context(cairo_surf)
     render_checks(cr, size, nchecks)
     cairo_surf.flush()
     # MyPaint background surface for layers-but-no-bg rendering
     pattern = cairo.SurfacePattern(cairo_surf)
     pattern.set_extend(cairo.EXTEND_REPEAT)
     self._alpha_check_bg = pattern
Beispiel #3
0
 def _init_alpha_check_bg(self):
     """Initialize the alpha check surface used for no-bg renderings"""
     # Checkerboard pattern, rendered via Cairo
     assert tiledsurface.N % _ALPHA_CHECK_SIZE == 0
     N = tiledsurface.N
     size = _ALPHA_CHECK_SIZE
     nchecks = int(N / size)
     cairo_surf = cairo.ImageSurface(cairo.FORMAT_ARGB32, N, N)
     cr = cairo.Context(cairo_surf)
     render_checks(cr, size, nchecks)
     cairo_surf.flush()
     # MyPaint background surface for layers-but-no-bg rendering
     pattern = cairo.SurfacePattern(cairo_surf)
     pattern.set_extend(cairo.EXTEND_REPEAT)
     self._alpha_check_bg = pattern