This repository has been archived by the owner on Oct 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
preferences.py
117 lines (93 loc) · 2.91 KB
/
preferences.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
import bpy
from bpy.types import AddonPreferences
from bpy.props import BoolProperty, FloatProperty, FloatVectorProperty, IntProperty
class CrowdManager_Preferences(AddonPreferences):
bl_idname = __package__
use_node_colors: BoolProperty(
name="Use Node Colors",
default=False
)
node_saturation: FloatProperty(
name="Node Saturation",
default=0.7,
min=0, max=1
)
object_node_color: FloatVectorProperty(
name="Object Node Color",
subtype="COLOR",
default=(1, 0.7, 0.2),
min=0, max=1
)
collection_node_color: FloatVectorProperty(
name="Collection Node Color",
subtype="COLOR",
default=(1, 0.5, 0.3),
min=0, max=1
)
point_node_color: FloatVectorProperty(
name="Point Node Color",
subtype="COLOR",
default=(0.6, 0.7, 0.9),
min=0, max=1
)
behavior_node_color: FloatVectorProperty(
name="Behavior Node Color",
subtype="COLOR",
default=(0.3, 0.7, 0.3),
min=0, max=1
)
agent_node_color: FloatVectorProperty(
name="Agent Node Color",
subtype="COLOR",
default=(0.6, 0.3, 0.7),
min=0, max=1
)
crowd_node_color: FloatVectorProperty(
name="Crowd Node Color",
subtype="COLOR",
default=(0.1, 0.3, 0.7),
min=0, max=1
)
point_size: IntProperty(
name="Point Size",
default=10,
min = 0,
)
def draw(self, context):
layout = self.layout
col = layout.column()
subcol = col.split()
subcolcol = subcol.column()
subcolcol.prop(self, "use_node_colors")
subcolcolrow = subcolcol.row()
subcolcolrow.enabled = self.use_node_colors
subcolcolrow.prop(self, "node_saturation")
subcol.prop(self, "object_node_color")
subcol.prop(self, "collection_node_color")
subcol.prop(self, "point_node_color")
subcol.prop(self, "behavior_node_color")
subcol.prop(self, "agent_node_color")
subcol.prop(self, "crowd_node_color")
col.prop(self, "point_size")
col = layout.column()
col.operator("wm.url_open", text="Report Bug",
icon='URL').url = "https://github.com/Christopher-Hosken/crowdManager/issues"
classes = [CrowdManager_Preferences]
def getUserPreferences(context=None):
if not context:
context = bpy.context
if hasattr(context, "user_preferences"):
prefs = context.user_preferences.addons.get(__package__, None)
elif hasattr(context, "preferences"):
prefs = context.preferences.addons.get(__package__, None)
if prefs:
return prefs.preferences
return None
def desaturate(c, f=0.5):
f = (1-f)
L = 0.3*c[0] + 0.6*c[1] + 0.1*c[2]
return (
c[0] + f * (L - c[0]),
c[1] + f * (L - c[1]),
c[2] + f * (L - c[2]),
)