Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import display
- import random
- import utime
- def draw(c, i):
- global tmpx, tmpy, incx, incy, x1, y1, x2, y2, bc
- tft.line(x1[i], y1[i], x2[i], y2[i], 0)
- tmpx += incx
- if (tmpx < 0 or tmpx > xmax):
- incx = -incx
- tmpx += incx
- tmpy += incy
- if (tmpy < 0 or tmpy > ymax):
- incy = -incy
- tmpy += incy
- x1[i] = x2[i]
- y1[i] = y2[i]
- x2[i] = tmpx
- y2[i] = tmpy
- bc[i] = c
- tft.line(x1[i], y1[i], x2[i], y2[i], bc[i])
- tft = display.TFT()
- tft.init(0, mosi=23, miso=19, clk=18, cs=5, dc=17, rst_pin=16, speed=40000000, bgr=True, rot=1)
- tft.set_bg(tft.BLACK)
- tft.clear()
- random.seed(utime.ticks_ms())
- LINES = 80
- xmax = 320
- ymax = 240
- x1 = []
- y1 = []
- x2 = []
- y2 = []
- bc = []
- for i in range(LINES):
- x1.append(0)
- y1.append(0)
- x2.append(0)
- y2.append(0)
- bc.append(0)
- tmpx = random.randint(0, xmax)
- tmpy = random.randint(0, ymax)
- while True:
- c = random.randint(0, 16777215)
- incx = random.randint(0, 13) - 6
- incy = random.randint(0, 13) - 6
- for i in range(LINES):
- draw(c, i)
- utime.sleep(0.02)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement