def test_inherit_from_pattern(self): parent = Pattern(id='test') pattern = Pattern(insert=(10, 20), size=(30, 40), inherit=parent, debug=True, profile='full') self.assertEqual( pattern.tostring(), '<pattern height="40" width="30" x="10" xlink:href="#test" y="20" />')
def prepare_character_images(drawing): # Load images base64 encoded to embed into svg file character_images = dict() for index in range(0, 84): p = Pattern(x=0, y=0, width="100%", height="100%", viewBox="0 0 512 512") image_path = ROOT_PATH_IMAGES + str(index) + ".jpeg" # Loading the image an convert it to base64 to integrate it directly # into the graphic. base64_prefix_href = "data:image/jpeg;base64," with open(image_path, 'rb') as image: base64_encoded_string = base64.standard_b64encode(image.read()) href_base64_img = base64_prefix_href + base64_encoded_string.decode( 'utf-8') i = Image(href=href_base64_img, x="0%", y="0%", width=512, height=512) p.add(i) drawing.defs.add(p) character_images[index] = p return character_images
def test_constructor(self): pattern = Pattern(insert=(10, 20), size=(30, 40), inherit='#test', debug=True, profile='full') self.assertEqual( pattern.tostring(), '<pattern height="40" width="30" x="10" xlink:href="#test" y="20" />' )
def __init__(self): super().__init__() rect = Rect(insert=(0, 0), size=(5, 5), fill='#9e9e9e') path = Path('M 0 5 L 5 0 Z M 6 4 L 4 6 Z M -1 1 L 1 -1 Z', stroke='#888', stroke_width=1) pattern = Pattern(id=self.__class__.__name__.lower(), patternUnits='userSpaceOnUse', size=(5, 5), stroke='none') pattern.add(rect) pattern.add(path) self.add(pattern)
def test_get_paint_server(self): pattern = Pattern(id="testpattern", debug=True, profile='full') self.assertEqual(pattern.get_paint_server(), "url(#testpattern) none")
def test_constructor(self): pattern = Pattern(insert=(10, 20), size=(30, 40), inherit='#test', debug=True, profile='full') self.assertEqual( pattern.tostring(), '<pattern height="40" width="30" x="10" xlink:href="#test" y="20" />')