added get_rg() + improved color gradient
This commit is contained in:
@@ -23,17 +23,7 @@ def bubble_sort(arr, count):
|
|||||||
mat1 = arr[j].active_material.diffuse_color
|
mat1 = arr[j].active_material.diffuse_color
|
||||||
mat2 = arr[j + 1].active_material.diffuse_color
|
mat2 = arr[j + 1].active_material.diffuse_color
|
||||||
|
|
||||||
#get R value of both materials
|
rg1, rg2 = get_rg(mat1, mat2)
|
||||||
r1 = mat1[0]
|
|
||||||
r2 = mat2[0]
|
|
||||||
|
|
||||||
#get G value of both materials
|
|
||||||
g1 = mat1[1]
|
|
||||||
g2 = mat2[1]
|
|
||||||
|
|
||||||
# R + G = value for comparison
|
|
||||||
rg1 = r1 + g1
|
|
||||||
rg2 = r2 + g2
|
|
||||||
|
|
||||||
#compare first colorarray values
|
#compare first colorarray values
|
||||||
if rg1 > rg2:
|
if rg1 > rg2:
|
||||||
@@ -72,30 +62,30 @@ def setup_array(count):
|
|||||||
|
|
||||||
#create arrays for each color value (RGB) to generate the sunset gradient
|
#create arrays for each color value (RGB) to generate the sunset gradient
|
||||||
|
|
||||||
#first half 0 --> 255, second half 255 --> 255
|
#add red values to array
|
||||||
colors_r = [0 for i in range(count)]
|
colors_r = [0 for i in range(count)]
|
||||||
colors_r1 = np.linspace(0, 254, count//2)
|
colors_r1 = np.linspace(0, 225, count//2)
|
||||||
colors_r2 = np.linspace(255, 255, count//2)
|
colors_r2 = np.linspace(230, 255, count//2)
|
||||||
for i in range(count):
|
for i in range(count):
|
||||||
if(i < count//2):
|
if(i < count//2):
|
||||||
colors_r[i]=colors_r1[i]
|
colors_r[i]=colors_r1[i]
|
||||||
else:
|
else:
|
||||||
colors_r[i]=colors_r2[i-count//2]
|
colors_r[i]=colors_r2[i-count//2]
|
||||||
|
|
||||||
#first half 0 --> 0, second half 0 --> 200
|
#add green values to array
|
||||||
colors_g = [0 for i in range(count)]
|
colors_g = [0 for i in range(count)]
|
||||||
colors_g1 = np.linspace(0, 0, count//2)
|
colors_g1 = np.linspace(0, 0, count//2)
|
||||||
colors_g2 = np.linspace(10, 200, count//2)
|
colors_g2 = np.linspace(20, 200, count//2)
|
||||||
for i in range(count):
|
for i in range(count):
|
||||||
if(i < count//2):
|
if(i < count//2):
|
||||||
colors_g[i]=colors_g1[i]
|
colors_g[i]=colors_g1[i]
|
||||||
else:
|
else:
|
||||||
colors_g[i]=colors_g2[i-count//2]
|
colors_g[i]=colors_g2[i-count//2]
|
||||||
|
|
||||||
#first half 200 --> 0, secondhalf 0 --> 100
|
#add blue values to array
|
||||||
colors_b = [0 for i in range(count)]
|
colors_b = [0 for i in range(count)]
|
||||||
colors_b1 = np.linspace(200, 0, count//2)
|
colors_b1 = np.linspace(200, 20, count//2)
|
||||||
colors_b2 = np.linspace(10, 100, count//2)
|
colors_b2 = np.linspace(0, 100, count//2)
|
||||||
for i in range(count):
|
for i in range(count):
|
||||||
if(i < count//2):
|
if(i < count//2):
|
||||||
colors_b[i]=colors_b1[i]
|
colors_b[i]=colors_b1[i]
|
||||||
@@ -139,15 +129,40 @@ def setup_array(count):
|
|||||||
planes[j+i*count].data.materials.append(materials[j]) #add the material to the object
|
planes[j+i*count].data.materials.append(materials[j]) #add the material to the object
|
||||||
Matrix[i][j] = planes[j+i*count]
|
Matrix[i][j] = planes[j+i*count]
|
||||||
|
|
||||||
|
#set optimal color managment setting
|
||||||
|
bpy.context.scene.view_settings.exposure = -3.75
|
||||||
|
bpy.context.scene.view_settings.gamma = 0.7
|
||||||
|
bpy.context.scene.view_settings.look = 'Medium Contrast'
|
||||||
|
|
||||||
return(Matrix, count)
|
return(Matrix, count)
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# Get R and G Values from Material
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
def get_rg(mat1, mat2):
|
||||||
|
|
||||||
|
#get R value of both materials
|
||||||
|
r1 = mat1[0]
|
||||||
|
r2 = mat2[0]
|
||||||
|
|
||||||
|
#get G value of both materials
|
||||||
|
g1 = mat1[1]
|
||||||
|
g2 = mat2[1]
|
||||||
|
|
||||||
|
# R + G = value for comparison
|
||||||
|
rg1 = r1 + g1
|
||||||
|
rg2 = r2 + g2
|
||||||
|
|
||||||
|
return rg1, rg2
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# Call Functions
|
# Call Functions
|
||||||
############################################################
|
############################################################
|
||||||
|
|
||||||
#setup_array(number of planes)
|
#setup_array(number of planes)
|
||||||
Matrix, count = setup_array(26)#only even numbers are valid
|
Matrix, count = setup_array(24)#only even numbers are valid
|
||||||
|
|
||||||
#sorting every subarray with bubble_sort + visualisation
|
#bubble_sort + visualisation
|
||||||
for i in range(count):
|
for i in range(count):
|
||||||
bubble_sort(Matrix[i], count)
|
bubble_sort(Matrix[i], count)
|
||||||
@@ -17,53 +17,33 @@ def heapify(arr, n, i, seed):
|
|||||||
l = 2 * i + 1 # left = 2*i + 1
|
l = 2 * i + 1 # left = 2*i + 1
|
||||||
r = 2 * i + 2 # right = 2*i + 2
|
r = 2 * i + 2 # right = 2*i + 2
|
||||||
|
|
||||||
# See if left child of root exists and is
|
|
||||||
# greater than root
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
#get materials during loop
|
#get materials during loop
|
||||||
mat1 = arr[largest].active_material.diffuse_color
|
mat1 = arr[largest].active_material.diffuse_color
|
||||||
mat2 = arr[l].active_material.diffuse_color
|
mat2 = arr[l].active_material.diffuse_color
|
||||||
|
|
||||||
#get R value of both materials
|
#get RG values from materials
|
||||||
r1 = mat1[0]
|
rg1, rg2 = get_rg(mat1, mat2)
|
||||||
r2 = mat2[0]
|
|
||||||
|
|
||||||
#get G value of both materials
|
|
||||||
g1 = mat1[1]
|
|
||||||
g2 = mat2[1]
|
|
||||||
|
|
||||||
# R + G = value for comparison
|
|
||||||
rg1 = r1 + g1
|
|
||||||
rg2 = r2 + g2
|
|
||||||
except:
|
except:
|
||||||
print("l to big")
|
print("l to big")
|
||||||
|
|
||||||
|
# See if left child of root exists and is greater than root
|
||||||
if l < n and rg1 < rg2:
|
if l < n and rg1 < rg2:
|
||||||
largest = l
|
largest = l
|
||||||
|
|
||||||
# See if right child of root exists and is
|
|
||||||
# greater than root
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
#get materials during loop
|
#get materials during loop
|
||||||
mat1 = arr[largest].active_material.diffuse_color
|
mat1 = arr[largest].active_material.diffuse_color
|
||||||
mat2 = arr[r].active_material.diffuse_color
|
mat2 = arr[r].active_material.diffuse_color
|
||||||
|
|
||||||
#get R value of both materials
|
#get RG values from materials
|
||||||
r1 = mat1[0]
|
rg1, rg2 = get_rg(mat1, mat2)
|
||||||
r2 = mat2[0]
|
|
||||||
|
|
||||||
#get G value of both materials
|
|
||||||
g1 = mat1[1]
|
|
||||||
g2 = mat2[1]
|
|
||||||
|
|
||||||
# R + G = value for comparison
|
|
||||||
rg1 = r1 + g1
|
|
||||||
rg2 = r2 + g2
|
|
||||||
except:
|
except:
|
||||||
print("r to big")
|
print("r to big")
|
||||||
|
|
||||||
|
# See if right child of root exists and is greater than root
|
||||||
if r < n and rg1 < rg2:
|
if r < n and rg1 < rg2:
|
||||||
largest = r
|
largest = r
|
||||||
|
|
||||||
@@ -133,30 +113,30 @@ def setup_array(count):
|
|||||||
|
|
||||||
#create arrays for each color value (RGB) to generate the sunset gradient
|
#create arrays for each color value (RGB) to generate the sunset gradient
|
||||||
|
|
||||||
#first half 0 --> 254, second half 255 --> 255
|
#add red values to array
|
||||||
colors_r = [0 for i in range(count)]
|
colors_r = [0 for i in range(count)]
|
||||||
colors_r1 = np.linspace(0, 254, count//2)
|
colors_r1 = np.linspace(0, 225, count//2)
|
||||||
colors_r2 = np.linspace(255, 255, count//2)
|
colors_r2 = np.linspace(230, 255, count//2)
|
||||||
for i in range(count):
|
for i in range(count):
|
||||||
if(i < count//2):
|
if(i < count//2):
|
||||||
colors_r[i]=colors_r1[i]
|
colors_r[i]=colors_r1[i]
|
||||||
else:
|
else:
|
||||||
colors_r[i]=colors_r2[i-count//2]
|
colors_r[i]=colors_r2[i-count//2]
|
||||||
|
|
||||||
#first half 0 --> 0, second half 10 --> 200
|
#add green values to array
|
||||||
colors_g = [0 for i in range(count)]
|
colors_g = [0 for i in range(count)]
|
||||||
colors_g1 = np.linspace(0, 0, count//2)
|
colors_g1 = np.linspace(0, 0, count//2)
|
||||||
colors_g2 = np.linspace(10, 200, count//2)
|
colors_g2 = np.linspace(20, 200, count//2)
|
||||||
for i in range(count):
|
for i in range(count):
|
||||||
if(i < count//2):
|
if(i < count//2):
|
||||||
colors_g[i]=colors_g1[i]
|
colors_g[i]=colors_g1[i]
|
||||||
else:
|
else:
|
||||||
colors_g[i]=colors_g2[i-count//2]
|
colors_g[i]=colors_g2[i-count//2]
|
||||||
|
|
||||||
#first half 200 --> 0, secondhalf 10 --> 100
|
#add blue values to array
|
||||||
colors_b = [0 for i in range(count)]
|
colors_b = [0 for i in range(count)]
|
||||||
colors_b1 = np.linspace(255, 0, count//2)
|
colors_b1 = np.linspace(200, 20, count//2)
|
||||||
colors_b2 = np.linspace(10, 100, count//2)
|
colors_b2 = np.linspace(0, 100, count//2)
|
||||||
for i in range(count):
|
for i in range(count):
|
||||||
if(i < count//2):
|
if(i < count//2):
|
||||||
colors_b[i]=colors_b1[i]
|
colors_b[i]=colors_b1[i]
|
||||||
@@ -207,11 +187,31 @@ def setup_array(count):
|
|||||||
|
|
||||||
return(Matrix, count)
|
return(Matrix, count)
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# Get R and G Values from Material
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
def get_rg(mat1, mat2):
|
||||||
|
|
||||||
|
#get R value of both materials
|
||||||
|
r1 = mat1[0]
|
||||||
|
r2 = mat2[0]
|
||||||
|
|
||||||
|
#get G value of both materials
|
||||||
|
g1 = mat1[1]
|
||||||
|
g2 = mat2[1]
|
||||||
|
|
||||||
|
# R + G = value for comparison
|
||||||
|
rg1 = r1 + g1
|
||||||
|
rg2 = r2 + g2
|
||||||
|
|
||||||
|
return rg1, rg2
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# Call Functions
|
# Call Functions
|
||||||
############################################################
|
############################################################
|
||||||
|
|
||||||
Matrix, count = setup_array(50)
|
Matrix, count = setup_array(24)
|
||||||
|
|
||||||
#quick_sort every array
|
#quick_sort every array
|
||||||
for i in range(count):
|
for i in range(count):
|
||||||
|
|||||||
@@ -27,17 +27,7 @@ def insertion_sort(arr, count):
|
|||||||
mat1 = arr[j].active_material.diffuse_color
|
mat1 = arr[j].active_material.diffuse_color
|
||||||
mat2 = key_item.active_material.diffuse_color
|
mat2 = key_item.active_material.diffuse_color
|
||||||
|
|
||||||
#get R value of both materials
|
rg1, rg2 = get_rg(mat1, mat2)
|
||||||
r1 = mat1[0]
|
|
||||||
r2 = mat2[0]
|
|
||||||
|
|
||||||
#get G value of both materials
|
|
||||||
g1 = mat1[1]
|
|
||||||
g2 = mat2[1]
|
|
||||||
|
|
||||||
# R + G = value for comparison
|
|
||||||
rg1 = r1 + g1
|
|
||||||
rg2 = r2 + g2
|
|
||||||
|
|
||||||
while j >= 0 and rg1 > rg2:
|
while j >= 0 and rg1 > rg2:
|
||||||
|
|
||||||
@@ -54,17 +44,7 @@ def insertion_sort(arr, count):
|
|||||||
mat1 = arr[j].active_material.diffuse_color
|
mat1 = arr[j].active_material.diffuse_color
|
||||||
mat2 = key_item.active_material.diffuse_color
|
mat2 = key_item.active_material.diffuse_color
|
||||||
|
|
||||||
#get R value of both materials
|
rg1, rg2 = get_rg(mat1, mat2)
|
||||||
r1 = mat1[0]
|
|
||||||
r2 = mat2[0]
|
|
||||||
|
|
||||||
#get G value of both materials
|
|
||||||
g1 = mat1[1]
|
|
||||||
g2 = mat2[1]
|
|
||||||
|
|
||||||
# R + G = value for comparison
|
|
||||||
rg1 = r1 + g1
|
|
||||||
rg2 = r2 + g2
|
|
||||||
|
|
||||||
#adding keyframes to all planes whenever one position/location is shifted
|
#adding keyframes to all planes whenever one position/location is shifted
|
||||||
for plane in arr:
|
for plane in arr:
|
||||||
@@ -111,29 +91,29 @@ def setup_array(count):
|
|||||||
|
|
||||||
#create arrays for each color value (RGB) to generate the sunset gradient
|
#create arrays for each color value (RGB) to generate the sunset gradient
|
||||||
|
|
||||||
#first half 0 --> 255, second half 255 --> 255
|
#add red values to array
|
||||||
colors_r = [0 for i in range(count)]
|
colors_r = [0 for i in range(count)]
|
||||||
colors_r1 = np.linspace(0, 255, count//2)
|
colors_r1 = np.linspace(0, 225, count//2)
|
||||||
colors_r2 = np.linspace(255, 255, count//2)
|
colors_r2 = np.linspace(230, 255, count//2)
|
||||||
for i in range(count):
|
for i in range(count):
|
||||||
if(i < count//2):
|
if(i < count//2):
|
||||||
colors_r[i]=colors_r1[i]
|
colors_r[i]=colors_r1[i]
|
||||||
else:
|
else:
|
||||||
colors_r[i]=colors_r2[i-count//2]
|
colors_r[i]=colors_r2[i-count//2]
|
||||||
|
|
||||||
#first half 0 --> 0, second half 0 --> 200
|
#add green values to array
|
||||||
colors_g = [0 for i in range(count)]
|
colors_g = [0 for i in range(count)]
|
||||||
colors_g1 = np.linspace(0, 0, count//2)
|
colors_g1 = np.linspace(0, 0, count//2)
|
||||||
colors_g2 = np.linspace(1, 200, count//2)
|
colors_g2 = np.linspace(20, 200, count//2)
|
||||||
for i in range(count):
|
for i in range(count):
|
||||||
if(i < count//2):
|
if(i < count//2):
|
||||||
colors_g[i]=colors_g1[i]
|
colors_g[i]=colors_g1[i]
|
||||||
else:
|
else:
|
||||||
colors_g[i]=colors_g2[i-count//2]
|
colors_g[i]=colors_g2[i-count//2]
|
||||||
|
|
||||||
#first half 200 --> 0, secondhalf 0 --> 100
|
#add blue values to array
|
||||||
colors_b = [0 for i in range(count)]
|
colors_b = [0 for i in range(count)]
|
||||||
colors_b1 = np.linspace(200, 0, count//2)
|
colors_b1 = np.linspace(200, 20, count//2)
|
||||||
colors_b2 = np.linspace(0, 100, count//2)
|
colors_b2 = np.linspace(0, 100, count//2)
|
||||||
for i in range(count):
|
for i in range(count):
|
||||||
if(i < count//2):
|
if(i < count//2):
|
||||||
@@ -178,13 +158,39 @@ def setup_array(count):
|
|||||||
planes[j+i*count].data.materials.append(materials[j]) #add the material to the object
|
planes[j+i*count].data.materials.append(materials[j]) #add the material to the object
|
||||||
Matrix[i][j] = planes[j+i*count]
|
Matrix[i][j] = planes[j+i*count]
|
||||||
|
|
||||||
|
#set optimal color managment setting
|
||||||
|
bpy.context.scene.view_settings.exposure = -3.75
|
||||||
|
bpy.context.scene.view_settings.gamma = 0.7
|
||||||
|
bpy.context.scene.view_settings.look = 'Medium Contrast'
|
||||||
|
|
||||||
|
|
||||||
return(Matrix, count)
|
return(Matrix, count)
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# Get R and G Values from Material
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
def get_rg(mat1, mat2):
|
||||||
|
|
||||||
|
#get R value of both materials
|
||||||
|
r1 = mat1[0]
|
||||||
|
r2 = mat2[0]
|
||||||
|
|
||||||
|
#get G value of both materials
|
||||||
|
g1 = mat1[1]
|
||||||
|
g2 = mat2[1]
|
||||||
|
|
||||||
|
# R + G = value for comparison
|
||||||
|
rg1 = r1 + g1
|
||||||
|
rg2 = r2 + g2
|
||||||
|
|
||||||
|
return rg1, rg2
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# Call Functions
|
# Call Functions
|
||||||
############################################################
|
############################################################
|
||||||
|
|
||||||
Matrix, count = setup_array(30)#only even numbers are valid
|
Matrix, count = setup_array(24)#only even numbers are valid
|
||||||
|
|
||||||
#insertion_sort every array
|
#insertion_sort every array
|
||||||
for i in range(count):
|
for i in range(count):
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ def merge(seed, arr, l, m, r):
|
|||||||
global Matrix
|
global Matrix
|
||||||
global iframe
|
global iframe
|
||||||
|
|
||||||
|
|
||||||
n1 = m - l + 1
|
n1 = m - l + 1
|
||||||
n2 = r - m
|
n2 = r - m
|
||||||
|
|
||||||
@@ -39,17 +38,8 @@ def merge(seed, arr, l, m, r):
|
|||||||
mat1 = L[i].active_material.diffuse_color
|
mat1 = L[i].active_material.diffuse_color
|
||||||
mat2 = R[j].active_material.diffuse_color
|
mat2 = R[j].active_material.diffuse_color
|
||||||
|
|
||||||
#get R value of both materials
|
#get RG values from materials
|
||||||
r1 = mat1[0]
|
rg1, rg2 = get_rg(mat1, mat2)
|
||||||
r2 = mat2[0]
|
|
||||||
|
|
||||||
#get G value of both materials
|
|
||||||
g1 = mat1[1]
|
|
||||||
g2 = mat2[1]
|
|
||||||
|
|
||||||
# R + G = value for comparison
|
|
||||||
rg1 = r1 + g1
|
|
||||||
rg2 = r2 + g2
|
|
||||||
|
|
||||||
if rg1 <= rg2:
|
if rg1 <= rg2:
|
||||||
arr[k] = L[i]
|
arr[k] = L[i]
|
||||||
@@ -74,8 +64,7 @@ def merge(seed, arr, l, m, r):
|
|||||||
|
|
||||||
iframe += 1
|
iframe += 1
|
||||||
|
|
||||||
# Copy the remaining elements of L[], if there
|
# Copy the remaining elements of L[], if there are any
|
||||||
# are any
|
|
||||||
while i < n1:
|
while i < n1:
|
||||||
arr[k] = L[i]
|
arr[k] = L[i]
|
||||||
L[i].location.x = k * 2
|
L[i].location.x = k * 2
|
||||||
@@ -92,8 +81,7 @@ def merge(seed, arr, l, m, r):
|
|||||||
i += 1
|
i += 1
|
||||||
k += 1
|
k += 1
|
||||||
|
|
||||||
# Copy the remaining elements of R[], if there
|
# Copy the remaining elements of R[], if there are any
|
||||||
# are any
|
|
||||||
while j < n2:
|
while j < n2:
|
||||||
arr[k] = R[j]
|
arr[k] = R[j]
|
||||||
|
|
||||||
@@ -108,15 +96,14 @@ def merge(seed, arr, l, m, r):
|
|||||||
|
|
||||||
j += 1
|
j += 1
|
||||||
k += 1
|
k += 1
|
||||||
# l is for left index and r is right index of the
|
|
||||||
# sub-array of arr to be sorted
|
|
||||||
|
|
||||||
|
# l is for left index and r is right index of the sub-array of arr to be sorted
|
||||||
def merge_sort(seed, iframe,arr, l, r):
|
def merge_sort(seed, iframe,arr, l, r):
|
||||||
if l < r:
|
if l < r:
|
||||||
|
|
||||||
# Same as (l+r)//2, but avoids overflow for
|
# Same as (l+r)//2, but avoids overflow for large l and h
|
||||||
# large l and h
|
|
||||||
m = l+(r-l)//2
|
m = l+(r-l)//2
|
||||||
|
|
||||||
# Sort first and second halves
|
# Sort first and second halves
|
||||||
merge_sort(seed, iframe,arr, l, m)
|
merge_sort(seed, iframe,arr, l, m)
|
||||||
merge_sort(seed, iframe, arr, m+1, r)
|
merge_sort(seed, iframe, arr, m+1, r)
|
||||||
@@ -142,29 +129,29 @@ def setup_array(count):
|
|||||||
|
|
||||||
#create arrays for each color value (RGB) to generate the sunset gradient
|
#create arrays for each color value (RGB) to generate the sunset gradient
|
||||||
|
|
||||||
#first half 0 --> 255, second half 255 --> 255
|
#add red values to array
|
||||||
colors_r = [0 for i in range(count)]
|
colors_r = [0 for i in range(count)]
|
||||||
colors_r1 = np.linspace(0, 255, count//2)
|
colors_r1 = np.linspace(0, 225, count//2)
|
||||||
colors_r2 = np.linspace(255, 255, count//2)
|
colors_r2 = np.linspace(230, 255, count//2)
|
||||||
for i in range(count):
|
for i in range(count):
|
||||||
if(i < count//2):
|
if(i < count//2):
|
||||||
colors_r[i]=colors_r1[i]
|
colors_r[i]=colors_r1[i]
|
||||||
else:
|
else:
|
||||||
colors_r[i]=colors_r2[i-count//2]
|
colors_r[i]=colors_r2[i-count//2]
|
||||||
|
|
||||||
#first half 0 --> 0, second half 0 --> 200
|
#add green values to array
|
||||||
colors_g = [0 for i in range(count)]
|
colors_g = [0 for i in range(count)]
|
||||||
colors_g1 = np.linspace(0, 0, count//2)
|
colors_g1 = np.linspace(0, 0, count//2)
|
||||||
colors_g2 = np.linspace(1, 200, count//2)
|
colors_g2 = np.linspace(20, 200, count//2)
|
||||||
for i in range(count):
|
for i in range(count):
|
||||||
if(i < count//2):
|
if(i < count//2):
|
||||||
colors_g[i]=colors_g1[i]
|
colors_g[i]=colors_g1[i]
|
||||||
else:
|
else:
|
||||||
colors_g[i]=colors_g2[i-count//2]
|
colors_g[i]=colors_g2[i-count//2]
|
||||||
|
|
||||||
#first half 200 --> 0, secondhalf 0 --> 100
|
#add blue values to array
|
||||||
colors_b = [0 for i in range(count)]
|
colors_b = [0 for i in range(count)]
|
||||||
colors_b1 = np.linspace(200, 0, count//2)
|
colors_b1 = np.linspace(200, 20, count//2)
|
||||||
colors_b2 = np.linspace(0, 100, count//2)
|
colors_b2 = np.linspace(0, 100, count//2)
|
||||||
for i in range(count):
|
for i in range(count):
|
||||||
if(i < count//2):
|
if(i < count//2):
|
||||||
@@ -209,16 +196,40 @@ def setup_array(count):
|
|||||||
planes[j+i*count].data.materials.append(materials[j]) #add the material to the object
|
planes[j+i*count].data.materials.append(materials[j]) #add the material to the object
|
||||||
Matrix[i][j] = planes[j+i*count]
|
Matrix[i][j] = planes[j+i*count]
|
||||||
|
|
||||||
|
#set optimal color managment setting
|
||||||
|
bpy.context.scene.view_settings.exposure = -3.75
|
||||||
|
bpy.context.scene.view_settings.gamma = 0.7
|
||||||
|
bpy.context.scene.view_settings.look = 'Medium Contrast'
|
||||||
|
|
||||||
return(Matrix, count)
|
return(Matrix, count)
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# Get R and G Values from Material
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
def get_rg(mat1, mat2):
|
||||||
|
#get R value of both materials
|
||||||
|
r1 = mat1[0]
|
||||||
|
r2 = mat2[0]
|
||||||
|
|
||||||
|
#get G value of both materials
|
||||||
|
g1 = mat1[1]
|
||||||
|
g2 = mat2[1]
|
||||||
|
|
||||||
|
# R + G = value for comparison
|
||||||
|
rg1 = r1 + g1
|
||||||
|
rg2 = r2 + g2
|
||||||
|
|
||||||
|
return rg1, rg2
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# Call Functions
|
# Call Functions
|
||||||
############################################################
|
############################################################
|
||||||
|
|
||||||
#setup_array(number of planes)
|
#setup_array(number of planes)
|
||||||
Matrix, count = setup_array(26)#only even numbers are valid
|
Matrix, count = setup_array(24)#only even numbers are valid
|
||||||
|
|
||||||
#sorting every subarray with merge_sort + visualisation
|
#merge_sort + visualisation
|
||||||
for i in range(count):
|
for i in range(count):
|
||||||
iframe = 0
|
iframe = 0
|
||||||
merge_sort(i,iframe,Matrix[i], 0, count-1)
|
merge_sort(i,iframe,Matrix[i], 0, count-1)
|
||||||
@@ -25,66 +25,30 @@ def partition(seed, array, low, high):
|
|||||||
mat1 = array[i].active_material.diffuse_color
|
mat1 = array[i].active_material.diffuse_color
|
||||||
mat2 = pivot.active_material.diffuse_color
|
mat2 = pivot.active_material.diffuse_color
|
||||||
|
|
||||||
#get R value of both materials
|
#get RG values from materials
|
||||||
r1 = mat1[0]
|
rg1, rg2 = get_rg(mat1, mat2)
|
||||||
r2 = mat2[0]
|
|
||||||
|
|
||||||
#get G value of both materials
|
|
||||||
g1 = mat1[1]
|
|
||||||
g2 = mat2[1]
|
|
||||||
|
|
||||||
# R + G = value for comparison
|
|
||||||
rg1 = r1 + g1
|
|
||||||
rg2 = r2 + g2
|
|
||||||
|
|
||||||
while rg1 < rg2:
|
while rg1 < rg2:
|
||||||
i += 1
|
i += 1
|
||||||
mat1 = array[i].active_material.diffuse_color
|
mat1 = array[i].active_material.diffuse_color
|
||||||
mat2 = pivot.active_material.diffuse_color
|
mat2 = pivot.active_material.diffuse_color
|
||||||
|
|
||||||
#get R value of both materials
|
#get RG values from materials
|
||||||
r1 = mat1[0]
|
rg1, rg2 = get_rg(mat1, mat2)
|
||||||
r2 = mat2[0]
|
|
||||||
|
|
||||||
#get G value of both materials
|
mat1 = array[j].active_material.diffuse_color
|
||||||
g1 = mat1[1]
|
mat2 = pivot.active_material.diffuse_color
|
||||||
g2 = mat2[1]
|
|
||||||
|
|
||||||
# R + G = value for comparison
|
#get RG values from materials
|
||||||
rg1 = r1 + g1
|
rg1, rg2 = get_rg(mat1, mat2)
|
||||||
rg2 = r2 + g2
|
|
||||||
|
|
||||||
mat3 = array[j].active_material.diffuse_color
|
while rg1 > rg2:
|
||||||
mat4 = pivot.active_material.diffuse_color
|
|
||||||
|
|
||||||
#get R value of both materials
|
|
||||||
r3 = mat3[0]
|
|
||||||
r4 = mat4[0]
|
|
||||||
|
|
||||||
#get G value of both materials
|
|
||||||
g3 = mat3[1]
|
|
||||||
g4 = mat4[1]
|
|
||||||
|
|
||||||
# R + G = value for comparison
|
|
||||||
rg3 = r3 + g3
|
|
||||||
rg4 = r4 + g4
|
|
||||||
|
|
||||||
while rg3 > rg4:
|
|
||||||
j -= 1
|
j -= 1
|
||||||
mat3 = array[j].active_material.diffuse_color
|
mat1 = array[j].active_material.diffuse_color
|
||||||
mat4 = pivot.active_material.diffuse_color
|
mat2 = pivot.active_material.diffuse_color
|
||||||
|
|
||||||
#get R value of both materials
|
#get RG values from materials
|
||||||
r3 = mat3[0]
|
rg1, rg2 = get_rg(mat1, mat2)
|
||||||
r4 = mat4[0]
|
|
||||||
|
|
||||||
#get G value of both materials
|
|
||||||
g3 = mat3[1]
|
|
||||||
g4 = mat4[1]
|
|
||||||
|
|
||||||
# R + G = value for comparison
|
|
||||||
rg3 = r3 + g3
|
|
||||||
rg4 = r4 + g4
|
|
||||||
|
|
||||||
if i >= j:
|
if i >= j:
|
||||||
return j
|
return j
|
||||||
@@ -138,29 +102,29 @@ def setup_array(count):
|
|||||||
|
|
||||||
#create arrays for each color value (RGB) to generate the sunset gradient
|
#create arrays for each color value (RGB) to generate the sunset gradient
|
||||||
|
|
||||||
#first half 0 --> 255, second half 255 --> 255
|
#add red values to array
|
||||||
colors_r = [0 for i in range(count)]
|
colors_r = [0 for i in range(count)]
|
||||||
colors_r1 = np.linspace(0, 255, count//2)
|
colors_r1 = np.linspace(0, 225, count//2)
|
||||||
colors_r2 = np.linspace(255, 255, count//2)
|
colors_r2 = np.linspace(230, 255, count//2)
|
||||||
for i in range(count):
|
for i in range(count):
|
||||||
if(i < count//2):
|
if(i < count//2):
|
||||||
colors_r[i]=colors_r1[i]
|
colors_r[i]=colors_r1[i]
|
||||||
else:
|
else:
|
||||||
colors_r[i]=colors_r2[i-count//2]
|
colors_r[i]=colors_r2[i-count//2]
|
||||||
|
|
||||||
#first half 0 --> 0, second half 0 --> 200
|
#add green values to array
|
||||||
colors_g = [0 for i in range(count)]
|
colors_g = [0 for i in range(count)]
|
||||||
colors_g1 = np.linspace(0, 0, count//2)
|
colors_g1 = np.linspace(0, 0, count//2)
|
||||||
colors_g2 = np.linspace(1, 200, count//2)
|
colors_g2 = np.linspace(20, 200, count//2)
|
||||||
for i in range(count):
|
for i in range(count):
|
||||||
if(i < count//2):
|
if(i < count//2):
|
||||||
colors_g[i]=colors_g1[i]
|
colors_g[i]=colors_g1[i]
|
||||||
else:
|
else:
|
||||||
colors_g[i]=colors_g2[i-count//2]
|
colors_g[i]=colors_g2[i-count//2]
|
||||||
|
|
||||||
#first half 200 --> 0, secondhalf 0 --> 100
|
#add blue values to array
|
||||||
colors_b = [0 for i in range(count)]
|
colors_b = [0 for i in range(count)]
|
||||||
colors_b1 = np.linspace(200, 0, count//2)
|
colors_b1 = np.linspace(200, 20, count//2)
|
||||||
colors_b2 = np.linspace(0, 100, count//2)
|
colors_b2 = np.linspace(0, 100, count//2)
|
||||||
for i in range(count):
|
for i in range(count):
|
||||||
if(i < count//2):
|
if(i < count//2):
|
||||||
@@ -199,20 +163,45 @@ def setup_array(count):
|
|||||||
|
|
||||||
#add materials to planes and planes to 2d array
|
#add materials to planes and planes to 2d array
|
||||||
for i in range(count):
|
for i in range(count):
|
||||||
|
|
||||||
#randomize distribution of colors for every row
|
#randomize distribution of colors for every row
|
||||||
random.shuffle(materials)
|
random.shuffle(materials)
|
||||||
for j in range(count):
|
for j in range(count):
|
||||||
planes[j+i*count].data.materials.append(materials[j]) #add the material to the object
|
planes[j+i*count].data.materials.append(materials[j]) #add the material to the object
|
||||||
Matrix[i][j] = planes[j+i*count]
|
Matrix[i][j] = planes[j+i*count]
|
||||||
|
|
||||||
|
#set optimal color managment setting
|
||||||
|
bpy.context.scene.view_settings.exposure = -3.75
|
||||||
|
bpy.context.scene.view_settings.gamma = 0.7
|
||||||
|
bpy.context.scene.view_settings.look = 'Medium Contrast'
|
||||||
|
bpy.context.scene.view_settings.view_transform = 'Standard'
|
||||||
|
|
||||||
return(Matrix, count)
|
return(Matrix, count)
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# Get R and G Values from Material
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
def get_rg(mat1, mat2):
|
||||||
|
#get R value of both materials
|
||||||
|
r1 = mat1[0]
|
||||||
|
r2 = mat2[0]
|
||||||
|
|
||||||
|
#get G value of both materials
|
||||||
|
g1 = mat1[1]
|
||||||
|
g2 = mat2[1]
|
||||||
|
|
||||||
|
# R + G = value for comparison
|
||||||
|
rg1 = r1 + g1
|
||||||
|
rg2 = r2 + g2
|
||||||
|
|
||||||
|
return rg1, rg2
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# Call Functions
|
# Call Functions
|
||||||
############################################################
|
############################################################
|
||||||
|
|
||||||
Matrix, count = setup_array(12)
|
Matrix, count = setup_array(24)#only even numbers are valid
|
||||||
|
|
||||||
#quick_sort every array
|
#quick_sort every array
|
||||||
for i in range(count):
|
for i in range(count):
|
||||||
|
|||||||
@@ -25,17 +25,8 @@ def selection_sort(arr, count):
|
|||||||
mat1 = arr[min_idx].active_material.diffuse_color
|
mat1 = arr[min_idx].active_material.diffuse_color
|
||||||
mat2 = arr[j].active_material.diffuse_color
|
mat2 = arr[j].active_material.diffuse_color
|
||||||
|
|
||||||
#get R value of both materials
|
#get RG values from materials
|
||||||
r1 = mat1[0]
|
rg1, rg2 = get_rg(mat1, mat2)
|
||||||
r2 = mat2[0]
|
|
||||||
|
|
||||||
#get G value of both materials
|
|
||||||
g1 = mat1[1]
|
|
||||||
g2 = mat2[1]
|
|
||||||
|
|
||||||
# R + G = value for comparison
|
|
||||||
rg1 = r1 + g1
|
|
||||||
rg2 = r2 + g2
|
|
||||||
|
|
||||||
if rg1 > rg2:
|
if rg1 > rg2:
|
||||||
min_idx = j
|
min_idx = j
|
||||||
@@ -69,29 +60,29 @@ def setup_array(count):
|
|||||||
|
|
||||||
#create arrays for each color value (RGB) to generate the sunset gradient
|
#create arrays for each color value (RGB) to generate the sunset gradient
|
||||||
|
|
||||||
#first half 0 --> 255, second half 255 --> 255
|
#add red values to array
|
||||||
colors_r = [0 for i in range(count)]
|
colors_r = [0 for i in range(count)]
|
||||||
colors_r1 = np.linspace(0, 255, count//2)
|
colors_r1 = np.linspace(0, 225, count//2)
|
||||||
colors_r2 = np.linspace(255, 255, count//2)
|
colors_r2 = np.linspace(230, 255, count//2)
|
||||||
for i in range(count):
|
for i in range(count):
|
||||||
if(i < count//2):
|
if(i < count//2):
|
||||||
colors_r[i]=colors_r1[i]
|
colors_r[i]=colors_r1[i]
|
||||||
else:
|
else:
|
||||||
colors_r[i]=colors_r2[i-count//2]
|
colors_r[i]=colors_r2[i-count//2]
|
||||||
|
|
||||||
#first half 0 --> 0, second half 0 --> 200
|
#add green values to array
|
||||||
colors_g = [0 for i in range(count)]
|
colors_g = [0 for i in range(count)]
|
||||||
colors_g1 = np.linspace(0, 0, count//2)
|
colors_g1 = np.linspace(0, 0, count//2)
|
||||||
colors_g2 = np.linspace(1, 200, count//2)
|
colors_g2 = np.linspace(20, 200, count//2)
|
||||||
for i in range(count):
|
for i in range(count):
|
||||||
if(i < count//2):
|
if(i < count//2):
|
||||||
colors_g[i]=colors_g1[i]
|
colors_g[i]=colors_g1[i]
|
||||||
else:
|
else:
|
||||||
colors_g[i]=colors_g2[i-count//2]
|
colors_g[i]=colors_g2[i-count//2]
|
||||||
|
|
||||||
#first half 200 --> 0, secondhalf 0 --> 100
|
#add blue values to array
|
||||||
colors_b = [0 for i in range(count)]
|
colors_b = [0 for i in range(count)]
|
||||||
colors_b1 = np.linspace(200, 0, count//2)
|
colors_b1 = np.linspace(200, 20, count//2)
|
||||||
colors_b2 = np.linspace(0, 100, count//2)
|
colors_b2 = np.linspace(0, 100, count//2)
|
||||||
for i in range(count):
|
for i in range(count):
|
||||||
if(i < count//2):
|
if(i < count//2):
|
||||||
@@ -136,15 +127,38 @@ def setup_array(count):
|
|||||||
planes[j+i*count].data.materials.append(materials[j]) #add the material to the object
|
planes[j+i*count].data.materials.append(materials[j]) #add the material to the object
|
||||||
Matrix[i][j] = planes[j+i*count]
|
Matrix[i][j] = planes[j+i*count]
|
||||||
|
|
||||||
|
#set optimal color managment setting
|
||||||
|
bpy.context.scene.view_settings.exposure = -3.75
|
||||||
|
bpy.context.scene.view_settings.gamma = 0.7
|
||||||
|
bpy.context.scene.view_settings.look = 'Medium Contrast'
|
||||||
|
|
||||||
return(Matrix, count)
|
return(Matrix, count)
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# Get R and G Values from Material
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
def get_rg(mat1, mat2):
|
||||||
|
#get R value of both materials
|
||||||
|
r1 = mat1[0]
|
||||||
|
r2 = mat2[0]
|
||||||
|
|
||||||
|
#get G value of both materials
|
||||||
|
g1 = mat1[1]
|
||||||
|
g2 = mat2[1]
|
||||||
|
|
||||||
|
# R + G = value for comparison
|
||||||
|
rg1 = r1 + g1
|
||||||
|
rg2 = r2 + g2
|
||||||
|
|
||||||
|
return rg1, rg2
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# Call Functions
|
# Call Functions
|
||||||
############################################################
|
############################################################
|
||||||
|
|
||||||
Matrix, count = setup_array(24)
|
Matrix, count = setup_array(24)#only even numbers are valid
|
||||||
|
|
||||||
#selection_sort every array
|
#selection_sort every array
|
||||||
for i in range(count):
|
for i in range(count):
|
||||||
selection_sort(Matrix[i], count)
|
selection_sort(Matrix[i], count)
|
||||||
|
|
||||||
|
|||||||
@@ -35,17 +35,8 @@ def shell_sort(arr, count):
|
|||||||
mat1 = arr[i+gap].active_material.diffuse_color
|
mat1 = arr[i+gap].active_material.diffuse_color
|
||||||
mat2 = arr[i].active_material.diffuse_color
|
mat2 = arr[i].active_material.diffuse_color
|
||||||
|
|
||||||
#get R value of both materials
|
#get RG values from materials
|
||||||
r1 = mat1[0]
|
rg1, rg2 = get_rg(mat1, mat2)
|
||||||
r2 = mat2[0]
|
|
||||||
|
|
||||||
#get G value of both materials
|
|
||||||
g1 = mat1[1]
|
|
||||||
g2 = mat2[1]
|
|
||||||
|
|
||||||
# R + G = value for comparison
|
|
||||||
rg1 = r1 + g1
|
|
||||||
rg2 = r2 + g2
|
|
||||||
|
|
||||||
if rg1 > rg2:
|
if rg1 > rg2:
|
||||||
break
|
break
|
||||||
@@ -85,29 +76,29 @@ def setup_array(count):
|
|||||||
|
|
||||||
#create arrays for each color value (RGB) to generate the sunset gradient
|
#create arrays for each color value (RGB) to generate the sunset gradient
|
||||||
|
|
||||||
#first half 0 --> 255, second half 255 --> 255
|
#add red values to array
|
||||||
colors_r = [0 for i in range(count)]
|
colors_r = [0 for i in range(count)]
|
||||||
colors_r1 = np.linspace(0, 255, count//2)
|
colors_r1 = np.linspace(0, 225, count//2)
|
||||||
colors_r2 = np.linspace(255, 255, count//2)
|
colors_r2 = np.linspace(230, 255, count//2)
|
||||||
for i in range(count):
|
for i in range(count):
|
||||||
if(i < count//2):
|
if(i < count//2):
|
||||||
colors_r[i]=colors_r1[i]
|
colors_r[i]=colors_r1[i]
|
||||||
else:
|
else:
|
||||||
colors_r[i]=colors_r2[i-count//2]
|
colors_r[i]=colors_r2[i-count//2]
|
||||||
|
|
||||||
#first half 0 --> 0, second half 0 --> 200
|
#add green values to array
|
||||||
colors_g = [0 for i in range(count)]
|
colors_g = [0 for i in range(count)]
|
||||||
colors_g1 = np.linspace(0, 0, count//2)
|
colors_g1 = np.linspace(0, 0, count//2)
|
||||||
colors_g2 = np.linspace(1, 200, count//2)
|
colors_g2 = np.linspace(20, 200, count//2)
|
||||||
for i in range(count):
|
for i in range(count):
|
||||||
if(i < count//2):
|
if(i < count//2):
|
||||||
colors_g[i]=colors_g1[i]
|
colors_g[i]=colors_g1[i]
|
||||||
else:
|
else:
|
||||||
colors_g[i]=colors_g2[i-count//2]
|
colors_g[i]=colors_g2[i-count//2]
|
||||||
|
|
||||||
#first half 200 --> 0, secondhalf 0 --> 100
|
#add blue values to array
|
||||||
colors_b = [0 for i in range(count)]
|
colors_b = [0 for i in range(count)]
|
||||||
colors_b1 = np.linspace(200, 0, count//2)
|
colors_b1 = np.linspace(200, 20, count//2)
|
||||||
colors_b2 = np.linspace(0, 100, count//2)
|
colors_b2 = np.linspace(0, 100, count//2)
|
||||||
for i in range(count):
|
for i in range(count):
|
||||||
if(i < count//2):
|
if(i < count//2):
|
||||||
@@ -152,15 +143,38 @@ def setup_array(count):
|
|||||||
planes[j+i*count].data.materials.append(materials[j]) #add the material to the object
|
planes[j+i*count].data.materials.append(materials[j]) #add the material to the object
|
||||||
Matrix[i][j] = planes[j+i*count]
|
Matrix[i][j] = planes[j+i*count]
|
||||||
|
|
||||||
|
#set optimal color managment setting
|
||||||
|
bpy.context.scene.view_settings.exposure = -3.75
|
||||||
|
bpy.context.scene.view_settings.gamma = 0.7
|
||||||
|
bpy.context.scene.view_settings.look = 'Medium Contrast'
|
||||||
|
|
||||||
return(Matrix, count)
|
return(Matrix, count)
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# Get R and G Values from Material
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
def get_rg(mat1, mat2):
|
||||||
|
#get R value of both materials
|
||||||
|
r1 = mat1[0]
|
||||||
|
r2 = mat2[0]
|
||||||
|
|
||||||
|
#get G value of both materials
|
||||||
|
g1 = mat1[1]
|
||||||
|
g2 = mat2[1]
|
||||||
|
|
||||||
|
# R + G = value for comparison
|
||||||
|
rg1 = r1 + g1
|
||||||
|
rg2 = r2 + g2
|
||||||
|
|
||||||
|
return rg1, rg2
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# Call Functions
|
# Call Functions
|
||||||
############################################################
|
############################################################
|
||||||
|
|
||||||
Matrix, count = setup_array(24)
|
Matrix, count = setup_array(24)#only even numbers are valid
|
||||||
|
|
||||||
#shell_sort every array
|
#shell_sort every array
|
||||||
for i in range(count):
|
for i in range(count):
|
||||||
shell_sort(Matrix[i], count)
|
shell_sort(Matrix[i], count)
|
||||||
|
|
||||||
Reference in New Issue
Block a user