Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
purr-data
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Aayush
purr-data
Commits
bf1c4cc3
Commit
bf1c4cc3
authored
Sep 01, 2019
by
Aayush
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
final UI working fine for pd->diagram to ascii_art
parent
0cdd32db
Pipeline
#1667
canceled with stage
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
69 additions
and
84 deletions
+69
-84
pd/nw/pd_canvas.js
pd/nw/pd_canvas.js
+7
-0
pd/nw/pd_message_parser.js
pd/nw/pd_message_parser.js
+59
-83
pd/nw/pdgui.js
pd/nw/pdgui.js
+1
-1
pd/src/g_editor.c
pd/src/g_editor.c
+2
-0
No files found.
pd/nw/pd_canvas.js
View file @
bf1c4cc3
...
...
@@ -4,6 +4,7 @@ var gui = require("nw.gui");
var
pdgui
=
require
(
"
./pdgui.js
"
);
var
pd_menus
=
require
(
"
./pd_menus.js
"
);
var
pd_ascii_art
=
require
(
"
./pd_ascii_art.js
"
);
var
pd_message_parser
=
require
(
"
./pd_message_parser.js
"
);
// Apply gui preset to this canvas
pdgui
.
skin
.
apply
(
window
);
...
...
@@ -800,6 +801,12 @@ var canvas_events = (function() {
document
.
getElementById
(
"
ascii_art_text_area
"
).
addEventListener
(
"
input
"
,
events
.
check_ascii_art_state
);
state
=
"
ascii_art
"
;
},
create_ascii_art
:
function
(
pd_message
)
{
canvas_events
.
none
();
var
selected_ascii_art
=
pd_message_parser
.
parse_pd_message
(
pd_message
);
document
.
getElementById
(
"
ascii_art_text_area
"
).
value
=
selected_ascii_art
;
canvas_events
[
canvas_events
.
get_previous_state
()]();
},
register
:
function
(
n
)
{
name
=
n
;
},
...
...
pd/nw/pd_message_parser.js
View file @
bf1c4cc3
//Example message
"
use strict
"
;
var
pd_message
=
"
#X obj 36 60 inlet;
\n
#X obj 36 416 outlet;
\n
#X obj 68 387 send;
\n
#X obj 93 282 loadbang;
\n
#X msg 93 308 dollarzero;
\n
#X obj 93 334 canvasinfo 1;
\n
#X msg 93 359 symbol
\
$1-result;
\n
#X connect 0 0 5 0;
\n
#X connect 1 0 4 0;
\n
#X connect 3 0 2 0;
\n
#X connect 4 0 3 0;
\n
#X connect 4 1 0 0;
"
var
x
=
parse_pd_message
(
pd_message
);
alert
(
x
);
document
.
getElementById
(
"
demo
"
).
innerHTML
=
x
;
function
makeArray
(
w
,
h
,
val
)
{
var
arr
=
[];
for
(
let
i
=
0
;
i
<
h
;
i
++
)
{
arr
[
i
]
=
[];
for
(
let
j
=
0
;
j
<
w
-
1
;
j
++
)
{
for
(
let
j
=
0
;
j
<
w
;
j
++
)
{
arr
[
i
][
j
]
=
val
;
}
arr
[
i
][
h
-
1
]
=
"
\n
<br>
"
;
}
return
arr
;
}
...
...
@@ -61,13 +54,16 @@ function parse_pd_message(message) {
counter
=
0
,
str_count
=
0
,
object_msg_index_info
=
{},
matrix
=
makeArray
(
100
,
100
,
'
'
);
min_x
=
Infinity
,
min_y
=
Infinity
,
max_x
=
0
,
max_y
=
0
,
matrix
;
message
.
replace
(
"
\n
"
,
""
);
lines
=
message
.
split
(
"
;
"
);
for
(
i
=
0
;
i
<
lines
.
length
-
1
;
i
++
)
{
lines
[
i
].
replace
(
"
;
\n
"
,
""
);
lines
[
i
].
replace
(
"
;
"
,
""
);
splitted_str
=
lines
[
i
].
split
(
"
"
);
if
(
splitted_str
[
1
]
==
"
connect
"
)
{
...
...
@@ -78,8 +74,8 @@ function parse_pd_message(message) {
}
else
{
temp_str
=
splitted_str
.
slice
(
4
,
splitted_str
.
length
);
obj_msg_info
.
push
({
type
:
splitted_str
[
1
],
x
:
splitted_str
[
2
],
y
:
splitted_str
[
3
],
x
:
splitted_str
[
3
],
y
:
splitted_str
[
2
],
obj_no
:
count
,
text
:
temp_str
,
cell_start_x
:
0
,
...
...
@@ -87,84 +83,49 @@ function parse_pd_message(message) {
cell_end_x
:
0
,
cell_end_y
:
0
});
count
=
count
+
1
;
if
(
min_y
>
splitted_str
[
2
])
{
min_y
=
splitted_str
[
2
];
}
if
(
min_x
>
splitted_str
[
3
])
{
min_x
=
splitted_str
[
3
];
}
if
(
max_y
<
splitted_str
[
2
])
{
max_y
=
splitted_str
[
2
];
}
if
(
max_x
<
splitted_str
[
3
])
{
max_x
=
splitted_str
[
3
];
}
}
}
matrix
=
makeArray
(
max_x
/
20
+
5
,
max_y
/
20
+
5
,
'
*
'
);
obj_msg_info
.
sort
(
compare
);
i
=
0
;
j
=
0
;
counter
=
0
;
while
(
counter
<
obj_msg_info
.
length
)
{
if
(
counter
==
0
)
{
obj_msg_info
[
counter
].
cell_start_x
=
i
;
obj_msg_info
[
counter
].
cell_start_y
=
j
;
matrix
[
i
][
j
]
=
"
[
"
;
j
++
;
str_count
=
0
;
for
(
l
=
j
;
l
<
j
+
obj_msg_info
[
counter
].
text
[
0
].
length
;
l
++
)
{
matrix
[
i
][
l
]
=
obj_msg_info
[
counter
].
text
[
0
][
str_count
];
str_count
++
;
}
j
=
l
;
if
(
obj_msg_info
[
counter
].
type
==
"
obj
"
)
matrix
[
i
][
j
]
=
"
]
"
;
else
matrix
[
i
][
j
]
=
"
(
"
;
obj_msg_info
[
counter
].
cell_end_x
=
i
;
obj_msg_info
[
counter
].
cell_end_y
=
j
;
counter
+=
1
;
}
else
{
if
(
obj_msg_info
[
counter
].
x
==
obj_msg_info
[
counter
-
1
].
x
)
{
j
+=
5
;
j
+=
(
obj_msg_info
[
counter
].
y
-
obj_msg_info
[
counter
-
1
].
y
)
/
50
;
j
=
Math
.
floor
(
j
);
obj_msg_info
[
counter
].
cell_start_x
=
i
;
obj_msg_info
[
counter
].
cell_start_y
=
j
;
matrix
[
i
][
j
]
=
"
[
"
;
j
++
;
str_count
=
0
;
for
(
l
=
j
;
l
<
j
+
obj_msg_info
[
counter
].
text
[
0
].
length
;
l
++
)
{
matrix
[
i
][
l
]
=
obj_msg_info
[
counter
].
text
[
0
][
str_count
];
str_count
++
;
}
j
=
l
;
if
(
obj_msg_info
[
counter
].
type
==
"
obj
"
)
matrix
[
i
][
j
]
=
"
]
"
;
else
matrix
[
i
][
j
]
=
"
(
"
;
obj_msg_info
[
counter
].
cell_end_x
=
i
;
obj_msg_info
[
counter
].
cell_end_y
=
j
;
}
else
{
i
+=
3
;
i
+=
(
obj_msg_info
[
counter
].
x
-
obj_msg_info
[
counter
-
1
].
x
)
/
10
;
i
=
Math
.
floor
(
i
);
j
=
(
obj_msg_info
[
counter
].
y
)
/
50
;
j
=
Math
.
floor
(
j
);
obj_msg_info
[
counter
].
cell_start_x
=
i
;
obj_msg_info
[
counter
].
cell_start_y
=
j
;
matrix
[
i
][
j
]
=
"
[
"
;
j
++
;
str_count
=
0
;
for
(
l
=
j
;
l
<
j
+
obj_msg_info
[
counter
].
text
[
0
].
length
;
l
++
)
{
matrix
[
i
][
l
]
=
obj_msg_info
[
counter
].
text
[
0
][
str_count
];
str_count
++
;
}
j
=
l
;
if
(
obj_msg_info
[
counter
].
type
==
"
obj
"
)
matrix
[
i
][
j
]
=
"
]
"
;
else
matrix
[
i
][
j
]
=
"
(
"
;
obj_msg_info
[
counter
].
cell_end_x
=
i
;
obj_msg_info
[
counter
].
cell_end_y
=
j
;
}
counter
+=
1
;
}
obj_msg_info
[
counter
].
cell_start_x
=
Math
.
floor
((
obj_msg_info
[
counter
].
x
-
min_x
)
/
20
);
obj_msg_info
[
counter
].
cell_start_y
=
Math
.
floor
((
obj_msg_info
[
counter
].
y
-
min_y
)
/
20
);
i
=
obj_msg_info
[
counter
].
cell_start_x
;
j
=
obj_msg_info
[
counter
].
cell_start_y
;
matrix
[
i
][
j
]
=
"
[
"
;
j
++
;
str_count
=
0
;
for
(
l
=
j
;
l
<
j
+
obj_msg_info
[
counter
].
text
[
0
].
length
;
l
++
)
{
matrix
[
i
][
l
]
=
obj_msg_info
[
counter
].
text
[
0
][
str_count
];
str_count
++
;
}
j
=
l
;
if
(
obj_msg_info
[
counter
].
type
==
"
obj
"
)
matrix
[
i
][
j
]
=
"
]
"
;
else
matrix
[
i
][
j
]
=
"
(
"
;
obj_msg_info
[
counter
].
cell_end_x
=
i
;
obj_msg_info
[
counter
].
cell_end_y
=
j
;
counter
+=
1
;
}
for
(
i
=
0
;
i
<
obj_msg_info
.
length
;
i
++
)
{
//alert([obj_msg_info[i].obj_no,obj_msg_info[i].cell_start_x,obj_msg_info[i].cell_start_y,obj_msg_info[i].cell_end_x,obj_msg_info[i].cell_end_y]);
object_msg_index_info
[
obj_msg_info
[
i
].
obj_no
]
=
{
cell_start_x
:
obj_msg_info
[
i
].
cell_start_x
,
cell_start_y
:
obj_msg_info
[
i
].
cell_start_y
,
cell_end_x
:
obj_msg_info
[
i
].
cell_end_x
,
...
...
@@ -197,5 +158,20 @@ function parse_pd_message(message) {
}
}
}
return
matrix
;
}
\ No newline at end of file
var
ascii_art
=
''
;
for
(
i
=
0
;
i
<
matrix
.
length
;
i
++
){
for
(
j
=
0
;
j
<
matrix
[
i
].
length
;
j
++
)
{
if
(
matrix
[
i
][
j
]
==
"
*
"
){
ascii_art
=
ascii_art
+
"
"
;
}
else
{
ascii_art
=
ascii_art
+
matrix
[
i
][
j
];
}
}
ascii_art
=
ascii_art
+
'
\n
'
;
}
return
ascii_art
;
}
exports
.
parse_pd_message
=
parse_pd_message
;
\ No newline at end of file
pd/nw/pdgui.js
View file @
bf1c4cc3
...
...
@@ -1175,7 +1175,7 @@ function ascii_entry(cid,textarea_state,pd_message,pd_message_length)
if
(
textarea_state
)
{
//Just to check if we are getting the correct pd_message
if
(
pd_message_length
>
0
)
{
ascii_art_text_area
.
value
=
pd_message
;
patchwin
[
cid
].
window
.
canvas_events
.
create_ascii_art
(
pd_message
)
;
}
ascii_art
.
style
.
setProperty
(
"
display
"
,
"
inline
"
);
ascii_art_text_area
.
focus
();
...
...
pd/src/g_editor.c
View file @
bf1c4cc3
...
...
@@ -184,6 +184,8 @@ static void canvas_ascii_entry(t_canvas *x, t_floatarg textarea_state)
state
,
b_string
,
b_length
);
if
(
b
)
binbuf_free
(
b
);
}
void
canvas_getscroll
(
t_canvas
*
x
)
{
//sys_vgui("pdtk_canvas_getscroll .x%lx.c\n",(long)x);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment