Advertisement
yclee126

drag shade

Jul 26th, 2021 (edited)
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. import cv2
  2. import numpy as np
  3.  
  4. parts = 5
  5. phase = 0 # 0 ~ parts*2 = 0
  6. w, h = 500, 100
  7.  
  8. while True:
  9.     img = np.zeros((h, w, 3), dtype='uint8')
  10.     if phase >= parts:
  11.         per = parts - (phase - parts)
  12.     else:
  13.         per = phase
  14.     coord = int(per / parts * w)
  15.    
  16.     img = cv2.rectangle(img, (coord, 0), (0, h-1), (255, 255, 255), -1)
  17.     cv2.imshow('win', img)
  18.     cv2.waitKey(1)
  19.    
  20.     phase += 1
  21.     phase %= parts*2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement