waves.py 812 B

1234567891011121314151617181920212223242526
  1. #!/usr/bin/python3
  2. from math import sin
  3. from random import randint
  4. boundX = 800
  5. boundY = 1000
  6. def drawPoint(x, y, colorR, colorG, colorB):
  7. hexR = hex(colorR)[2:4] if len(hex(colorR)) > 3 else hex(colorR)[2:3] + "0"
  8. hexG = hex(colorG)[2:4] if len(hex(colorG)) > 3 else hex(colorG)[2:3] + "0"
  9. hexB = hex(colorB)[2:4] if len(hex(colorB)) > 3 else hex(colorB)[2:3] + "0"
  10. print("px "+str(x)+" "+str(y)+" "+hexR+hexG+hexB)
  11. while True:
  12. randShiftYFactor = randint(100, boundY)
  13. shiftY = boundY - randShiftYFactor
  14. colorR = randint(0, 255)
  15. colorG = randint(0, 255)
  16. colorB = randint(0, 255)
  17. shift = randint(0, 5)
  18. for x in range(0, boundX):
  19. for scale in range(0, randint(0, 50)):
  20. drawPoint(x , int(sin(x+shift)*scale)+shiftY, colorR, colorG, colorB)