To check that new blending mode code does not change existing brushes.
def is_empty(self):
return not self.tiledict
def is_empty(self):
return not self.tiledict
+ def remove_empty_tiles(self):
+ for pos, data in self.tiledict.items():
+ if not data.rgba.any():
+ self.tiledict.pop(pos)
b2 = brush.Brush()
b2.load_from_string(open('brushes/redbrush.myb').read())
b2.set_color_hsv((0.3, 0.4, 0.35))
b2 = brush.Brush()
b2.load_from_string(open('brushes/redbrush.myb').read())
b2.set_color_hsv((0.3, 0.4, 0.35))
+ b3 = brush.Brush()
+ b3.load_from_string(open('brushes/watercolor.myb').read())
+ b3.set_color_hsv((0.9, 0.2, 0.2))
# test some actions
doc = document.Document()
# test some actions
doc = document.Document()
assert doc.get_bbox().empty()
if i == n*3/8:
doc.undo()
assert doc.get_bbox().empty()
if i == n*3/8:
doc.undo()
if i == n*4/8:
doc.set_brush(b2)
if i == n*5/8:
if i == n*4/8:
doc.set_brush(b2)
if i == n*5/8:
if i == n*7/8:
doc.add_layer(1)
if i == n*7/8:
doc.add_layer(1)
+ # If there is an eraser (or smudging) at work, we might be erasing
+ # tiles that are empty. Those tile get memory allocated and affect
+ # the bouting box of the layer. This shouldn't be a big issue, but
+ # they get dropped when loading a document, which makes a
+ # comparision of the PNG files fail. The hack below is to avoid that.
+ for l in doc.layers:
+ l.surface.remove_empty_tiles()
+
doc.layers[0].surface.save('test_docPaint_a.png')
doc.layers[0].surface.save('test_docPaint_a1.png')
# the resulting images will look slightly different because of dithering
doc.layers[0].surface.save('test_docPaint_a.png')
doc.layers[0].surface.save('test_docPaint_a1.png')
# the resulting images will look slightly different because of dithering
doc.save('test_f1.ora')
doc2 = document.Document()
doc2.load('test_f1.ora')
doc.save('test_f1.ora')
doc2 = document.Document()
doc2.load('test_f1.ora')
- print doc.get_bbox(), doc2.get_bbox()
- # TODO: fix this one?!
+
+ # (We don't preserve the absolute position of the image, only the size.)
#assert doc.get_bbox() == doc2.get_bbox()
#assert doc.get_bbox() == doc2.get_bbox()
+ print 'doc / doc2 bbox:', doc.get_bbox(), doc2.get_bbox()
+
doc2.layers[0].surface.save('test_docPaint_b.png')
assert pngs_equal('test_docPaint_a.png', 'test_docPaint_b.png')
doc2.save('test_f2.ora')
doc2.layers[0].surface.save('test_docPaint_b.png')
assert pngs_equal('test_docPaint_a.png', 'test_docPaint_b.png')
doc2.save('test_f2.ora')