Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
blender-addons
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
blender
blender-addons
Commits
747c0a37
Commit
747c0a37
authored
6 years ago
by
Sergey Sharybin
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' into blender2.8
parents
85e6619a
c2aef4a9
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
io_curve_svg/import_svg.py
+33
-12
33 additions, 12 deletions
io_curve_svg/import_svg.py
with
33 additions
and
12 deletions
io_curve_svg/import_svg.py
+
33
−
12
View file @
747c0a37
...
@@ -47,9 +47,13 @@ SVGEmptyStyles = {'useFill': None,
...
@@ -47,9 +47,13 @@ SVGEmptyStyles = {'useFill': None,
def
srgb_to_linearrgb
(
c
):
def
srgb_to_linearrgb
(
c
):
if
c
<
0.04045
:
if
c
<
0.04045
:
return
0.0
if
c
<
0.0
else
c
*
(
1.0
/
12.92
)
;
return
0.0
if
c
<
0.0
else
c
*
(
1.0
/
12.92
)
else
:
else
:
return
pow
((
c
+
0.055
)
*
(
1.0
/
1.055
),
2.4
);
return
pow
((
c
+
0.055
)
*
(
1.0
/
1.055
),
2.4
)
def
check_points_equal
(
point_a
,
point_b
):
return
(
abs
(
point_a
[
0
]
-
point_b
[
0
])
<
1e-6
and
abs
(
point_a
[
1
]
-
point_b
[
1
])
<
1e-6
)
def
SVGParseFloat
(
s
,
i
=
0
):
def
SVGParseFloat
(
s
,
i
=
0
):
...
@@ -645,7 +649,7 @@ class SVGPathParser:
...
@@ -645,7 +649,7 @@ class SVGPathParser:
# filled.
# filled.
first
=
self
.
_spline
[
'
points
'
][
0
]
first
=
self
.
_spline
[
'
points
'
][
0
]
if
abs
(
first
[
'
x
'
]
-
x
)
<
1e-6
and
abs
(
first
[
'
y
'
]
-
y
)
<
1e-6
:
if
check_points_equal
((
first
[
'
x
'
],
first
[
'
y
'
]),
(
x
,
y
))
:
if
handle_left
is
not
None
:
if
handle_left
is
not
None
:
first
[
'
handle_left
'
]
=
handle_left
first
[
'
handle_left
'
]
=
handle_left
first
[
'
handle_left_type
'
]
=
'
FREE
'
first
[
'
handle_left_type
'
]
=
'
FREE
'
...
@@ -662,6 +666,9 @@ class SVGPathParser:
...
@@ -662,6 +666,9 @@ class SVGPathParser:
if
last
[
'
handle_right_type
'
]
==
'
VECTOR
'
and
handle_left_type
==
'
FREE
'
:
if
last
[
'
handle_right_type
'
]
==
'
VECTOR
'
and
handle_left_type
==
'
FREE
'
:
last
[
'
handle_right
'
]
=
(
last
[
'
x
'
],
last
[
'
y
'
])
last
[
'
handle_right
'
]
=
(
last
[
'
x
'
],
last
[
'
y
'
])
last
[
'
handle_right_type
'
]
=
'
FREE
'
last
[
'
handle_right_type
'
]
=
'
FREE
'
if
last
[
'
handle_right_type
'
]
==
'
FREE
'
and
handle_left_type
==
'
VECTOR
'
:
handle_left
=
(
x
,
y
)
handle_left_type
=
'
FREE
'
point
=
{
'
x
'
:
x
,
point
=
{
'
x
'
:
x
,
'
y
'
:
y
,
'
y
'
:
y
,
...
@@ -796,20 +803,21 @@ class SVGPathParser:
...
@@ -796,20 +803,21 @@ class SVGPathParser:
else
:
else
:
if
self
.
_handle
is
not
None
:
if
self
.
_handle
is
not
None
:
x1
,
y1
=
SVGFlipHandle
(
self
.
_point
[
0
],
self
.
_point
[
1
],
x1
,
y1
=
SVGFlipHandle
(
self
.
_point
[
0
],
self
.
_point
[
1
],
self
.
_handle
[
0
],
self
.
_handle
[
1
])
self
.
_handle
[
0
],
self
.
_handle
[
1
])
else
:
else
:
x1
,
y1
=
self
.
_point
x1
,
y1
=
self
.
_point
x
,
y
=
self
.
_getCoordPair
(
code
.
islower
(),
self
.
_point
)
x
,
y
=
self
.
_getCoordPair
(
code
.
islower
(),
self
.
_point
)
if
self
.
_spline
is
None
:
if
not
check_points_equal
((
x
,
y
),
self
.
_point
):
self
.
_appendPoint
(
self
.
_point
[
0
],
self
.
_point
[
1
],
if
self
.
_spline
is
None
:
handle_left_type
=
'
FREE
'
,
handle_left
=
self
.
_point
,
self
.
_appendPoint
(
self
.
_point
[
0
],
self
.
_point
[
1
],
handle_right_type
=
'
FREE
'
,
handle_right
=
self
.
_point
)
handle_left_type
=
'
FREE
'
,
handle_left
=
self
.
_point
,
handle_right_type
=
'
FREE
'
,
handle_right
=
self
.
_point
)
self
.
_appendPoint
(
x
,
y
,
self
.
_appendPoint
(
x
,
y
,
handle_left_type
=
'
FREE
'
,
handle_left
=
(
x1
,
y1
),
handle_left_type
=
'
FREE
'
,
handle_left
=
(
x1
,
y1
),
handle_right_type
=
'
FREE
'
,
handle_right
=
(
x
,
y
))
handle_right_type
=
'
FREE
'
,
handle_right
=
(
x
,
y
))
self
.
_point
=
(
x
,
y
)
self
.
_point
=
(
x
,
y
)
self
.
_handle
=
(
x1
,
y1
)
self
.
_handle
=
(
x1
,
y1
)
...
@@ -961,7 +969,7 @@ class SVGPathParser:
...
@@ -961,7 +969,7 @@ class SVGPathParser:
raise
Exception
(
'
Unknown path command: {0}
'
.
format
(
code
))
raise
Exception
(
'
Unknown path command: {0}
'
.
format
(
code
))
if
cmd
in
{
'
Z
'
,
'
z
'
}:
if
cmd
in
{
'
Z
'
,
'
z
'
}:
closed
=
True
closed
=
True
else
:
else
:
closed
=
False
closed
=
False
...
@@ -1225,6 +1233,19 @@ class SVGGeometryPATH(SVGGeometry):
...
@@ -1225,6 +1233,19 @@ class SVGGeometryPATH(SVGGeometry):
for
spline
in
self
.
_splines
:
for
spline
in
self
.
_splines
:
act_spline
=
None
act_spline
=
None
if
spline
[
'
closed
'
]
and
len
(
spline
[
'
points
'
])
>=
2
:
first
=
spline
[
'
points
'
][
0
]
last
=
spline
[
'
points
'
][
-
1
]
if
(
first
[
'
handle_left_type
'
]
==
'
FREE
'
and
last
[
'
handle_right_type
'
]
==
'
VECTOR
'
):
last
[
'
handle_right_type
'
]
=
'
FREE
'
last
[
'
handle_right
'
]
=
(
last
[
'
x
'
],
last
[
'
y
'
])
if
(
last
[
'
handle_right_type
'
]
==
'
FREE
'
and
first
[
'
handle_left_type
'
]
==
'
VECTOR
'
):
first
[
'
handle_left_type
'
]
=
'
FREE
'
first
[
'
handle_left
'
]
=
(
first
[
'
x
'
],
first
[
'
y
'
])
for
point
in
spline
[
'
points
'
]:
for
point
in
spline
[
'
points
'
]:
co
=
self
.
_transformCoord
((
point
[
'
x
'
],
point
[
'
y
'
]))
co
=
self
.
_transformCoord
((
point
[
'
x
'
],
point
[
'
y
'
]))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment