Advertisement
jpglickwebber

rectanglesandscramble.py

Jul 17th, 2022
5,343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.31 KB | None | 0 0
  1. import cv2 as cv
  2. import numpy as np
  3. import random
  4. import imagelib as il
  5.  
  6. fourcc=cv.VideoWriter_fourcc(*'DIVX')
  7. film = cv.VideoWriter('film.mkv', fourcc, 24, (1440,1080))
  8. frame=255*np.ones((1080,1440,3), np.uint8)
  9. random.seed()
  10.  
  11. for x in range(1, 14401):
  12.     print(x)
  13.     h=int(360*(x/4800))%360
  14.     s=100
  15.     l=random.randint(40,60)
  16.     bgr=il.hslToBGR((h,s,l))
  17.     if(x%12!=1):
  18.         area = random.randint(10000,int(1440*1080/8))
  19.         minLength=int(max(area/800,50))
  20.         maxLength=int(area/minLength)
  21.         length=random.randint(minLength, maxLength)
  22.         height=int(area/length)
  23.         x1=random.randint(0,1439-length)
  24.         y1=random.randint(0,1079-height)
  25.         x2=x1+length
  26.         y2=y1+height
  27.         x3=random.randint(0,1439-length)
  28.         y3=random.randint(0,1079-height)
  29.         frame=il.moveEllipse(frame, x1, y1, x2, y2, x3, y3)
  30.     else:
  31.         area = random.randint(10000,250000)
  32.         minLength=int(max(area/800,50))
  33.         maxLength=int(area/minLength)
  34.         length=random.randint(minLength, maxLength)
  35.         height=int(area/length)
  36.         x1=random.randint(0,1439-length)
  37.         y1=random.randint(0,1079-height)
  38.         x2=x1+length
  39.         y2=y1+height
  40.         cv.rectangle(frame, (x1,y1), (x2,y2), bgr, cv.FILLED)
  41.     film.write(frame)
  42.  
  43. print('done')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement