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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sweng-group-15
drawing-app
Commits
e0b53a58
Commit
e0b53a58
authored
5 years ago
by
Giovanni Caruso
Committed by
Moritz Langenstein
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fixed stroke radius not being synchronised correctly
parent
1cac63e9
No related branches found
No related tags found
1 merge request
!45
Brush size
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/canvas.js
+12
-6
12 additions, 6 deletions
src/canvas.js
src/room.js
+4
-4
4 additions, 4 deletions
src/room.js
with
16 additions
and
10 deletions
src/canvas.js
+
12
−
6
View file @
e0b53a58
...
...
@@ -73,10 +73,10 @@ const smoothPath = ([...path]) => {
return
path
}
const
getStrokeRadius
=
(
pressure
)
=>
{
const
getStrokeRadius
=
(
pressure
,
radius
)
=>
{
return
(
MIN_STROKE_RADIUS
+
(
stroke_
radius
+
pressure
)
*
(
MAX_STROKE_RADIUS
-
MIN_STROKE_RADIUS
)
(
radius
+
pressure
)
*
(
MAX_STROKE_RADIUS
-
MIN_STROKE_RADIUS
)
)
}
...
...
@@ -92,11 +92,13 @@ const createPathElem = (d, width) => {
export
const
renderPath
=
(
id
,
points
)
=>
{
points
=
points
.
filter
(([
x
])
=>
x
!=
null
)
let
colour
=
""
var
radius
=
0
// Split up points into completely non-erased segments.
let
segments
=
[[]]
for
(
const
point
of
points
)
{
colour
=
point
[
3
]
radius
=
point
[
4
]
if
(
point
[
5
]
!=
false
)
{
segments
[
segments
.
length
-
1
].
push
(
point
)
}
else
{
...
...
@@ -134,8 +136,8 @@ export const renderPath = (id, points) => {
circleElem
.
setAttribute
(
"
fill
"
,
colour
)
circleElem
.
setAttribute
(
"
cx
"
,
subpath
[
0
][
0
])
circleElem
.
setAttribute
(
"
cy
"
,
subpath
[
0
][
1
])
circleElem
.
setAttribute
(
"
r
"
,
getStrokeRadius
(
subpath
[
0
][
2
]))
console
.
log
(
getStrokeRadius
(
subpath
[
0
][
2
]))
circleElem
.
setAttribute
(
"
r
"
,
getStrokeRadius
(
subpath
[
0
][
2
]
,
radius
))
console
.
log
(
getStrokeRadius
(
subpath
[
0
][
2
]
,
radius
))
pathGroupElem
.
appendChild
(
circleElem
)
}
else
{
// Further split up segments based on thickness.
...
...
@@ -144,13 +146,17 @@ export const renderPath = (id, points) => {
for
(
let
i
=
1
;
i
<
subpath_
.
length
;
i
++
)
{
if
(
subpath_
[
i
][
2
]
!=
w
)
{
const
d
=
lineFn
([...
subpath_
.
splice
(
0
,
i
),
subpath_
[
0
]])
pathGroupElem
.
appendChild
(
createPathElem
(
d
,
getStrokeRadius
(
w
)
*
2
))
pathGroupElem
.
appendChild
(
createPathElem
(
d
,
getStrokeRadius
(
w
,
radius
)
*
2
),
)
w
=
subpath_
[
0
][
2
]
i
=
1
}
}
const
d
=
lineFn
(
subpath_
)
pathGroupElem
.
appendChild
(
createPathElem
(
d
,
getStrokeRadius
(
w
)
*
2
))
pathGroupElem
.
appendChild
(
createPathElem
(
d
,
getStrokeRadius
(
w
,
radius
)
*
2
),
)
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/room.js
+
4
−
4
View file @
e0b53a58
...
...
@@ -23,14 +23,14 @@ class Room extends EventTarget {
this
.
_y
.
destroy
()
}
addPath
([
x
,
y
,
w
,
colour
])
{
addPath
([
x
,
y
,
w
,
colour
,
radius
])
{
const
id
=
uuidv4
()
this
.
_y
.
share
.
strokeAdd
.
set
(
id
,
Y
.
Array
).
push
([[
x
,
y
,
w
,
colour
]])
this
.
_y
.
share
.
strokeAdd
.
set
(
id
,
Y
.
Array
).
push
([[
x
,
y
,
w
,
colour
,
radius
]])
return
id
}
extendPath
(
id
,
[
x
,
y
,
w
,
colour
])
{
this
.
_y
.
share
.
strokeAdd
.
get
(
id
).
push
([[
x
,
y
,
w
,
colour
]])
extendPath
(
id
,
[
x
,
y
,
w
,
colour
,
radius
])
{
this
.
_y
.
share
.
strokeAdd
.
get
(
id
).
push
([[
x
,
y
,
w
,
colour
,
radius
]])
}
getPaths
()
{
...
...
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