summaryrefslogtreecommitdiff
path: root/generate_graph.py
diff options
context:
space:
mode:
Diffstat (limited to 'generate_graph.py')
-rw-r--r--generate_graph.py43
1 files changed, 19 insertions, 24 deletions
diff --git a/generate_graph.py b/generate_graph.py
index 7fb44f9..d47e345 100644
--- a/generate_graph.py
+++ b/generate_graph.py
@@ -11,28 +11,19 @@ subnode_threshold = float(sys.argv[10])
nodes = {}
-nodes['n0'] = {'width': base_size, 'height': base_size, 'color': 'white', 'mass': base_size, 'fixed': True, 'x': 0, 'y': 0}
+nodes['n0'] = {'width': base_size, 'height': base_size, 'color': 'rgba(255,255,255,0.01)', 'mass': base_size, 'fixed': True, 'x': 0, 'y': 0, 'image': 'photo' + str(random.randint(1, 5)) + '.jpg'}
node_count = 1
node_sizes = []
for i in counts:
node_sizes = node_sizes + [sizes.pop(0)] * int(i)
-node_images = {
- 1.0: 'blue.png',
- 0.9: 'blue.png',
- 0.8: 'blue.png',
- 0.7: 'blue.png',
- 0.3: 'red.png',
- 0.2: 'yellow.png',
- 0.1: 'black.png'
-}
node_colors = {
- 1.0: '#3495FF',
- 0.9: '#3495FF',
- 0.8: '#3495FF',
- 0.7: '#3495FF',
- 0.3: 'red',
+ 1.0: 'rgba(52,149,255,0.33)',
+ 0.9: 'rgba(52,149,255,0.33)',
+ 0.8: 'rgba(52,149,255,0.33)',
+ 0.7: 'rgba(52,149,255,0.33)',
+ 0.3: 'rgba(255,0,0,0.33)',
0.2: 'yellow',
0.1: 'white'
}
@@ -47,9 +38,11 @@ for node_size in node_sizes:
node_dimension = max(10, int(ceil(base_size * node_size * size_quotient)))
node_mass = int(ceil(base_size * mass_quotient))
node_angular_position = angular_positions[node_count-1]
- node_position = { 'x': 0.05 * cos(node_angular_position),
- 'y': 0.05 * sin(node_angular_position) }
+ node_position = { 'x': 0.8 * cos(node_angular_position),
+ 'y': 0.8 * sin(node_angular_position) }
nodes[node_id] = {'width': node_dimension, 'height': node_dimension, 'mass': node_mass, 'color': node_colors[node_size], 'fixed': True, 'x': node_position['x'], 'y': node_position['y']}
+ if node_size > 0.2:
+ nodes[node_id]['image'] = 'photo' + str(random.randint(1, 5)) + '.jpg'
edges['n0'][node_id] = {}
edges[node_id] = {}
node_count += 1
@@ -59,18 +52,20 @@ for node_size in node_sizes:
subnode_id = node_id + '_' + str(subnode_count)
subnode_dimension = max(5, int(ceil(base_size * node_size * subnode_size * size_quotient * size_quotient)))
subnode_mass = int(ceil(base_size * mass_quotient))
- nodes[subnode_id] = {'width': subnode_dimension, 'height': subnode_dimension, 'mass': subnode_mass, 'color': node_colors[subnode_size], 'fixed': True, 'x': node_position['x'], 'y': node_position['y']}
+ nodes[subnode_id] = {'width': subnode_dimension, 'height': subnode_dimension, 'mass': subnode_mass, 'color': node_colors[subnode_size], 'fixed': True, 'x': node_position['x'] * (0.995 + random.random() / 100), 'y': node_position['y'] * (0.995 + random.random() / 100)}
+ if subnode_size > 0.2:
+ nodes[subnode_id]['image'] = 'photo' + str(random.randint(1, 5)) + '.jpg'
edges[node_id][subnode_id] = {}
subnode_count += 1
print json.dumps(
{
- 'repulsion': 1000,
- 'stiffness': 100,
- 'friction': 100,
- 'precision': 0.99,
- 'fps': 40,
- 'dt': 0.05,
+ 'repulsion': 2200,
+ 'stiffness': 900,
+ 'friction': 0,
+ 'precision': 0.1,
+ 'fps': 15,
+ 'dt': 0.005,
'gravity': True,
'nodes': nodes,
'edges': edges