-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcolors.py
83 lines (63 loc) · 2.71 KB
/
colors.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
71
72
73
74
75
76
77
78
79
80
81
82
83
from numba import cuda
from math import log as real_log
from numba import float64, int8
@cuda.jit('void(int8[:,:,:], int32, int32, int32, int32)', device=True)
def get_log_color_rgb(image_array, x, y, iterations, max_iterations):
if iterations == max_iterations:
return
k = 3.0 * real_log(float64(iterations)) / real_log(float64(max_iterations))
if k < 1:
image_array[y, x, 0] = int8(255 * k)
image_array[y, x, 1] = 0
image_array[y, x, 2] = 0
elif k < 2:
image_array[y, x, 0] = 255
image_array[y, x, 1] = int8(255 * (k - 1))
image_array[y, x, 2] = 0
else:
image_array[y, x, 0] = 255
image_array[y, x, 1] = 255
image_array[y, x, 2] = int8(255 * (k - 2))
@cuda.jit('void(int8[:,:,:], int32, int32, int32, int32)', device=True)
def get_log_color_bgr(image_array, x, y, iterations, max_iterations):
if iterations == max_iterations:
return
k = 3.0 * real_log(float64(iterations)) / real_log(float64(max_iterations) - 1.0)
if k < 1:
image_array[y, x, 0] = 0
image_array[y, x, 1] = 0
image_array[y, x, 2] = int8(255 * k)
elif k < 2:
image_array[y, x, 0] = 0
image_array[y, x, 1] = int8(255 * (k - 1))
image_array[y, x, 2] = 255
else:
image_array[y, x, 0] = int8(255 * (k - 2))
image_array[y, x, 1] = 255
image_array[y, x, 2] = 255
@cuda.jit('void(int8[:,:,:], int32, int32, int32, int32)', device=True)
def get_log_color_gray(image_array, x, y, iterations, max_iterations):
if iterations == max_iterations:
return
k = real_log(float64(iterations)) / real_log(float64(max_iterations) - 1.0)
image_array[y, x, 0] = int8(255 * k)
image_array[y, x, 1] = int8(255 * k)
image_array[y, x, 2] = int8(255 * k)
@cuda.jit('void(int8[:,:,:], int32, int32, int32, int32)', device=True)
def get_log_color_r(image_array, x, y, iterations, max_iterations):
if iterations == max_iterations:
return
k = real_log(float64(iterations)) / real_log(float64(max_iterations) - 1.0)
image_array[y, x, 0] = int8(255 * k)
@cuda.jit('void(int8[:,:,:], int32, int32, int32, int32)', device=True)
def get_log_color_g(image_array, x, y, iterations, max_iterations):
if iterations == max_iterations:
return
k = real_log(float64(iterations)) / real_log(float64(max_iterations) - 1.0)
image_array[y, x, 1] = int8(255 * k)
@cuda.jit('void(int8[:,:,:], int32, int32, int32, int32)', device=True)
def get_log_color_b(image_array, x, y, iterations, max_iterations):
if iterations == max_iterations:
return
k = real_log(float64(iterations)) / real_log(float64(max_iterations) - 1.0)
image_array[y, x, 2] = int8(255 * k)