-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
spectrum.py
1474 lines (1277 loc) · 69.2 KB
/
spectrum.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Spectrum Palette Node
import bpy
import json, os
from bpy.types import Node
from mathutils import Color
from collections import Counter
import random
import requests, math
import xml.etree.ElementTree as ET
from . import client
if "bpy" in locals():
import importlib
importlib.reload(client)
PaletteHistory = []
Palette_idHistory = [0, 0, 0]
palette = {}
shuffle_time = 1
before_shuffle_colors=[]
community_maintain = False
community_palette = {}
online_check = True
lovers_id = None
for i in range(1, 16):
PaletteHistory.append(Color())
for i in range(0, 15):
if i % 5 == 0:
PaletteHistory[i].r = 0.009
PaletteHistory[i].g = 0.421
PaletteHistory[i].b = 0.554
elif i % 5 == 1:
PaletteHistory[i].r = 0.267
PaletteHistory[i].g = 0.639
PaletteHistory[i].b = 0.344
elif i % 5 == 2:
PaletteHistory[i].r = 0.612
PaletteHistory[i].g = 0.812
PaletteHistory[i].b = 0.194
elif i % 5 == 3:
PaletteHistory[i].r = 0.974
PaletteHistory[i].g = 0.465
PaletteHistory[i].b = 0.08
elif i % 5 == 4:
PaletteHistory[i].r = 1.0
PaletteHistory[i].g = 0.08
PaletteHistory[i].b = 0.087
class SpectrumTreeNode:
@classmethod
def poll(cls, ntree):
b = False
if ntree.bl_idname == 'ShaderNodeTree':
b = True
return b
class SpectrumProperties(bpy.types.PropertyGroup):
"""Properties of Spectrum which are created for every new scene"""
def update_color(self, context):
update_caller(self, "Color 1", self.color1)
update_caller(self, "Color 2", self.color2)
update_caller(self, "Color 3", self.color3)
update_caller(self, "Color 4", self.color4)
update_caller(self, "Color 5", self.color5)
def set_type(self, context):
self.random_int = int(self.gen_type)
self.random_custom_int = int(self.custom_gen_type)
self.random_online_int = int(self.online_type)
def set_global_settings(self, context):
c = Color()
for i in range(0,5):
if self.history_count == 0:
exec("c.r = PaletteHistory[1"+str(i)+"].r")
exec("c.g = PaletteHistory[1"+str(i)+"].g")
exec("c.b = PaletteHistory[1"+str(i)+"].b")
elif self.history_count == 1:
exec("c.r = PaletteHistory["+str(i+5)+"].r")
exec("c.g = PaletteHistory["+str(i+5)+"].g")
exec("c.b = PaletteHistory["+str(i+5)+"].b")
elif self.history_count == 2:
exec("c.r = PaletteHistory["+str(i)+"].r")
exec("c.g = PaletteHistory["+str(i)+"].g")
exec("c.b = PaletteHistory["+str(i)+"].b")
c.v = c.v+self.value_slider
c.s = c.s+self.saturation_slider
# Hue correction, as it is a single sphere without a bound
val = c.h+self.hue_slider
c.h = val if val < 1 else val - 1
exec("self.color"+str(i+1)+" = c.r, c.g, c.b, 1.0")
exec("self.color"+str(i+1)+" = c.r, c.g, c.b, 1.0")
exec("self.color"+str(i+1)+" = c.r, c.g, c.b, 1.0")
def get_saved_palettes(self, context):
saved_palettes_list = []
i=0
if not os.path.exists(os.path.join(os.path.dirname(__file__), "palettes")):
os.makedirs(os.path.join(os.path.dirname(__file__), "palettes"))
for sub in os.listdir(os.path.join(os.path.dirname(__file__), "palettes")):
if os.path.isfile(os.path.join(os.path.dirname(__file__), "palettes", str(sub))):
name = str(sub)
if name.endswith('.json'):
name = name[:-5]
name = name.title()
name = name.replace('_', ' ')
saved_palettes_list.append((name, name, "Choose the Saved Palette from Local Library", "FILE", i))
i=i+1
return saved_palettes_list
def import_saved_palette(self, context):
name = self.saved_palettes
name = name.lower()
name = name.replace(' ', '_')
name = name+".json"
path = os.path.join(os.path.dirname(__file__), "palettes", name)
palette_file = open(path, 'r')
self.palette = json.load(palette_file)
for i in range(1, 6):
exec("self.color"+str(i)+" = hex_to_rgb(self.palette[self.saved_palettes]['color"+str(i)+"'])")
palette_file.close()
set_palettes_list(self, context)
def set_ramp(self, context):
set_color_ramp(self)
return None
def set_base_color(self, context):
if self.use_realtime_base == True:
bpy.ops.spectrum_palette.palette_gen('INVOKE_DEFAULT')
return None
value_slider: bpy.props.FloatProperty(name="Global Brightness", description="Control the Overall Brightness of the Palette", min=-0.5, max=0.5, default=0.0, update=set_global_settings)
saturation_slider: bpy.props.FloatProperty(name="Global Saturation", description="Control the Overall Saturation of the Palette", min=-0.5, max=0.5, default=0.0, update=set_global_settings)
hue_slider: bpy.props.FloatProperty(name="Global Hue", description="Control the Overall Hue of the Palette", min=0.0, max=1.0, default=0, update=set_global_settings)
color1: bpy.props.FloatVectorProperty(name="Color1", description="Set Color 1 for the Palette", subtype="COLOR", default=(0.009, 0.421, 0.554,1.0), size=4, max=1.0, min=0.0, update=update_color)
color2: bpy.props.FloatVectorProperty(name="Color2", description="Set Color 2 for the Palette", subtype="COLOR", default=(0.267, 0.639, 0.344,1.0), size=4, max=1.0, min=0.0, update=update_color)
color3: bpy.props.FloatVectorProperty(name="Color3", description="Set Color 3 for the Palette", subtype="COLOR", default=(0.612, 0.812, 0.194,1.0), size=4, max=1.0, min=0.0, update=update_color)
color4: bpy.props.FloatVectorProperty(name="Color4", description="Set Color 4 for the Palette", subtype="COLOR", default=(0.974, 0.465, 0.08,1.0), size=4, max=1.0, min=0.0, update=update_color)
color5: bpy.props.FloatVectorProperty(name="Color5", description="Set Color 5 for the Palette", subtype="COLOR", default=(1.0, 0.08, 0.087,1.0), size=4, max=1.0, min=0.0, update=update_color)
hue: bpy.props.FloatVectorProperty(name="Hue", description="Set the Color for the Base Color to be used in Palette Generation", subtype="COLOR", size=4, max=1.0, min=0.0, default=(random.random(), random.random(), random.random(), 1.0), update=set_base_color)
gen_type: bpy.props.EnumProperty(name="Type of Palette", description="Select the Rule for the Color Palette Generation", items=(('0','Monochromatic','Use Monochromatic Rule for Palette'),('1','Analogous','Use Analogous Rule for Palette'),('2','Complementary','Use Complementary Rule for Palette'),('3','Triadic','Use Triadic Rule for Palette'),('4','Custom','Use Custom Rule for Palette')), update=set_type, default="0")
custom_gen_type: bpy.props.EnumProperty(name="Type of Custom Rule", description="Select the Custom rule for Custom Palette Generation", items=(('0', 'Vibrant', 'Uses Two Vibrant Colors, along with shades of black and white'), ('1', 'Gradient', 'Use Color with same hue, but gradual change in Saturation and Value'), ('2', 'Pop out', 'Pop out effect uses one color in combination with shades of black and white'), ('4', 'Online', 'Get Color Palettes from Internet'), ('3', 'Random Rule', 'Use any Rule or color Effect to generate the palette'), ('5', 'Random', 'Randomly Generated Color scheme, not following any rule!')), update=set_type, default="0")
online_type: bpy.props.EnumProperty(name="Type of Online Palette", description="Select the Type of Online Palettes", items=(('0', 'Standard', 'Use the Online Palettes that I have selected just for you. This includes the best picks by me'), ('1', 'COLOURlovers', '')), default='0', update=set_type)
saved_palettes: bpy.props.EnumProperty(name="Saved Palettes", description="Stores the Saved Palettes", items=get_saved_palettes, update=import_saved_palette)
use_custom: bpy.props.BoolProperty(name="Use Custom", description="Use Custom Values for Base Color", default=False)
use_global: bpy.props.BoolProperty(name="Use Global Controls", description="Use Global Settings to control the overall Color of the Palette", default=False)
use_internet_libs: bpy.props.BoolProperty(name="Internet Library Checker", description="Checks if the palette generated is from Internet library", default=False)
use_organize: bpy.props.BoolProperty(name="Organize the Color Palette", description="Organize the Color palette generated", default=False)
use_realtime_base: bpy.props.BoolProperty(name="Real Time Base Color", description="Use Real time Update of the Base Color in the Palette", default=False)
view_help: bpy.props.BoolProperty(name="Color Rule Help", description="Get some knowledge about this color rule", default=False)
assign_colorramp_world: bpy.props.BoolProperty(name="Assign ColorRamp World", description="Assign the Colors from Spectrum to ColorRamp in the World Material", default=False, update=set_ramp)
random_int: bpy.props.IntProperty(name="Random Integer", description="Used to use Random color rules and effects", default=0)
random_custom_int: bpy.props.IntProperty(name="Random Custom Integer", description="Used to use Random color rules and effects", default=0)
random_online_int: bpy.props.IntProperty(name="Random Online Integer", description="Used the use Random color rules from online type", default=0)
new_file: bpy.props.IntProperty(name="File Count",description="", default=1)
online_palette_index: bpy.props.IntProperty(name="Palette Index", description="Stores the Index of the Online Palette")
history_count: bpy.props.IntProperty(name="History Counter", description="Value to Count the Current History Value", default=0)
save_palette_name: bpy.props.StringProperty(name="Save Palette Name", description="Name to be used to save this palette", default="My Palette")
colorramp_world_name: bpy.props.StringProperty(name="ColorRamp name World", description="Select the ColorRamp in the World Material to assign the Colors", default="", update=set_ramp)
class SpectrumMaterialProps(bpy.types.PropertyGroup):
"""Spectrum Properties for Every Material"""
def set_ramp(self, context):
set_color_ramp(self)
return None
colorramp_name: bpy.props.StringProperty(name="ColorRamp name", description="Select the ColorRamp to assign the Colors", default="", update=set_ramp)
assign_colorramp: bpy.props.BoolProperty(name="Assign ColorRamp", description="Assign the Colors from Spectrum to ColorRamp in the Object Material", default=False, update=set_ramp)
def set_color_ramp(self):
"""Set the Colors from the Palette to a ColorRamp node"""
kaleidoscope_spectrum_props=bpy.context.scene.kaleidoscope_spectrum_props
ramp = None
ramp_world = None
if kaleidoscope_spectrum_props.assign_colorramp_world == True:
try:
try:
ramp_world = bpy.context.scene.world.node_tree.nodes[kaleidoscope_spectrum_props.colorramp_world_name].color_ramp
except:
if kaleidoscope_spectrum_props.assign_colorramp_world == True:
try:
self.report({'WARNING'}, "There is Not a Valid ColorRamp Node in the World Material")
except AttributeError:
pass
if kaleidoscope_spectrum_props.colorramp_world_name != "" and kaleidoscope_spectrum_props.assign_colorramp_world == True:
try:
for i in range(0, len(ramp_world.elements)):
if kaleidoscope_spectrum_props.assign_colorramp_world == True:
exec("ramp_world.elements["+str(i)+"].color[0] = kaleidoscope_spectrum_props.color"+str(i+1)+"[0]")
exec("ramp_world.elements["+str(i)+"].color[1] = kaleidoscope_spectrum_props.color"+str(i+1)+"[1]")
exec("ramp_world.elements["+str(i)+"].color[2] = kaleidoscope_spectrum_props.color"+str(i+1)+"[2]")
ramp_world.elements[0].color[3] = 1.0
except:
pass
except:
pass
for mat in bpy.data.materials:
spectrum_active = mat.kaleidoscope_spectrum_props
if spectrum_active.assign_colorramp == True and spectrum_active.colorramp_name != "":
try:
if spectrum_active is not None:
ramp = mat.node_tree.nodes[spectrum_active.colorramp_name].color_ramp
except:
if spectrum_active.assign_colorramp == True:
try:
self.report({'WARNING'}, "There is Not a Valid ColorRamp Node in '"+mat.name+"'")
except AttributeError:
pass
if spectrum_active.colorramp_name != "" and spectrum_active.assign_colorramp == True:
try:
for i in range(0, len(ramp.elements)):
if spectrum_active.assign_colorramp == True:
exec("ramp.elements["+str(i)+"].color[0] = kaleidoscope_spectrum_props.color"+str(i+1)+"[0]")
exec("ramp.elements["+str(i)+"].color[1] = kaleidoscope_spectrum_props.color"+str(i+1)+"[1]")
exec("ramp.elements["+str(i)+"].color[2] = kaleidoscope_spectrum_props.color"+str(i+1)+"[2]")
ramp.elements[0].color[3] = 1.0
except:
pass
class SpectrumNode(Node, SpectrumTreeNode):
"""The Spectrum Node with all the Attributes"""
bl_idname = 'spectrum_palette.node'
bl_label = 'Spectrum Palette'
bl_icon = 'NONE'
bl_width_min = 226.0
bl_width_max = 350.0
def init(self, context):
self.outputs.new('NodeSocketColor', "Color 1")
self.outputs.new('NodeSocketColor', "Color 2")
self.outputs.new('NodeSocketColor', "Color 3")
self.outputs.new('NodeSocketColor', "Color 4")
self.outputs.new('NodeSocketColor', "Color 5")
self.outputs["Color 1"].default_value = bpy.context.scene.kaleidoscope_spectrum_props.color1
self.outputs["Color 2"].default_value = bpy.context.scene.kaleidoscope_spectrum_props.color2
self.outputs["Color 3"].default_value = bpy.context.scene.kaleidoscope_spectrum_props.color3
self.outputs["Color 4"].default_value = bpy.context.scene.kaleidoscope_spectrum_props.color4
self.outputs["Color 5"].default_value = bpy.context.scene.kaleidoscope_spectrum_props.color5
self.width = 226
def update(self):
try:
for attr in ('materials', 'lights', 'worlds'):
for item in getattr(bpy.data, attr):
for node in item.node_tree.nodes:
if node.bl_idname == 'spectrum_palette.node':
for out in node.outputs:
if out.is_linked:
for o in out.links:
if o.is_valid:
if o.to_node.bl_idname == 'NodeReroute':
update_reroutes(attr, item.name, node.name, o.to_node.name, out.name)
o.to_socket.node.inputs[o.to_socket.name].default_value = out.default_value
except:
pass
# Additional buttons displayed on the node.
def draw_buttons(self, context, layout):
SpectrumPaletteUI(self, context, layout)
#Node Label
def draw_label(self):
return "Spectrum Palette"
def SpectrumPaletteUI(self, context, layout):
"""Spectrum Palette Interface, which can be accessed from any other class"""
kaleidoscope_spectrum_props = bpy.context.scene.kaleidoscope_spectrum_props
col = layout.column(align=True)
row = col.row(align=True)
split = row.split(factor=0.8)
col1 = split.column(align=True)
col1.prop(kaleidoscope_spectrum_props, "gen_type", text="Rule")
if kaleidoscope_spectrum_props.gen_type == "4":
col1.prop(kaleidoscope_spectrum_props, "custom_gen_type", text="Type")
if kaleidoscope_spectrum_props.custom_gen_type == "4":
col1.prop(kaleidoscope_spectrum_props, "online_type", text="Source")
col2 = split.column()
row2 = col2.row(align=True)
colr = row2.column(align=True)
if (kaleidoscope_spectrum_props.gen_type != '4' or kaleidoscope_spectrum_props.custom_gen_type == '3' or kaleidoscope_spectrum_props.custom_gen_type == '0' or kaleidoscope_spectrum_props.custom_gen_type == '2') and kaleidoscope_spectrum_props.use_internet_libs == False:
colr.enabled = True
else:
colr.enabled = False
if kaleidoscope_spectrum_props.use_organize == False:
colr.prop(kaleidoscope_spectrum_props, "use_organize", toggle=True, text="", icon='SNAP_OFF', emboss=False)
else:
colr.prop(kaleidoscope_spectrum_props, "use_organize", toggle=True, text="", icon='SNAP_ON', emboss=False)
colr = row2.column(align=True)
colr.prop(kaleidoscope_spectrum_props, "view_help", toggle=True, text="", icon='INFO', emboss=False)
if kaleidoscope_spectrum_props.view_help == True:
box = layout.box()
col_box = box.column(align=True)
if kaleidoscope_spectrum_props.gen_type == "0":
col_box.label(text="Monochromatic Scheme is the")
col_box.label(text="most basic color rule. It has")
col_box.label(text="colors of same hue, but with")
col_box.label(text="varying saturation and")
col_box.label(text="brightness. It is useful when")
col_box.label(text="used in a proper way.")
col_box.label()
elif kaleidoscope_spectrum_props.gen_type == "1":
col_box.label(text="Analogous Scheme uses")
col_box.label(text="colors of different hues. It")
col_box.label(text="uses one color as base color")
col_box.label(text="and uses colors near it in the")
col_box.label(text="color wheel, with varying")
col_box.label(text="saturation and brightness.")
col_box.label()
elif kaleidoscope_spectrum_props.gen_type == "2":
col_box.label(text="Complementary Scheme is")
col_box.label(text="interesting rule where colors")
col_box.label(text="opposite to each other in the")
col_box.label(text="color wheel are used. This")
col_box.label(text="scheme should be used")
col_box.label(text="carefully because of contrasting")
col_box.label(text="shades.")
col_box.label()
elif kaleidoscope_spectrum_props.gen_type == "3":
col_box.label(text="Triadic Scheme uses")
col_box.label(text="one color as base color")
col_box.label(text="and other two colors are")
col_box.label(text="chosen from the color wheel")
col_box.label(text="such that all three form an")
col_box.label(text="equilateral triangle.")
col_box.label()
elif kaleidoscope_spectrum_props.gen_type == "4":
col_box.label(text="Custom schemes are some")
col_box.label(text="simple rules exclusive to")
col_box.label(text="this add-on")
col_box.label()
if kaleidoscope_spectrum_props.custom_gen_type == "0":
col_box.label(text="Vibrant scheme uses two")
col_box.label(text="visually appealing color shades")
col_box.label(text="and others are shades of black")
col_box.label(text="and white")
col_box.label()
elif kaleidoscope_spectrum_props.custom_gen_type == "1":
col_box.label(text="Gradient scheme is similar")
col_box.label(text="to Monochromatic scheme, and")
col_box.label(text="it uses fixed hue with fixed")
col_box.label(text="change and goes light to dark")
col_box.label(text="from left to form gradient of")
col_box.label(text="colors.")
col_box.label()
elif kaleidoscope_spectrum_props.custom_gen_type == "2":
col_box.label(text="Pop Out scheme is similar to")
col_box.label(text="Vibrant scheme, but this uses")
col_box.label(text="two same colors and other three")
col_box.label(text="are shades of black and white.")
col_box.label(text="Really Minimal Color Scheme.")
col_box.label()
elif kaleidoscope_spectrum_props.custom_gen_type == "4":
if kaleidoscope_spectrum_props.online_type == "0":
col_box.label(text="Standard Online mode provides")
col_box.label(text="you with some amazing color")
col_box.label(text="palettes that I have personally")
col_box.label(text="added for you.")
col_box.label()
elif kaleidoscope_spectrum_props.online_type == "1":
col_box.label(text="COLOURlovers site has amazing")
col_box.label(text="color palettes added by users.")
col_box.label(text="This Source provides you with all")
col_box.label(text="those amazing palettes directly")
col_box.label(text="inside Blender.")
col_box.label()
elif kaleidoscope_spectrum_props.custom_gen_type == "3":
col_box.label(text="Random option allows you to")
col_box.label(text="generate a palette from any rule")
col_box.label(text="in a click. It is helpful when")
col_box.label(text="you need want to find the best")
col_box.label(text="palette of a base color.")
col_box.label()
elif kaleidoscope_spectrum_props.custom_gen_type == "5":
col_box.label(text="If you are really angry, and")
col_box.label(text="want to try any color for your")
col_box.label(text="scene, then use this option.")
col_box.label(text="This option 'Randomly' generates")
col_box.label(text="the colors for the palette.")
if kaleidoscope_spectrum_props.use_internet_libs == True:
col_box.label()
if kaleidoscope_spectrum_props.use_internet_libs == True:
if kaleidoscope_spectrum_props.custom_gen_type == '3':
if kaleidoscope_spectrum_props.random_online_int != 2:
col_box.label(text="Palette ID: "+str(kaleidoscope_spectrum_props.online_palette_index+1))
elif kaleidoscope_spectrum_props.random_online_int == 2:
col_box.label(text="Palette ID: "+str(lovers_id))
else:
if kaleidoscope_spectrum_props.online_type != "1":
col_box.label(text="Palette ID: "+str(kaleidoscope_spectrum_props.online_palette_index+1))
elif kaleidoscope_spectrum_props.online_type == "1":
col_box.label(text="Palette ID: "+str(lovers_id))
row = col_box.row(align=True)
row.scale_y = 1.1
row.operator("wm.url_open", text="Problem?", icon="HELP").url="http://blskl.cf/kalbugs"
if kaleidoscope_spectrum_props.gen_type != '4' and kaleidoscope_spectrum_props.custom_gen_type != '4':
col_box.label()
col_box.prop(kaleidoscope_spectrum_props, "view_help", text="Close Help", icon='INFO')
col = layout.column(align=True)
if kaleidoscope_spectrum_props.use_internet_libs == False:
col.enabled = True
else:
col.enabled = False
if kaleidoscope_spectrum_props.gen_type == "4" and kaleidoscope_spectrum_props.custom_gen_type == "4":
col.enabled = False
if kaleidoscope_spectrum_props.use_custom == False:
col.prop(kaleidoscope_spectrum_props, "use_custom", text="Use Custom Base Color", toggle=True, icon="LAYER_USED")
else:
col.prop(kaleidoscope_spectrum_props, "use_custom", text="Hide Custom Base Color", toggle=True, icon="LAYER_ACTIVE")
box = col.box()
col1 = box.column()
row = col1.row(align=True)
row.label(text="Base Color:")
row.prop(kaleidoscope_spectrum_props, "hue", text="")
row.prop(kaleidoscope_spectrum_props, "use_realtime_base", text="", icon='HIDE_OFF')
col2 = layout.column(align=True)
row = col2.row(align=True)
row.prop(kaleidoscope_spectrum_props, "color1", text="")
row.prop(kaleidoscope_spectrum_props, "color2", text="")
row.prop(kaleidoscope_spectrum_props, "color3", text="")
row.prop(kaleidoscope_spectrum_props, "color4", text="")
row.prop(kaleidoscope_spectrum_props, "color5", text="")
row2 = col2.row(align=True)
row2.scale_y = 1.2
row2.operator(PaletteGenerate.bl_idname, text="Refresh Palette", icon="COLOR")
col3 = layout.column(align=True)
if online_check == False:
col3.label(text="There was some problem,", icon='ERROR')
col3.label(text="try again")
if community_maintain == True:
col3.label(text="The Community Palettes,", icon='INFO')
col3.label(text="are not available now")
if kaleidoscope_spectrum_props.use_global == False:
col3.prop(kaleidoscope_spectrum_props, "use_global", text="View Global Controls", icon='LAYER_USED', toggle=True)
else:
col3.prop(kaleidoscope_spectrum_props, "use_global", text="Hide Global Controls", icon='LAYER_ACTIVE', toggle=True)
box = col3.box()
col4 = box.column(align=True)
row4 = col4.row(align=True)
col4.prop(kaleidoscope_spectrum_props, "hue_slider", text="Hue", slider=True)
col4.prop(kaleidoscope_spectrum_props, "saturation_slider", text="Saturation", slider=True)
col4.prop(kaleidoscope_spectrum_props, "value_slider", text="Value", slider=True)
col4 = layout.column(align=True)
col4.label()
row4 = col4.row(align=True)
if kaleidoscope_spectrum_props.history_count != 2:
row4.operator(PreviousPalette.bl_idname, text="", icon="TRIA_LEFT")
else:
row4.separator()
row4.separator()
row4.operator(PaletteInvert.bl_idname, text="Invert", icon="ARROW_LEFTRIGHT")
row4.operator(PaletteShuffle.bl_idname, text="Shuffle", icon="LOOP_BACK")
if kaleidoscope_spectrum_props.history_count != 0:
row4.operator(NextPalette.bl_idname, text="", icon="TRIA_RIGHT")
else:
row4.separator()
row4.separator()
col4.label()
row5 = col4.row(align=True)
if len(kaleidoscope_spectrum_props.saved_palettes) !=0:
row5.prop(kaleidoscope_spectrum_props, "saved_palettes", text="")
else:
row5.label(text="No Saved Palettes")
row5.operator(client.SavePaletteMenu.bl_idname, text="", icon='FILE_TICK')
if len(kaleidoscope_spectrum_props.saved_palettes) != 0:
row5.operator(client.DeletePaletteMenu.bl_idname, text="", icon='TRASH')
col4.label()
row6 = col4.row(align=True)
try:
if bpy.context.space_data.shader_type == 'WORLD':
row6.prop_search(kaleidoscope_spectrum_props,"colorramp_world_name", bpy.context.scene.world.node_tree, "nodes",text="Ramp", icon='NODETREE')
row6.prop(kaleidoscope_spectrum_props, "assign_colorramp_world", text="", icon='RESTRICT_COLOR_ON', toggle=True)
elif bpy.context.space_data.shader_type == 'OBJECT':
row6.prop_search(bpy.context.object.active_material.kaleidoscope_spectrum_props,"colorramp_name", bpy.context.object.active_material.node_tree, "nodes",text="Ramp", icon='NODETREE')
row6.prop(bpy.context.object.active_material.kaleidoscope_spectrum_props, "assign_colorramp", text="", icon='RESTRICT_COLOR_ON', toggle=True)
col4.label()
except:
pass
row7 = col4.row(align=True)
row7_1 = row7.row(align=True)
row7_1.alignment = 'CENTER'
row7_1.label(text="Akash Hamirwasia")
row7_1.scale_y = 1.2
row7_1.operator('wm.url_open', text="Support Me", icon='SOLO_ON').url='http://blskl.cf/kalsupport'
def update_caller(caller, input_name, value):
kaleidoscope_spectrum_props=bpy.context.scene.kaleidoscope_spectrum_props
for attr in ('materials', 'lights', 'worlds'):
for item in getattr(bpy.data, attr):
if item.node_tree is not None:
for node in item.node_tree.nodes:
if node.bl_idname == 'spectrum_palette.node':
node.outputs[input_name].default_value = value
if node.outputs[input_name].is_linked:
for o in node.outputs[input_name].links:
if o.is_valid:
if o.to_node.bl_idname == 'NodeReroute':
update_reroutes(attr, item.name, node.name, o.to_node.name, input_name)
o.to_socket.node.inputs[o.to_socket.name].default_value = value
for mat in bpy.data.materials:
if mat.kaleidoscope_spectrum_props.assign_colorramp == True or kaleidoscope_spectrum_props.assign_colorramp_world == True:
set_color_ramp(caller)
break
def update_reroutes(tree_type, material_name, kaleidoscope_node_name, reroute_name, input_name):
if tree_type == "materials":
node_tree_type = bpy.data.materials[material_name]
elif tree_type == "worlds":
node_tree_type = bpy.data.worlds[material_name]
elif tree_type == "lights":
node_tree_type = bpy.data.lights[material_name]
else:
return ("NodeTree Type not in [\"materials\", \"worlds\", \"lights\"]")
reroute = node_tree_type.node_tree.nodes[reroute_name]
node = node_tree_type.node_tree.nodes[kaleidoscope_node_name]
links = node_tree_type.node_tree.links
try:
if reroute.outputs['Output'].is_linked:
for ro in reroute.outputs['Output'].links:
if ro.is_valid:
next_node = node_tree_type.node_tree.nodes[ro.to_node.name]
links.new(node.outputs[input_name], next_node.inputs[ro.to_socket.name])
if next_node.bl_idname == "NodeReroute":
update_reroutes(tree_type, material_name, kaleidoscope_node_name, next_node.name, input_name)
except:
pass
def hex_to_rgb(value, alpha=True):
"""Convets a Hex code to a Blender RGB Value"""
gamma = 2.2
value = value.lstrip('#')
lv = len(value)
fin = list(int(value[i:i + lv // 3], 16) for i in range(0, lv, lv // 3))
r = pow(fin[0] / 255, gamma)
g = pow(fin[1] / 255, gamma)
b = pow(fin[2] / 255, gamma)
fin.clear()
fin.append(r)
fin.append(g)
fin.append(b)
if alpha == True:
fin.append(1.0)
return tuple(fin)
def rgb_to_hex(rgb):
"""Converts Blender RGB Value to Hex code"""
gamma = 1/2.2
fin = list(rgb)
r = fin[0]*255
g = fin[1]*255
b = fin[2]*255
r = int(255*pow(r / 255, gamma))
g = int(255*pow(g / 255, gamma))
b = int(255*pow(b / 255, gamma))
fin.clear()
fin.append(r)
fin.append(g)
fin.append(b)
fin = tuple(fin)
return '#%02x%02x%02x' % fin
def hex_to_real_rgb(value):
"""Return (red, green, blue) for the color given as #rrggbb."""
value = value.lstrip('#')
lv = len(value)
return list(int(value[i:i + lv // 3], 16) for i in range(0, lv, lv // 3))
def real_rgb_to_hex(value):
"""Return color as #rrggbb for the given color values."""
return '#%02x%02x%02x' % value
def Spectrum_Engine():
"""Generates the Color Palettes. Use the PaletteGenerate Class for Palettes, as this requires some custom properties"""
kaleidoscope_spectrum_props = bpy.context.scene.kaleidoscope_spectrum_props
kaleidoscope_spectrum_props.hue_slider = 0.0
kaleidoscope_spectrum_props.saturation_slider = 0.0
kaleidoscope_spectrum_props.value_slider = 0.0
c = Color()
c.hsv = 1.0, 0.0, 1.0
index = [0, 1, 2, 3, 4]
random.shuffle(index)
color_palette = ["", "", "", "", ""]
c.hsv = random.random(), random.random(), random.random()
if random.randint(0, 3) /2 == 0:
c.h = 0.0
if c.v >= 0.95:
c.v = c.v-0.1
elif c.v <= 0.4:
c.v = c.v+0.2
if kaleidoscope_spectrum_props.use_custom == True:
if kaleidoscope_spectrum_props.hue != (0.0, 0.0, 0.0, 1.0):
c.r = random.uniform(kaleidoscope_spectrum_props.hue[0]-0.1, kaleidoscope_spectrum_props.hue[0]+0.05)
c.g = random.uniform(kaleidoscope_spectrum_props.hue[1]-0.1, kaleidoscope_spectrum_props.hue[1]+0.05)
c.b = random.uniform(kaleidoscope_spectrum_props.hue[2]-0.1, kaleidoscope_spectrum_props.hue[2]+0.05)
#Monochromatic
if kaleidoscope_spectrum_props.gen_type == "0" or kaleidoscope_spectrum_props.random_int == 0:
Hue = c.h
Saturation_less= 0.0
if c.s <=0.1:
Saturation_less = 0.0
else:
Saturation_less = random.uniform(0.1, c.s)
if Saturation_less == c.s:
Saturation_less = random.uniform(0.1, c.s)
if Saturation_less < 0.25:
Saturation_less = 0.4
Saturation_more = random.uniform(c.s+0.1, c.s+0.2)
Value_less = random.uniform(0.2, c.v)
Value_more = random.uniform(c.v+0.1, c.v+0.3)
if Value_less == 0.0:
Value_less = 0.3
elif Value_more == 0.0:
Value_more = 0.7
c1 = Color()
c1.hsv = Hue, Saturation_more, Value_more
if kaleidoscope_spectrum_props.use_organize == False:
color_palette[index[0]] = rgb_to_hex((c1.r, c1.g, c1.b))
else:
color_palette[0] = rgb_to_hex((c1.r, c1.g, c1.b))
c1.hsv = Hue, Saturation_more+0.1, Value_more
if kaleidoscope_spectrum_props.use_organize == False:
color_palette[index[1]] = rgb_to_hex((c1.r, c1.g, c1.b))
else:
color_palette[1] = rgb_to_hex((c1.r, c1.g, c1.b))
c1.hsv = Hue, c.s, c.v
if kaleidoscope_spectrum_props.use_organize == False:
color_palette[index[2]] = rgb_to_hex((c1.r, c1.g, c1.b))
else:
color_palette[2] = rgb_to_hex((c1.r, c1.g, c1.b))
c1.hsv = Hue, Saturation_more+0.1, Value_less-0.1
if kaleidoscope_spectrum_props.use_organize == False:
color_palette[index[3]] = rgb_to_hex((c1.r, c1.g, c1.b))
else:
color_palette[3] = rgb_to_hex((c1.r, c1.g, c1.b))
c1.hsv = Hue, Saturation_less, Value_less-0.1
if kaleidoscope_spectrum_props.use_organize == False:
color_palette[index[4]] = rgb_to_hex((c1.r, c1.g, c1.b))
else:
color_palette[4] = rgb_to_hex((c1.r, c1.g, c1.b))
kaleidoscope_spectrum_props.use_internet_libs = False
elif kaleidoscope_spectrum_props.gen_type == "1" or kaleidoscope_spectrum_props.random_int == 1:
#Analogous
Saturation = random.uniform(c.s, 1)
if Saturation <= 0.4:
Saturation = Saturation+0.35
Value = c.v
if (Value <= 1.0 or Value>1.0) and Value >= 0.8:
Value = Value-0.1
if Value <=0.3:
Value = 0.7
Value1 = random.uniform(Value+0.1, Value+0.25)
if (Value1 <= 1.0 or Value1>1.0) and Value1 >= 0.8:
Value1 = Value1-0.3
if Value1 <=0.3:
Value1 = 0.7
Hue1 = random.uniform(c.h+0.2, c.h+0.3)
Hue = random.uniform(c.h, c.h+0.2)
if Hue1 == Hue:
Hue1 = Hue1-0.1
if Hue == 0:
Hue1 = 0.1
c2 = Color()
c2.hsv = Hue1, Saturation-0.2, Value
if kaleidoscope_spectrum_props.use_organize == False:
color_palette[index[0]] = rgb_to_hex((c2.r, c2.g, c2.b))
else:
color_palette[2] = rgb_to_hex((c2.r, c2.g, c2.b))
Hue1_2 = random.uniform(c.h-0.07, c.h-0.2)
if Hue1_2 == Hue1:
Hue1_2 = Hue1_2-0.1
c2.hsv = Hue, Saturation+0.2, Value1
if kaleidoscope_spectrum_props.use_organize == False:
color_palette[index[1]] = rgb_to_hex((c2.r, c2.g, c2.b))
color_palette[index[2]] = rgb_to_hex((c2.r, c2.g, c2.b))
else:
color_palette[1] = rgb_to_hex((c2.r, c2.g, c2.b))
color_palette[0] = rgb_to_hex((c2.r, c2.g, c2.b))
Hue_1 = random.uniform(c.h, c.h-0.3)
if Hue_1==0:
Hue_1 = 0.9
if Hue_1 == Hue:
Hue_1 = Hue_1-0.08
if c.h == 0.0:
Hue_1 = 1-abs(Hue_1)
Hue1_2 = 1-abs(Hue1_2)
c2.hsv = Hue1_2, Saturation, Value1
if kaleidoscope_spectrum_props.use_organize == False:
color_palette[index[3]] = rgb_to_hex((c2.r, c2.g, c2.b))
else:
color_palette[3] = rgb_to_hex((c2.r, c2.g, c2.b))
c2.hsv = Hue_1, Saturation, Value
if kaleidoscope_spectrum_props.use_organize == False:
color_palette[index[4]] = rgb_to_hex((c2.r, c2.g, c2.b))
else:
color_palette[4] = rgb_to_hex((c2.r, c2.g, c2.b))
kaleidoscope_spectrum_props.use_internet_libs = False
elif kaleidoscope_spectrum_props.gen_type == "2" or kaleidoscope_spectrum_props.random_int == 2:
#Complementary
Hue = c.h
Hue1 = 0.0
if Hue>=0.5:
Hue1=Hue-0.5
else:
Hue1=Hue+0.5
Saturation = c.s
if Saturation <=1.0 and Saturation >=0.95:
Saturation = Saturation-0.1
if Saturation <=0.3:
Saturation = Saturation+0.25
Saturation_more = random.uniform(Saturation+0.05, Saturation+0.2)
Saturation_less = random.uniform(Saturation-0.2, Saturation-0.05)
if Saturation_more <=1.0 and Saturation_more >=0.95:
Saturation_more = Saturation_more-0.1
if Saturation_more <=0.6:
Saturation_more = Saturation_more+0.45
if Saturation_less <=1.0 and Saturation_less >=0.95:
Saturation_less = Saturation_less-0.15
Value = c.v
Value_more = random.uniform(Value+0.05, Value+0.2)
Value_less = random.uniform(Value-0.2, Value-0.05)
if Value_more >=0.0 and Value_more <0.1:
Value_more = Value_more+0.35
if Value_less >=0.0 and Value_less <0.1:
Value_less = Value_less+0.3
c2 = Color()
c2.hsv = Hue, Saturation_more, Value_less
if kaleidoscope_spectrum_props.use_organize == False:
color_palette[index[0]] = rgb_to_hex((c2.r, c2.g, c2.b))
else:
color_palette[0] = rgb_to_hex((c2.r, c2.g, c2.b))
c2.hsv = Hue, Saturation_less, Value_more
if kaleidoscope_spectrum_props.use_organize == False:
color_palette[index[1]] = rgb_to_hex((c2.r, c2.g, c2.b))
else:
color_palette[1] = rgb_to_hex((c2.r, c2.g, c2.b))
c2.hsv = Hue, Saturation, Value
if kaleidoscope_spectrum_props.use_organize == False:
color_palette[index[2]] = rgb_to_hex((c2.r, c2.g, c2.b))
else:
color_palette[2] = rgb_to_hex((c2.r, c2.g, c2.b))
c2.hsv = Hue1, Saturation_more, Value_less
if kaleidoscope_spectrum_props.use_organize == False:
color_palette[index[3]] = rgb_to_hex((c2.r, c2.g, c2.b))
else:
color_palette[3] = rgb_to_hex((c2.r, c2.g, c2.b))
c2.hsv = Hue1, Saturation, Value
if kaleidoscope_spectrum_props.use_organize == False:
color_palette[index[4]] = rgb_to_hex((c2.r, c2.g, c2.b))
else:
color_palette[4] = rgb_to_hex((c2.r, c2.g, c2.b))
kaleidoscope_spectrum_props.use_internet_libs = False
elif kaleidoscope_spectrum_props.gen_type == "3" or kaleidoscope_spectrum_props.random_int == 3:
#Triad
Hue = c.h
Hue2 = Hue+0.34
Hue3 = Hue+0.34+0.34
if Hue >0.34:
if Hue > 0.66:
Hue2 = Hue-0.34
Hue3 = Hue-0.34-0.34
Hue2 = Hue+0.34
Hue3 = Hue-0.34
Saturation = c.s
if Saturation <=0.1:
Saturation = 0.6
elif Saturation <=0.6:
Saturation = Saturation+0.45
if Saturation >= 0.95:
Saturation = Saturation-0.2
Saturation_more = random.uniform(Saturation+0.07, Saturation+0.2)
Saturation_less = random.uniform(Saturation-0.2, Saturation-0.07)
Saturation_lesser = random.uniform(Saturation-0.1, Saturation-0.08)
if Saturation_more <=1.0 and Saturation_more >=0.95:
Saturation_more = Saturation_more-0.1
if Saturation_more <=0.6:
Saturation_more = Saturation_more+0.45
if Saturation_lesser>=1.0 and Saturation_lesser >=0.85:
Saturation_lesser = 0.7
if Saturation_lesser <=0.6:
Saturation_lesser = Saturation_lesser+0.35
Value = c.v
Value_less = 0
if Value<=0.4:
Value = 0.6
Value_less = random.uniform(Value-0.2, Value-0.07)
c2 = Color()
c2.hsv = Hue, Saturation_more, Value_less
if kaleidoscope_spectrum_props.use_organize == False:
color_palette[index[0]] = rgb_to_hex((c2.r, c2.g, c2.b))
else:
color_palette[0] = rgb_to_hex((c2.r, c2.g, c2.b))
c2.hsv = Hue, Saturation, Value
if kaleidoscope_spectrum_props.use_organize == False:
color_palette[index[1]] = rgb_to_hex((c2.r, c2.g, c2.b))
else:
color_palette[1] = rgb_to_hex((c2.r, c2.g, c2.b))
c2.hsv = Hue3, Saturation_lesser, Value
if kaleidoscope_spectrum_props.use_organize == False:
color_palette[index[2]] = rgb_to_hex((c2.r, c2.g, c2.b))
else:
color_palette[2] = rgb_to_hex((c2.r, c2.g, c2.b))
c2.hsv = Hue2, Saturation_less-0.07, Value_less+0.1
if kaleidoscope_spectrum_props.use_organize == False:
color_palette[index[3]] = rgb_to_hex((c2.r, c2.g, c2.b))
else:
color_palette[3] = rgb_to_hex((c2.r, c2.g, c2.b))
c2.hsv = Hue2, Saturation_less+0.07, Value_less-0.2
if kaleidoscope_spectrum_props.use_organize == False:
color_palette[index[4]] = rgb_to_hex((c2.r, c2.g, c2.b))
else:
color_palette[4] = rgb_to_hex((c2.r, c2.g, c2.b))
kaleidoscope_spectrum_props.use_internet_libs = False
elif kaleidoscope_spectrum_props.gen_type == "4" or kaleidoscope_spectrum_props.random_int == 4:
global online_check
if kaleidoscope_spectrum_props.custom_gen_type == "0" or kaleidoscope_spectrum_props.random_custom_int == 0:
#Vibrant
Hue = c.h
while True:
if Hue <=0.1 and Hue>=0.0:
Hue = random.random()
if kaleidoscope_spectrum_props.use_custom == True:
if kaleidoscope_spectrum_props.hue != (0.0, 0.0, 0.0, 1.0):
c_rgb = Color()
c_rgb.r = kaleidoscope_spectrum_props.hue[0]
c_rgb.g = kaleidoscope_spectrum_props.hue[1]
c_rgb.b = kaleidoscope_spectrum_props.hue[2]
Hue = random.uniform(c_rgb.h-0.1, c_rgb.h+0.1)
else:
break
Hue1 = 0.0
if Hue > 0.7:
Hue1 = Hue-random.random()
else:
Hue1 = Hue+random.random()
Saturation = c.s
if Saturation <= 0.7:
Saturation = 0.8
Value1 = c.v
if Value1<0.5:
Value1 = Value1+0.3
Value = random.uniform(Value1-0.3, Value1-0.23)
c2 = Color()
c2.hsv = 0.0, 0.0, random.uniform(0.3, 0.7)
if kaleidoscope_spectrum_props.use_organize == False:
color_palette[index[0]] = rgb_to_hex((c2.r, c2.g, c2.b))
else:
color_palette[3] = rgb_to_hex((c2.r, c2.g, c2.b))
c2.hsv = 0.0, 0.0, random.uniform(0, 0.5)
if kaleidoscope_spectrum_props.use_organize == False:
color_palette[index[1]] = rgb_to_hex((c2.r, c2.g, c2.b))
else:
color_palette[4] = rgb_to_hex((c2.r, c2.g, c2.b))
c2.hsv = 0.0, 0.0, random.uniform(0.7, 1)
if kaleidoscope_spectrum_props.use_organize == False:
color_palette[index[2]] = rgb_to_hex((c2.r, c2.g, c2.b))
else:
color_palette[2] = rgb_to_hex((c2.r, c2.g, c2.b))
c2.hsv = Hue, Saturation, Value1
if kaleidoscope_spectrum_props.use_organize == False:
color_palette[index[3]] = rgb_to_hex((c2.r, c2.g, c2.b))
else:
color_palette[1] = rgb_to_hex((c2.r, c2.g, c2.b))
c2.hsv = Hue1, Saturation, Value
if kaleidoscope_spectrum_props.use_organize == False:
color_palette[index[4]] = rgb_to_hex((c2.r, c2.g, c2.b))
else:
color_palette[0] = rgb_to_hex((c2.r, c2.g, c2.b))
kaleidoscope_spectrum_props.use_internet_libs = False
elif kaleidoscope_spectrum_props.custom_gen_type=="1" or kaleidoscope_spectrum_props.random_custom_int == 1:
#Gradient
Hue = c.h
Value = c.v
Saturation = c.s+0.1
c1 = Color()
c1.hsv = Hue, 0.2, 0.9
color_palette[0] = rgb_to_hex((c1.r, c1.g, c1.b))
c1.hsv = Hue, 0.3, 0.9-0.1
color_palette[1] = rgb_to_hex((c1.r, c1.g, c1.b))
c1.hsv = Hue, Saturation, Value
color_palette[2] = rgb_to_hex((c1.r, c1.g, c1.b))
c1.hsv = Hue, 0.9-0.1, 0.1+0.1
color_palette[3] = rgb_to_hex((c1.r, c1.g, c1.b))
c1.hsv = Hue, 0.9, 0.1
color_palette[4] = rgb_to_hex((c1.r, c1.g, c1.b))
kaleidoscope_spectrum_props.use_internet_libs = False
elif kaleidoscope_spectrum_props.custom_gen_type == "2" or kaleidoscope_spectrum_props.random_custom_int == 2:
#Popout
Hue = c.h
Saturation = c.s
if Saturation<0.9:
Saturation = 0.95
Value = c.v
c2 = Color()
c2.hsv = 0.0, 0.0, random.uniform(0.3, 0.7)
if kaleidoscope_spectrum_props.use_organize == False:
color_palette[index[0]] = rgb_to_hex((c2.r, c2.g, c2.b))
else:
color_palette[3] = rgb_to_hex((c2.r, c2.g, c2.b))
c2.hsv = Hue, Saturation, Value
if kaleidoscope_spectrum_props.use_organize == False:
color_palette[index[1]] = rgb_to_hex((c2.r, c2.g, c2.b))
else:
color_palette[0] = rgb_to_hex((c2.r, c2.g, c2.b))
c2.hsv = 0.0, 0.0, random.uniform(0, 0.2)
if kaleidoscope_spectrum_props.use_organize == False:
color_palette[index[2]] = rgb_to_hex((c2.r, c2.g, c2.b))
else:
color_palette[4] = rgb_to_hex((c2.r, c2.g, c2.b))
c2.hsv = Hue, Saturation-0.1, Value
if kaleidoscope_spectrum_props.use_organize == False:
color_palette[index[3]] = rgb_to_hex((c2.r, c2.g, c2.b))
else:
color_palette[1] = rgb_to_hex((c2.r, c2.g, c2.b))
c2.hsv = 0.0, 0.0, random.uniform(0.7, 1)
if kaleidoscope_spectrum_props.use_organize == False:
color_palette[index[4]] = rgb_to_hex((c2.r, c2.g, c2.b))
else:
color_palette[2] = rgb_to_hex((c2.r, c2.g, c2.b))
kaleidoscope_spectrum_props.use_internet_libs = False
elif kaleidoscope_spectrum_props.custom_gen_type == "4" or kaleidoscope_spectrum_props.random_custom_int == 3:
global palette