Skip to content

Commit d5d058a

Browse files
committed
Bug fixes
- Fixed text rendering to use relative coordinates instead of pixels - Cleaned up example scripts - Fixed a bug preventing neuron mesh being set - Refactored -lh/-rh functionality to work properly - Fixed a bug preventing clearing areas after they were loaded
1 parent 40baa5a commit d5d058a

File tree

16 files changed

+485
-408
lines changed

16 files changed

+485
-408
lines changed

API/unityneuro/render.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -765,13 +765,14 @@ def set_text_sizes(text_sizes):
765765

766766
def set_text_positions(text_pos):
767767
"""Set the positions of a set of text objects in UI canvas space
768+
Bottom left corner is [-1,-1], top right [1,1]
768769
769-
Note that by default the UI canvas is 800 x 600
770+
Text is anchored at the top left corner of its text box.
770771
771772
Parameters
772773
----------
773774
text_pos : dict {string : list of two floats}
774-
dictionary of IDs and canvas positions for the top left corner
775+
dictionary of IDs and canvas positions relative to the center
775776
776777
Examples
777778
--------

Examples/basics/.ipynb_checkpoints/Text-checkpoint.ipynb

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 1,
5+
"execution_count": null,
66
"id": "ffccfa79-9e51-4159-a8e3-4d38e0d69cd2",
77
"metadata": {},
88
"outputs": [],
@@ -12,71 +12,70 @@
1212
},
1313
{
1414
"cell_type": "code",
15-
"execution_count": 2,
15+
"execution_count": null,
1616
"id": "76973a23-f3a2-4932-85d7-c9a1554ec240",
1717
"metadata": {},
18-
"outputs": [
19-
{
20-
"name": "stdout",
21-
"output_type": "stream",
22-
"text": [
23-
"(URN) connected to server\n",
24-
"Login sent with ID: Dan\n"
25-
]
26-
}
27-
],
18+
"outputs": [],
2819
"source": [
2920
"urn.setup()"
3021
]
3122
},
3223
{
3324
"cell_type": "code",
34-
"execution_count": 8,
25+
"execution_count": null,
3526
"id": "f2545933-e1d8-47bb-aa5e-6285324e02ca",
3627
"metadata": {},
3728
"outputs": [],
3829
"source": [
39-
"urn.create_text(['t1','t2'])"
30+
"urn.create_text(['tl','bl','tr','br','center'])"
4031
]
4132
},
4233
{
4334
"cell_type": "code",
44-
"execution_count": 9,
45-
"id": "a8eb5485-35e9-4df5-a3bd-633e466d2f46",
35+
"execution_count": null,
36+
"id": "7beb8367-c70c-456f-9c82-fd66ce6687c5",
4637
"metadata": {},
4738
"outputs": [],
4839
"source": [
49-
"urn.set_text_positions({'t1':[500,-200]})"
40+
"urn.set_text({'tl':'top left',\n",
41+
" 'bl':'bottom left',\n",
42+
" 'tr':'top right',\n",
43+
" 'br':'bottom right',\n",
44+
" 'center':'center'})"
5045
]
5146
},
5247
{
5348
"cell_type": "code",
54-
"execution_count": 10,
55-
"id": "2a982a1c-52a7-49d2-aa49-de468dd27356",
49+
"execution_count": null,
50+
"id": "a8eb5485-35e9-4df5-a3bd-633e466d2f46",
5651
"metadata": {},
5752
"outputs": [],
5853
"source": [
59-
"urn.set_text({'t1':'hello world','t2':'urchin is great'})"
54+
"urn.set_text_positions({'tl':[-1,1],\n",
55+
" 'bl':[-1,-0.9],\n",
56+
" 'tr':[0.85,1],\n",
57+
" 'br':[0.85,-0.9],\n",
58+
" 'center':[0,0]})"
6059
]
6160
},
6261
{
6362
"cell_type": "code",
64-
"execution_count": 11,
63+
"execution_count": null,
6564
"id": "9ac44a3f-fccd-4205-aa93-24259f521dfc",
6665
"metadata": {},
6766
"outputs": [],
6867
"source": [
69-
"urn.set_text_colors({'t1':\"#FF0000\"})"
68+
"urn.set_text_colors({'tl':\"#FF0000\"})"
7069
]
7170
},
7271
{
7372
"cell_type": "code",
74-
"execution_count": 12,
73+
"execution_count": null,
7574
"id": "2e31c5aa-ee7e-47d9-bfd7-3c69e55c86da",
7675
"metadata": {},
7776
"outputs": [],
7877
"source": [
79-
"urn.set_text_sizes({'t1':100})"
78+
"urn.set_text_sizes({'tl':100})"
8079
]
8180
},
8281
{

Examples/basics/Create_and_Delete.ipynb

Lines changed: 0 additions & 116 deletions
This file was deleted.

Examples/basics/Text.ipynb

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 1,
5+
"execution_count": null,
66
"id": "ffccfa79-9e51-4159-a8e3-4d38e0d69cd2",
77
"metadata": {},
88
"outputs": [],
@@ -12,71 +12,70 @@
1212
},
1313
{
1414
"cell_type": "code",
15-
"execution_count": 2,
15+
"execution_count": null,
1616
"id": "76973a23-f3a2-4932-85d7-c9a1554ec240",
1717
"metadata": {},
18-
"outputs": [
19-
{
20-
"name": "stdout",
21-
"output_type": "stream",
22-
"text": [
23-
"(URN) connected to server\n",
24-
"Login sent with ID: Dan\n"
25-
]
26-
}
27-
],
18+
"outputs": [],
2819
"source": [
2920
"urn.setup()"
3021
]
3122
},
3223
{
3324
"cell_type": "code",
34-
"execution_count": 8,
25+
"execution_count": null,
3526
"id": "f2545933-e1d8-47bb-aa5e-6285324e02ca",
3627
"metadata": {},
3728
"outputs": [],
3829
"source": [
39-
"urn.create_text(['t1','t2'])"
30+
"urn.create_text(['tl','bl','tr','br','center'])"
4031
]
4132
},
4233
{
4334
"cell_type": "code",
44-
"execution_count": 9,
45-
"id": "a8eb5485-35e9-4df5-a3bd-633e466d2f46",
35+
"execution_count": null,
36+
"id": "7beb8367-c70c-456f-9c82-fd66ce6687c5",
4637
"metadata": {},
4738
"outputs": [],
4839
"source": [
49-
"urn.set_text_positions({'t1':[500,-200]})"
40+
"urn.set_text({'tl':'top left',\n",
41+
" 'bl':'bottom left',\n",
42+
" 'tr':'top right',\n",
43+
" 'br':'bottom right',\n",
44+
" 'center':'center'})"
5045
]
5146
},
5247
{
5348
"cell_type": "code",
54-
"execution_count": 10,
55-
"id": "2a982a1c-52a7-49d2-aa49-de468dd27356",
49+
"execution_count": null,
50+
"id": "a8eb5485-35e9-4df5-a3bd-633e466d2f46",
5651
"metadata": {},
5752
"outputs": [],
5853
"source": [
59-
"urn.set_text({'t1':'hello world','t2':'urchin is great'})"
54+
"urn.set_text_positions({'tl':[-1,1],\n",
55+
" 'bl':[-1,-0.9],\n",
56+
" 'tr':[0.85,1],\n",
57+
" 'br':[0.85,-0.9],\n",
58+
" 'center':[0,0]})"
6059
]
6160
},
6261
{
6362
"cell_type": "code",
64-
"execution_count": 11,
63+
"execution_count": null,
6564
"id": "9ac44a3f-fccd-4205-aa93-24259f521dfc",
6665
"metadata": {},
6766
"outputs": [],
6867
"source": [
69-
"urn.set_text_colors({'t1':\"#FF0000\"})"
68+
"urn.set_text_colors({'tl':\"#FF0000\"})"
7069
]
7170
},
7271
{
7372
"cell_type": "code",
74-
"execution_count": 12,
73+
"execution_count": null,
7574
"id": "2e31c5aa-ee7e-47d9-bfd7-3c69e55c86da",
7675
"metadata": {},
7776
"outputs": [],
7877
"source": [
79-
"urn.set_text_sizes({'t1':100})"
78+
"urn.set_text_sizes({'tl':100})"
8079
]
8180
},
8281
{

0 commit comments

Comments
 (0)