Vasarely-style Codesters Art!

# import the math library module import math import random radius = random.randint(5, 25) * 10 scale = random.randint(1, 5) * 10 curve = random.randint(1, 5) * 10 fraction = random.randint(2, 8) coords = range(int(-scale/2), -radius, -scale) def draw_lines(x, y1, y2, c): sprite = codesters.Line(x, y1, x, y2, c) sprite = codesters.Line(-x, y1, -x, y2, c) sprite = codesters.Line(y1, x, y2, x, c) sprite = codesters.Line(y1, -x, y2, -x, c) for coord in coords: coord2 = math.sqrt(radius*radius - coord*coord) height = -radius+((radius+coord)/fraction) sprite = codesters.Curve(coord, coord2, height, curve, height, -curve, coord, -coord2, None, "red") sprite = codesters.Curve(-coord, coord2, -height, curve, -height, -curve, -coord, -coord2, None, "red") sprite = codesters.Curve(coord2, coord, curve, height, -curve, height, -coord2, coord, None, "red") sprite = codesters.Curve(coord2, -coord, curve, -height, -curve, -height, -coord2, -coord, None, "red") draw_lines(coord, -coord2, -250, "green") draw_lines(coord, coord2, 250, "green") for x in range(coords[-1]-scale, -250, -scale): draw_lines(x, -250, 250, "blue")
  • Run Code
  • Show Console
  • Codesters How To (opens in a new tab)