コード例 #1
0
 def test_colorlist(self):
     """ Get set of eight colours, no jitter, using ColorSpiral."""
     cs = ColorSpiral(a=4, b=0.33, jitter=0)
     colours = list(cs.get_colors(8))
     cstr = ["(%.2f, %.2f, %.2f)" % (r, g, b) for r, g, b in colours]
     expected = \
         ['(0.64, 0.74, 0.81)', '(0.68, 0.52, 0.76)', '(0.72, 0.41, 0.55)',
          '(0.68, 0.39, 0.31)', '(0.63, 0.54, 0.22)', '(0.48, 0.59, 0.13)',
          '(0.24, 0.54, 0.06)', '(0.01, 0.50, -0.00)']
     self.assertEqual(cstr, expected)
コード例 #2
0
 def test_colorlist(self):
     """ Get set of eight colours, no jitter, using ColorSpiral."""
     cs = ColorSpiral(a=4, b=0.33, jitter=0)
     colours = list(cs.get_colors(8))
     cstr = ["(%.2f, %.2f, %.2f)" % (r, g, b)
             for r, g, b in colours]
     expected = \
         ['(0.64, 0.74, 0.81)', '(0.68, 0.52, 0.76)', '(0.72, 0.41, 0.55)',
          '(0.68, 0.39, 0.31)', '(0.63, 0.54, 0.22)', '(0.48, 0.59, 0.13)',
          '(0.24, 0.54, 0.06)', '(0.01, 0.50, -0.00)']
     self.assertEqual(cstr, expected)
コード例 #3
0
 def test_colorspiral(self):
     """ Get set of 16 colours, no jitter, using ColorSpiral."""
     cs = ColorSpiral(a=4, b=0.33, jitter=0)
     radius = A4[0] * 0.025
     for r, g, b in cs.get_colors(16):
         self.c.setFillColor((r, g, b))
         # Convert HSV colour to rectangular coordinates on HSV disc
         h, s, v = colorsys.rgb_to_hsv(r, g, b)
         coords = cmath.rect(s * A4[0] * 0.45, h * 2 * pi)
         x, y = self.x_0 + coords.real, self.y_0 + coords.imag
         self.c.ellipse(x - radius, y - radius, x + radius, y + radius,
                        stroke=0, fill=1)
     self.finish()
コード例 #4
0
 def test_colorspiral(self):
     """ Get set of 16 colours, no jitter, using ColorSpiral."""
     cs = ColorSpiral(a=4, b=0.33, jitter=0)
     radius = A4[0] * 0.025
     for r, g, b in cs.get_colors(16):
         self.c.setFillColor((r, g, b))
         # Convert HSV colour to rectangular coordinates on HSV disc
         h, s, v = colorsys.rgb_to_hsv(r, g, b)
         coords = cmath.rect(s * A4[0] * 0.45, h * 2 * pi)
         x, y = self.x_0 + coords.real, self.y_0 + coords.imag
         self.c.ellipse(x - radius,
                        y - radius,
                        x + radius,
                        y + radius,
                        stroke=0,
                        fill=1)
     self.finish()