Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Amanda Ghassaei
OrigamiSimulator
Commits
ac66c067
Commit
ac66c067
authored
May 06, 2017
by
amandaghassaei
Browse files
import variable angles in svg
parent
70c09d89
Changes
2
Hide whitespace changes
Inline
Side-by-side
js/importer.js
View file @
ac66c067
...
...
@@ -32,8 +32,8 @@ function initImporter(globals){
}
var
file
=
files
[
0
];
var
name
=
file
.
name
;
var
extension
=
name
.
split
(
"
.
"
)
;
var
extension
=
file
.
name
.
split
(
"
.
"
)
;
var
name
=
extension
[
0
]
;
extension
=
extension
[
extension
.
length
-
1
];
var
reader
=
new
FileReader
();
...
...
js/pattern.js
View file @
ac66c067
...
...
@@ -39,18 +39,22 @@ function initPattern(globals){
});
var
$mountains
=
$paths
.
filter
(
function
(){
var
color
=
hexToColor
(
$
(
this
).
attr
(
"
stroke
"
).
toLowerCase
());
if
(
color
.
r
>
0
&&
color
.
g
==
0
&&
color
.
b
==
0
){
_mountainAngles
.
push
(
-
color
.
r
*
Math
.
PI
);
var
stroke
=
$
(
this
).
attr
(
"
stroke
"
).
toLowerCase
();
if
(
stroke
==
"
#ff0000
"
||
stroke
==
"
#f00
"
){
var
opacity
=
parseFloat
(
$
(
this
).
attr
(
"
opacity
"
));
if
(
isNaN
(
opacity
))
opacity
=
1
;
_mountainAngles
.
push
(
-
opacity
*
Math
.
PI
);
return
true
;
}
return
false
;
});
var
$valleys
=
$paths
.
filter
(
function
(){
var
color
=
hexToColor
(
$
(
this
).
attr
(
"
stroke
"
).
toLowerCase
());
if
(
color
.
b
>
0
&&
color
.
g
==
0
&&
color
.
r
==
0
){
_valleyAngles
.
push
(
color
.
b
*
Math
.
PI
);
var
stroke
=
$
(
this
).
attr
(
"
stroke
"
).
toLowerCase
();
if
(
stroke
==
"
#0000ff
"
||
stroke
==
"
#00f
"
){
var
opacity
=
parseFloat
(
$
(
this
).
attr
(
"
opacity
"
));
if
(
isNaN
(
opacity
))
opacity
=
1
;
_valleyAngles
.
push
(
opacity
*
Math
.
PI
);
return
true
;
}
return
false
;
...
...
@@ -105,14 +109,6 @@ function initPattern(globals){
});
}
function
hexToColor
(
stroke
){
stroke
=
stroke
.
slice
(
1
);
if
(
stroke
.
length
==
3
){
stroke
=
stroke
[
0
]
+
stroke
[
0
]
+
stroke
[
1
]
+
stroke
[
1
]
+
stroke
[
2
]
+
stroke
[
2
];
}
return
new
THREE
.
Color
(
parseInt
(
"
0x
"
+
stroke
));
}
function
parsePath
(
_verticesRaw
,
_segmentsRaw
,
$paths
,
angles
){
for
(
var
i
=
0
;
i
<
$paths
.
length
;
i
++
){
var
segments
=
$paths
[
i
].
getPathData
();
...
...
Write
Preview
Supports
Markdown
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