-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil.py
70 lines (54 loc) · 1.27 KB
/
util.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
from random import randint
def RGB(color):
r = int(color[1:3], 16)
g = int(color[3:5], 16)
b = int(color[5:7], 16)
a = 255
if len(color) == 9:
a = int(color[7:9], 16)
return r, g, b, a
def mapThis(current, min1, max1, min2, max2):
x = min1
max1 -= x
current -= x
x = min2
max2 -= x
out = (current / max1) * max2
out += x + 1
max2 += x
if out < min2:
out = min2
elif out > max2:
out = max2
return out
def listsub(list1, list2):
list3 = []
for x in range(len(list1)):
list3.append(list1[x] - list2[x])
return list3
def listdivied(list1, x):
if x != 0:
list3 = []
for y in range(len(list1)):
list3.append(list1[y] / x)
return list3
print('Divied By 0')
return list1
def listadd(list1, list2):
list3 = []
for x in range(len(list1)):
list3.append(list1[x] + list2[x])
return list3
def clamp(num, minnum, maxnum):
res = min(max(num, minnum), maxnum)
return res
def listloop(list1, loopby):
list3 = []
for x in range(len(list1)):
list3.append(list1[x] % loopby[x])
return list3
def randColor():
R = randint(0, 200)
G = randint(0, 200)
B = randint(0, 250)
return (R, G, B)