Exemple #1
0
 def grid(self, xrows, yrows, width, height) -> plist:
     points = plist([], self.seed)
     xspan = width / xrows
     yspan = height / yrows
     for ypoints in range(1, yrows):
         for xpoints in range(1, xrows):
             points.append(Point(xpoints * xspan, ypoints * yspan))
     return points
Exemple #2
0
def palette(pid=None):
    cl = clapi.ColourLovers()
    if pid:
        pl = cl.search_palette(id=pid, format='json')
    else:
        pl = cl.search_palettes(request='random', format='json')
    print(">> random palette: {}".format(pl[0].id))
    return plist(map(lambda x: '#' + x, pl[0].colors))
Exemple #3
0
 def thirds(start, width, height) -> plist:
     rulePoints = plist()
     thirdWidth = width / 3
     thirdHeight = height / 3
     x, y = start
     rulePoints.append(thirdWidth + x, thirdHeight + y)
     rulePoints.append(thirdWidth * 2 + x, thirdHeight + y)
     rulePoints.append(thirdWidth * 2 + x, thirdHeight * 2 + y)
     rulePoints.append(thirdWidth + x, thirdHeight * 2 + y)
     return rulePoints
Exemple #4
0
 def butterfly(self, origin, scale, loops, lamb) -> plist:
     points = plist([], self.seed)
     stepSize = 0.025
     upperLimit = loops * math.pi
     t = 0.0
     while t <= upperLimit:
         e = (math.exp(math.cos(t)) - 2 * math.cos(lamb * t) -
              math.pow(math.sin(t / 12), 5))
         x = math.sin(t) * e
         y = math.cos(t) * e
         t += stepSize
         points.append((x * scale + origin[0], y * scale + origin[1]))
     return points
Exemple #5
0
def spline(pts: list, numpoints: float = 100) -> plist:
    ps = Spline.bspline(pts.as_tuples(), numpoints, 4)
    return plist([Point(p[0], p[1]) for p in ps])
Exemple #6
0
 def rows(origin, interRow, height) -> plist:
     points = plist()
     for i in range(origin[1], height, interRow):
         points.append((origin[0], i))
     return points
Exemple #7
0
 def cols(origin, interCol, width) -> plist:
     points = plist()
     for i in range(origin[0], width, interCol):
         points.append((i, origin[1]))
     return points
Exemple #8
0
 def pick(self, arr):
     return plist(arr).rit()
Exemple #9
0
 def rectangles_brush(self, h) -> list[Shape]:
     shapes = []
     pairs = plist(self.center).pairs()
     for pair in pairs:
         shapes.append(Shapes.rect(pair[0], pair[1], h))
     return shapes
Exemple #10
0
 def test_interpolate(self):
     mylist = plist([Point(0, 0), Point(20, 30)])
     points = mylist.interpolate()
     self.assertEqual(3, len(points))
     self.assertEqual(Point(10, 15), points[1])