added get_rg() + improved color gradient
This commit is contained in:
parent
0ba3236432
commit
1dde3dc91f
@ -23,17 +23,7 @@ def bubble_sort(arr, count):
|
||||
mat1 = arr[j].active_material.diffuse_color
|
||||
mat2 = arr[j + 1].active_material.diffuse_color
|
||||
|
||||
#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
|
||||
rg1, rg2 = get_rg(mat1, mat2)
|
||||
|
||||
#compare first colorarray values
|
||||
if rg1 > rg2:
|
||||
@ -72,30 +62,30 @@ def setup_array(count):
|
||||
|
||||
#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_r1 = np.linspace(0, 254, count//2)
|
||||
colors_r2 = np.linspace(255, 255, count//2)
|
||||
colors_r1 = np.linspace(0, 225, count//2)
|
||||
colors_r2 = np.linspace(230, 255, count//2)
|
||||
for i in range(count):
|
||||
if(i < count//2):
|
||||
colors_r[i]=colors_r1[i]
|
||||
else:
|
||||
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_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):
|
||||
if(i < count//2):
|
||||
colors_g[i]=colors_g1[i]
|
||||
else:
|
||||
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_b1 = np.linspace(200, 0, count//2)
|
||||
colors_b2 = np.linspace(10, 100, count//2)
|
||||
colors_b1 = np.linspace(200, 20, count//2)
|
||||
colors_b2 = np.linspace(0, 100, count//2)
|
||||
for i in range(count):
|
||||
if(i < count//2):
|
||||
colors_b[i]=colors_b1[i]
|
||||
@ -138,16 +128,41 @@ def setup_array(count):
|
||||
for j in range(count):
|
||||
planes[j+i*count].data.materials.append(materials[j]) #add the material to the object
|
||||
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)
|
||||
|
||||
############################################################
|
||||
# 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
|
||||
############################################################
|
||||
|
||||
#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):
|
||||
bubble_sort(Matrix[i], count)
|
@ -17,53 +17,33 @@ def heapify(arr, n, i, seed):
|
||||
l = 2 * i + 1 # left = 2*i + 1
|
||||
r = 2 * i + 2 # right = 2*i + 2
|
||||
|
||||
# See if left child of root exists and is
|
||||
# greater than root
|
||||
|
||||
try:
|
||||
#get materials during loop
|
||||
mat1 = arr[largest].active_material.diffuse_color
|
||||
mat2 = arr[l].active_material.diffuse_color
|
||||
|
||||
#get R value of both materials
|
||||
r1 = mat1[0]
|
||||
r2 = mat2[0]
|
||||
#get RG values from materials
|
||||
rg1, rg2 = get_rg(mat1, mat2)
|
||||
|
||||
#get G value of both materials
|
||||
g1 = mat1[1]
|
||||
g2 = mat2[1]
|
||||
|
||||
# R + G = value for comparison
|
||||
rg1 = r1 + g1
|
||||
rg2 = r2 + g2
|
||||
except:
|
||||
print("l to big")
|
||||
|
||||
|
||||
# See if left child of root exists and is greater than root
|
||||
if l < n and rg1 < rg2:
|
||||
largest = l
|
||||
|
||||
# See if right child of root exists and is
|
||||
# greater than root
|
||||
|
||||
try:
|
||||
#get materials during loop
|
||||
mat1 = arr[largest].active_material.diffuse_color
|
||||
mat2 = arr[r].active_material.diffuse_color
|
||||
|
||||
#get R value of both materials
|
||||
r1 = mat1[0]
|
||||
r2 = mat2[0]
|
||||
#get RG values from materials
|
||||
rg1, rg2 = get_rg(mat1, mat2)
|
||||
|
||||
#get G value of both materials
|
||||
g1 = mat1[1]
|
||||
g2 = mat2[1]
|
||||
|
||||
# R + G = value for comparison
|
||||
rg1 = r1 + g1
|
||||
rg2 = r2 + g2
|
||||
except:
|
||||
print("r to big")
|
||||
|
||||
|
||||
# See if right child of root exists and is greater than root
|
||||
if r < n and rg1 < rg2:
|
||||
largest = r
|
||||
|
||||
@ -133,30 +113,30 @@ def setup_array(count):
|
||||
|
||||
#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_r1 = np.linspace(0, 254, count//2)
|
||||
colors_r2 = np.linspace(255, 255, count//2)
|
||||
colors_r1 = np.linspace(0, 225, count//2)
|
||||
colors_r2 = np.linspace(230, 255, count//2)
|
||||
for i in range(count):
|
||||
if(i < count//2):
|
||||
colors_r[i]=colors_r1[i]
|
||||
else:
|
||||
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_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):
|
||||
if(i < count//2):
|
||||
colors_g[i]=colors_g1[i]
|
||||
else:
|
||||
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_b1 = np.linspace(255, 0, count//2)
|
||||
colors_b2 = np.linspace(10, 100, count//2)
|
||||
colors_b1 = np.linspace(200, 20, count//2)
|
||||
colors_b2 = np.linspace(0, 100, count//2)
|
||||
for i in range(count):
|
||||
if(i < count//2):
|
||||
colors_b[i]=colors_b1[i]
|
||||
@ -207,11 +187,31 @@ def setup_array(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
|
||||
############################################################
|
||||
|
||||
Matrix, count = setup_array(50)
|
||||
Matrix, count = setup_array(24)
|
||||
|
||||
#quick_sort every array
|
||||
for i in range(count):
|
||||
|
@ -27,17 +27,7 @@ def insertion_sort(arr, count):
|
||||
mat1 = arr[j].active_material.diffuse_color
|
||||
mat2 = key_item.active_material.diffuse_color
|
||||
|
||||
#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
|
||||
rg1, rg2 = get_rg(mat1, mat2)
|
||||
|
||||
while j >= 0 and rg1 > rg2:
|
||||
|
||||
@ -54,17 +44,7 @@ def insertion_sort(arr, count):
|
||||
mat1 = arr[j].active_material.diffuse_color
|
||||
mat2 = key_item.active_material.diffuse_color
|
||||
|
||||
#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
|
||||
rg1, rg2 = get_rg(mat1, mat2)
|
||||
|
||||
#adding keyframes to all planes whenever one position/location is shifted
|
||||
for plane in arr:
|
||||
@ -111,29 +91,29 @@ def setup_array(count):
|
||||
|
||||
#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_r1 = np.linspace(0, 255, count//2)
|
||||
colors_r2 = np.linspace(255, 255, count//2)
|
||||
colors_r1 = np.linspace(0, 225, count//2)
|
||||
colors_r2 = np.linspace(230, 255, count//2)
|
||||
for i in range(count):
|
||||
if(i < count//2):
|
||||
colors_r[i]=colors_r1[i]
|
||||
else:
|
||||
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_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):
|
||||
if(i < count//2):
|
||||
colors_g[i]=colors_g1[i]
|
||||
else:
|
||||
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_b1 = np.linspace(200, 0, count//2)
|
||||
colors_b1 = np.linspace(200, 20, count//2)
|
||||
colors_b2 = np.linspace(0, 100, count//2)
|
||||
for i in range(count):
|
||||
if(i < count//2):
|
||||
@ -177,14 +157,40 @@ def setup_array(count):
|
||||
for j in range(count):
|
||||
planes[j+i*count].data.materials.append(materials[j]) #add the material to the object
|
||||
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)
|
||||
|
||||
############################################################
|
||||
# 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
|
||||
############################################################
|
||||
|
||||
Matrix, count = setup_array(30)#only even numbers are valid
|
||||
Matrix, count = setup_array(24)#only even numbers are valid
|
||||
|
||||
#insertion_sort every array
|
||||
for i in range(count):
|
||||
|
@ -14,7 +14,6 @@ def merge(seed, arr, l, m, r):
|
||||
global Matrix
|
||||
global iframe
|
||||
|
||||
|
||||
n1 = m - l + 1
|
||||
n2 = r - m
|
||||
|
||||
@ -39,17 +38,8 @@ def merge(seed, arr, l, m, r):
|
||||
mat1 = L[i].active_material.diffuse_color
|
||||
mat2 = R[j].active_material.diffuse_color
|
||||
|
||||
#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
|
||||
#get RG values from materials
|
||||
rg1, rg2 = get_rg(mat1, mat2)
|
||||
|
||||
if rg1 <= rg2:
|
||||
arr[k] = L[i]
|
||||
@ -74,8 +64,7 @@ def merge(seed, arr, l, m, r):
|
||||
|
||||
iframe += 1
|
||||
|
||||
# Copy the remaining elements of L[], if there
|
||||
# are any
|
||||
# Copy the remaining elements of L[], if there are any
|
||||
while i < n1:
|
||||
arr[k] = L[i]
|
||||
L[i].location.x = k * 2
|
||||
@ -92,8 +81,7 @@ def merge(seed, arr, l, m, r):
|
||||
i += 1
|
||||
k += 1
|
||||
|
||||
# Copy the remaining elements of R[], if there
|
||||
# are any
|
||||
# Copy the remaining elements of R[], if there are any
|
||||
while j < n2:
|
||||
arr[k] = R[j]
|
||||
|
||||
@ -108,15 +96,14 @@ def merge(seed, arr, l, m, r):
|
||||
|
||||
j += 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):
|
||||
if l < r:
|
||||
|
||||
# Same as (l+r)//2, but avoids overflow for
|
||||
# large l and h
|
||||
# Same as (l+r)//2, but avoids overflow for large l and h
|
||||
m = l+(r-l)//2
|
||||
|
||||
# Sort first and second halves
|
||||
merge_sort(seed, iframe,arr, l, m)
|
||||
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
|
||||
|
||||
#first half 0 --> 255, second half 255 --> 255
|
||||
#add red values to array
|
||||
colors_r = [0 for i in range(count)]
|
||||
colors_r1 = np.linspace(0, 255, count//2)
|
||||
colors_r2 = np.linspace(255, 255, count//2)
|
||||
colors_r1 = np.linspace(0, 225, count//2)
|
||||
colors_r2 = np.linspace(230, 255, count//2)
|
||||
for i in range(count):
|
||||
if(i < count//2):
|
||||
colors_r[i]=colors_r1[i]
|
||||
else:
|
||||
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_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):
|
||||
if(i < count//2):
|
||||
colors_g[i]=colors_g1[i]
|
||||
else:
|
||||
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_b1 = np.linspace(200, 0, count//2)
|
||||
colors_b1 = np.linspace(200, 20, count//2)
|
||||
colors_b2 = np.linspace(0, 100, count//2)
|
||||
for i in range(count):
|
||||
if(i < count//2):
|
||||
@ -208,17 +195,41 @@ def setup_array(count):
|
||||
for j in range(count):
|
||||
planes[j+i*count].data.materials.append(materials[j]) #add the material to the object
|
||||
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)
|
||||
|
||||
############################################################
|
||||
# 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
|
||||
############################################################
|
||||
|
||||
#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):
|
||||
iframe = 0
|
||||
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
|
||||
mat2 = pivot.active_material.diffuse_color
|
||||
|
||||
#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
|
||||
#get RG values from materials
|
||||
rg1, rg2 = get_rg(mat1, mat2)
|
||||
|
||||
while rg1 < rg2:
|
||||
i += 1
|
||||
mat1 = array[i].active_material.diffuse_color
|
||||
mat2 = pivot.active_material.diffuse_color
|
||||
|
||||
#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
|
||||
#get RG values from materials
|
||||
rg1, rg2 = get_rg(mat1, mat2)
|
||||
|
||||
mat3 = array[j].active_material.diffuse_color
|
||||
mat4 = pivot.active_material.diffuse_color
|
||||
mat1 = array[j].active_material.diffuse_color
|
||||
mat2 = pivot.active_material.diffuse_color
|
||||
|
||||
#get R value of both materials
|
||||
r3 = mat3[0]
|
||||
r4 = mat4[0]
|
||||
#get RG values from materials
|
||||
rg1, rg2 = get_rg(mat1, mat2)
|
||||
|
||||
#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:
|
||||
while rg1 > rg2:
|
||||
j -= 1
|
||||
mat3 = array[j].active_material.diffuse_color
|
||||
mat4 = pivot.active_material.diffuse_color
|
||||
mat1 = array[j].active_material.diffuse_color
|
||||
mat2 = 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
|
||||
#get RG values from materials
|
||||
rg1, rg2 = get_rg(mat1, mat2)
|
||||
|
||||
if i >= j:
|
||||
return j
|
||||
@ -138,29 +102,29 @@ def setup_array(count):
|
||||
|
||||
#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_r1 = np.linspace(0, 255, count//2)
|
||||
colors_r2 = np.linspace(255, 255, count//2)
|
||||
colors_r1 = np.linspace(0, 225, count//2)
|
||||
colors_r2 = np.linspace(230, 255, count//2)
|
||||
for i in range(count):
|
||||
if(i < count//2):
|
||||
colors_r[i]=colors_r1[i]
|
||||
else:
|
||||
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_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):
|
||||
if(i < count//2):
|
||||
colors_g[i]=colors_g1[i]
|
||||
else:
|
||||
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_b1 = np.linspace(200, 0, count//2)
|
||||
colors_b1 = np.linspace(200, 20, count//2)
|
||||
colors_b2 = np.linspace(0, 100, count//2)
|
||||
for i in range(count):
|
||||
if(i < count//2):
|
||||
@ -199,20 +163,45 @@ def setup_array(count):
|
||||
|
||||
#add materials to planes and planes to 2d array
|
||||
for i in range(count):
|
||||
|
||||
#randomize distribution of colors for every row
|
||||
random.shuffle(materials)
|
||||
for j in range(count):
|
||||
planes[j+i*count].data.materials.append(materials[j]) #add the material to the object
|
||||
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)
|
||||
|
||||
############################################################
|
||||
# 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
|
||||
############################################################
|
||||
|
||||
Matrix, count = setup_array(12)
|
||||
Matrix, count = setup_array(24)#only even numbers are valid
|
||||
|
||||
#quick_sort every array
|
||||
for i in range(count):
|
||||
|
@ -25,17 +25,8 @@ def selection_sort(arr, count):
|
||||
mat1 = arr[min_idx].active_material.diffuse_color
|
||||
mat2 = arr[j].active_material.diffuse_color
|
||||
|
||||
#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
|
||||
#get RG values from materials
|
||||
rg1, rg2 = get_rg(mat1, mat2)
|
||||
|
||||
if rg1 > rg2:
|
||||
min_idx = j
|
||||
@ -69,29 +60,29 @@ def setup_array(count):
|
||||
|
||||
#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_r1 = np.linspace(0, 255, count//2)
|
||||
colors_r2 = np.linspace(255, 255, count//2)
|
||||
colors_r1 = np.linspace(0, 225, count//2)
|
||||
colors_r2 = np.linspace(230, 255, count//2)
|
||||
for i in range(count):
|
||||
if(i < count//2):
|
||||
colors_r[i]=colors_r1[i]
|
||||
else:
|
||||
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_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):
|
||||
if(i < count//2):
|
||||
colors_g[i]=colors_g1[i]
|
||||
else:
|
||||
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_b1 = np.linspace(200, 0, count//2)
|
||||
colors_b1 = np.linspace(200, 20, count//2)
|
||||
colors_b2 = np.linspace(0, 100, count//2)
|
||||
for i in range(count):
|
||||
if(i < count//2):
|
||||
@ -135,16 +126,39 @@ def setup_array(count):
|
||||
for j in range(count):
|
||||
planes[j+i*count].data.materials.append(materials[j]) #add the material to the object
|
||||
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)
|
||||
|
||||
############################################################
|
||||
# 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
|
||||
############################################################
|
||||
|
||||
Matrix, count = setup_array(24)
|
||||
Matrix, count = setup_array(24)#only even numbers are valid
|
||||
|
||||
#selection_sort every array
|
||||
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
|
||||
mat2 = arr[i].active_material.diffuse_color
|
||||
|
||||
#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
|
||||
#get RG values from materials
|
||||
rg1, rg2 = get_rg(mat1, mat2)
|
||||
|
||||
if rg1 > rg2:
|
||||
break
|
||||
@ -85,29 +76,29 @@ def setup_array(count):
|
||||
|
||||
#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_r1 = np.linspace(0, 255, count//2)
|
||||
colors_r2 = np.linspace(255, 255, count//2)
|
||||
colors_r1 = np.linspace(0, 225, count//2)
|
||||
colors_r2 = np.linspace(230, 255, count//2)
|
||||
for i in range(count):
|
||||
if(i < count//2):
|
||||
colors_r[i]=colors_r1[i]
|
||||
else:
|
||||
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_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):
|
||||
if(i < count//2):
|
||||
colors_g[i]=colors_g1[i]
|
||||
else:
|
||||
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_b1 = np.linspace(200, 0, count//2)
|
||||
colors_b1 = np.linspace(200, 20, count//2)
|
||||
colors_b2 = np.linspace(0, 100, count//2)
|
||||
for i in range(count):
|
||||
if(i < count//2):
|
||||
@ -151,16 +142,39 @@ def setup_array(count):
|
||||
for j in range(count):
|
||||
planes[j+i*count].data.materials.append(materials[j]) #add the material to the object
|
||||
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)
|
||||
|
||||
############################################################
|
||||
# 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
|
||||
############################################################
|
||||
|
||||
Matrix, count = setup_array(24)
|
||||
Matrix, count = setup_array(24)#only even numbers are valid
|
||||
|
||||
#shell_sort every array
|
||||
for i in range(count):
|
||||
shell_sort(Matrix[i], count)
|
||||
|
||||
shell_sort(Matrix[i], count)
|
Loading…
x
Reference in New Issue
Block a user