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
hlgr
drawing-app
Commits
a17ab04f
Unverified
Commit
a17ab04f
authored
5 years ago
by
Giovanni Caruso
Committed by
Alexander Harkness
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Implement brush size
parent
0aa4223d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
public/index.html
+1
-1
1 addition, 1 deletion
public/index.html
src/app.js
+8
-1
8 additions, 1 deletion
src/app.js
src/canvas.js
+12
-2
12 additions, 2 deletions
src/canvas.js
src/room.js
+8
-1
8 additions, 1 deletion
src/room.js
with
29 additions
and
5 deletions
public/index.html
+
1
−
1
View file @
a17ab04f
...
...
@@ -89,7 +89,7 @@
type=
"range"
min=
"1"
max=
"100"
value=
"
5
0"
value=
"
1
0"
class=
"slider"
id=
"range"
/>
...
...
This diff is collapsed.
Click to expand it.
src/app.js
+
8
−
1
View file @
a17ab04f
...
...
@@ -132,6 +132,7 @@ HTML.output.innerHTML = HTML.slider.value
HTML
.
slider
.
oninput
=
function
()
{
HTML
.
output
.
innerHTML
=
this
.
value
canvas
.
setStrokeRadius
(
this
.
value
/
10
)
}
HTML
.
eraserButton
.
addEventListener
(
"
click
"
,
()
=>
{
...
...
@@ -238,7 +239,12 @@ canvas.input.addEventListener("strokestart", ({ detail: e }) => {
if
(
currentTool
==
tools
.
PEN
)
{
pathIDsByPointerID
.
set
(
e
.
pointerId
,
room
.
addPath
([...
mousePos
,
e
.
pressure
,
canvas
.
getStrokeColour
()]),
room
.
addPath
([
...
mousePos
,
e
.
pressure
,
canvas
.
getStrokeColour
(),
canvas
.
stroke_radius
,
]),
)
}
else
if
(
currentTool
==
tools
.
ERASER
)
{
erasePoint
(
mousePos
)
...
...
@@ -261,6 +267,7 @@ canvas.input.addEventListener("strokemove", ({ detail: e }) => {
...
mousePos
,
e
.
pressure
,
canvas
.
getStrokeColour
(),
canvas
.
stroke_radius
,
])
}
else
if
(
currentTool
==
tools
.
ERASER
)
{
erasePoint
(
mousePos
)
...
...
This diff is collapsed.
Click to expand it.
src/canvas.js
+
12
−
2
View file @
a17ab04f
...
...
@@ -17,6 +17,7 @@ const lineFn = line()
const
pathGroupElems
=
new
Map
()
let
stroke_colour
=
"
blue
"
export
var
stroke_radius
=
1
export
const
MIN_STROKE_RADIUS
=
0.1
export
const
MAX_STROKE_RADIUS
=
3.9
...
...
@@ -73,7 +74,10 @@ const smoothPath = ([...path]) => {
}
const
getStrokeRadius
=
(
pressure
)
=>
{
return
MIN_STROKE_RADIUS
+
pressure
*
(
MAX_STROKE_RADIUS
-
MIN_STROKE_RADIUS
)
return
(
MIN_STROKE_RADIUS
+
(
stroke_radius
+
pressure
)
*
(
MAX_STROKE_RADIUS
-
MIN_STROKE_RADIUS
)
)
}
export
const
input
=
new
EventTarget
()
...
...
@@ -93,7 +97,7 @@ export const renderPath = (id, points) => {
let
segments
=
[[]]
for
(
const
point
of
points
)
{
colour
=
point
[
3
]
if
(
point
[
4
]
!=
false
)
{
if
(
point
[
5
]
!=
false
)
{
segments
[
segments
.
length
-
1
].
push
(
point
)
}
else
{
segments
.
push
([])
...
...
@@ -131,6 +135,7 @@ export const renderPath = (id, points) => {
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
]))
pathGroupElem
.
appendChild
(
circleElem
)
}
else
{
// Further split up segments based on thickness.
...
...
@@ -178,6 +183,11 @@ export function setStrokeColour(colour) {
stroke_colour
=
colour
}
<<<<<<<
HEAD
export
function
getStrokeColour
()
{
return
stroke_colour
=======
export
function
setStrokeRadius
(
radius
)
{
stroke_radius
=
radius
>>>>>>>
Implement
brush
size
}
This diff is collapsed.
Click to expand it.
src/room.js
+
8
−
1
View file @
a17ab04f
...
...
@@ -65,7 +65,14 @@ class Room extends EventTarget {
return
addSet
.
toArray
()
.
map
((
p
=
[],
i
)
=>
[
p
[
0
],
p
[
1
],
p
[
2
],
p
[
3
],
!
eraseSet
.
get
(
i
.
toString
())])
.
map
((
p
=
[],
i
)
=>
[
p
[
0
],
p
[
1
],
p
[
2
],
p
[
3
],
p
[
4
],
!
eraseSet
.
get
(
i
.
toString
()),
])
}
inviteUser
(
id
)
{
...
...
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