Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drawing-app
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
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sweng-group-15
drawing-app
Commits
889b6f13
Commit
889b6f13
authored
Jan 5, 2020
by
Moritz Langenstein
Browse files
Options
Downloads
Patches
Plain Diff
(ml5717) Added comment explanation to shape smoothing
parent
b94c7f36
No related branches found
No related tags found
1 merge request
!78
(ml5717) (ztw17) Small frontend improvements
Pipeline
#109541
passed
Jan 5, 2020
Stage: fetch
Stage: deps
Stage: check
Stage: build
Stage: test
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/canvas.js
+15
-8
15 additions, 8 deletions
src/canvas.js
with
15 additions
and
8 deletions
src/canvas.js
+
15
−
8
View file @
889b6f13
...
@@ -192,10 +192,14 @@ export const splitOnPressures = ([...path]) => {
...
@@ -192,10 +192,14 @@ export const splitOnPressures = ([...path]) => {
}
}
export
const
renderPath
=
(
id
,
points
,
pathEraseIntervals
)
=>
{
export
const
renderPath
=
(
id
,
points
,
pathEraseIntervals
)
=>
{
let
index
=
-
1
let
rectShapeStartIndex
=
-
1
// Rect recognition hint shape: pure rect with no erasure
if
(
Object
.
keys
(
pathEraseIntervals
).
length
==
0
&&
points
.
length
==
5
)
{
if
(
Object
.
keys
(
pathEraseIntervals
).
length
==
0
&&
points
.
length
==
5
)
{
index
=
0
rectShapeStartIndex
=
0
// Recognised rect shape: rect after completely erased raw data
}
else
if
(
Object
.
keys
(
pathEraseIntervals
).
length
>
0
&&
points
.
length
>
5
)
{
}
else
if
(
Object
.
keys
(
pathEraseIntervals
).
length
>
0
&&
points
.
length
>
5
)
{
// Check that the preceding raw data is completely erased
for
(
let
i
=
0
;
i
<
points
.
length
-
5
;
i
++
)
{
for
(
let
i
=
0
;
i
<
points
.
length
-
5
;
i
++
)
{
if
(
if
(
!
pathEraseIntervals
[
i
]
||
!
pathEraseIntervals
[
i
]
||
...
@@ -207,14 +211,16 @@ export const renderPath = (id, points, pathEraseIntervals) => {
...
@@ -207,14 +211,16 @@ export const renderPath = (id, points, pathEraseIntervals) => {
}
}
}
}
i
ndex
=
points
.
length
-
5
rectShapeStartI
ndex
=
points
.
length
-
5
}
}
// Only draw the path smooth if it is not a recognised rect shape, i.e. the last five points form a cycle
const
pathSmooth
=
!
(
const
pathSmooth
=
!
(
i
ndex
>=
0
&&
rectShapeStartI
ndex
>=
0
&&
points
[
i
ndex
][
0
]
==
points
[
i
ndex
+
4
][
0
]
&&
points
[
rectShapeStartI
ndex
][
0
]
==
points
[
rectShapeStartI
ndex
+
4
][
0
]
&&
points
[
i
ndex
][
1
]
==
points
[
i
ndex
+
4
][
1
]
&&
points
[
rectShapeStartI
ndex
][
1
]
==
points
[
rectShapeStartI
ndex
+
4
][
1
]
&&
points
[
i
ndex
][
2
]
==
points
[
i
ndex
+
4
][
2
]
&&
points
[
rectShapeStartI
ndex
][
2
]
==
points
[
rectShapeStartI
ndex
+
4
][
2
]
&&
points
[
i
ndex
][
3
]
==
points
[
i
ndex
+
4
][
3
]
points
[
rectShapeStartI
ndex
][
3
]
==
points
[
rectShapeStartI
ndex
+
4
][
3
]
)
)
let
subpaths
=
applyErasureIntervals
(
points
,
pathEraseIntervals
)
let
subpaths
=
applyErasureIntervals
(
points
,
pathEraseIntervals
)
...
@@ -223,6 +229,7 @@ export const renderPath = (id, points, pathEraseIntervals) => {
...
@@ -223,6 +229,7 @@ export const renderPath = (id, points, pathEraseIntervals) => {
const
subpathElems
=
subpaths
.
map
((
subpath
)
=>
const
subpathElems
=
subpaths
.
map
((
subpath
)
=>
renderSubpath
(
subpath
,
pathSmooth
),
renderSubpath
(
subpath
,
pathSmooth
),
)
)
const
pathGroupElem
=
ensurePathGroupElem
(
id
)
const
pathGroupElem
=
ensurePathGroupElem
(
id
)
subpathElems
.
forEach
((
subpathElem
)
=>
pathGroupElem
.
appendChild
(
subpathElem
))
subpathElems
.
forEach
((
subpathElem
)
=>
pathGroupElem
.
appendChild
(
subpathElem
))
}
}
...
...
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
sign in
to comment