Advertisement
tinyevil

Untitled

Nov 13th, 2018
388
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.87 KB | None | 0 0
  1. import terminal
  2.  
  3. terminal.init()
  4.  
  5.  
  6. def draw_line(r, g, b):
  7.     terminal.set_background(r, g, b)
  8.     for _ in range(80):
  9.         terminal.print(" ")
  10.  
  11.  
  12. def canvas(lines):
  13.     is_red = True
  14.     for _ in range(lines):
  15.         if is_red:
  16.             draw_line(220, 20, 60)
  17.         else:
  18.             draw_line(255, 255, 240)
  19.         is_red = not is_red
  20.  
  21.  
  22. def draw_star_line(len, starts_with_star):
  23.     terminal.set_background(25, 25, 112)
  24.     terminal.print(" ")
  25.     is_star = starts_with_star
  26.     # -2 for two spaces on the border
  27.     for _ in range(len - 2):
  28.         if is_star:
  29.             terminal.print("╬")
  30.         else:
  31.             terminal.print(" ")
  32.         is_star = not is_star
  33.     terminal.print(" ")
  34.  
  35.  
  36. def canvas_of_stars(lines, len):
  37.     starts_with_star = True
  38.     for y in range(lines):
  39.         terminal.set_xy(0, y)
  40.         draw_star_line(len, starts_with_star)
  41.         starts_with_star = not starts_with_star
  42.  
  43.  
  44. canvas(25)
  45. canvas_of_stars(12, 35)
  46.  
  47. terminal.waitkey()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement