Example #1
0
 def test_add_stop_color(self):
     rg = RadialGradient()
     rg.add_stop_color(offset=0.5, color='red', opacity=1.0)
     self.assertEqual(
         rg.tostring(),
         '<radialGradient><stop offset="0.5" stop-color="red" stop-opacity="1.0" /></radialGradient>'
     )
Example #2
0
 def test_get_paint_server(self):
     rg = RadialGradient()
     self.assertTrue(re.match("^url\(#id\d+\) none$",
                              rg.get_paint_server()))
     self.assertTrue(
         re.match("^url\(#id\d+\) red$",
                  rg.get_paint_server(default='red')))
Example #3
0
 def test_constructor(self):
     rg = RadialGradient(center=(10, 20),
                         r=10,
                         focal=(15, 25),
                         inherit='#test',
                         debug=True,
                         profile='full')
     self.assertEqual(
         rg.tostring(),
         '<radialGradient cx="10" cy="20" fx="15" fy="25" r="10" xlink:href="#test" />'
     )
Example #4
0
def draw_background(drawing):

    rad = RadialGradient(center=("50%", "50%"), r="50%", focal=("50%", "50%"))
    rad.add_stop_color(offset="0%", color="rgb(170,170,170)", opacity="1")
    rad.add_stop_color(offset="90%", color="rgb(0,0,0)", opacity="1")
    drawing.defs.add(rad)

    size = max(WIDTH, HEIGHT) / 1.25

    c = Circle(center=(WIDTH / 2, HEIGHT / 2),
               r=size,
               fill=rad.get_paint_server())

    drawing.add(c)
Example #5
0
 def test_add_stop_color(self):
     rg = RadialGradient()
     rg.add_stop_color(offset=0.5, color='red', opacity=1.0)
     self.assertEqual(rg.tostring(), '<radialGradient><stop offset="0.5" stop-color="red" stop-opacity="1.0" /></radialGradient>')
Example #6
0
 def test_get_paint_server(self):
     rg = RadialGradient()
     self.assertTrue(re.match("^url\(#id\d+\) none$", rg.get_paint_server()))
     self.assertTrue(re.match("^url\(#id\d+\) red$", rg.get_paint_server(default='red')))
Example #7
0
 def test_constructor(self):
     rg = RadialGradient(center=(10, 20), r=10, focal=(15, 25), inherit='#test', debug=True, profile='full')
     self.assertEqual(rg.tostring(),
         '<radialGradient cx="10" cy="20" fx="15" fy="25" r="10" xlink:href="#test" />')