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
e086c768
Commit
e086c768
authored
5 years ago
by
Giovanni Caruso
Browse files
Options
Downloads
Patches
Plain Diff
Fixed stroke_colour
parent
6c5cd176
No related branches found
No related tags found
1 merge request
!42
Colouredlines
Pipeline
#103237
passed
5 years ago
Stage: fetch
Stage: deps
Stage: check
Stage: build
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/app.js
+5
-5
5 additions, 5 deletions
src/app.js
src/canvas.js
+6
-2
6 additions, 2 deletions
src/canvas.js
with
11 additions
and
7 deletions
src/app.js
+
5
−
5
View file @
e086c768
...
@@ -91,10 +91,10 @@ HTML.rectangle.addEventListener("click", () => {
...
@@ -91,10 +91,10 @@ HTML.rectangle.addEventListener("click", () => {
showElement
(
HTML
.
palette
)
showElement
(
HTML
.
palette
)
})
})
var
svg
=
HTML
.
wheel
.
children
let
svg
=
HTML
.
wheel
.
children
for
(
var
i
=
1
;
i
<
svg
.
length
;
i
++
)
{
for
(
var
i
=
1
;
i
<
svg
.
length
;
i
++
)
{
svg
[
i
].
addEventListener
(
"
click
"
,
(
event
)
=>
{
svg
[
i
].
addEventListener
(
"
click
"
,
(
event
)
=>
{
var
paletteColour
=
event
.
target
.
getAttribute
(
"
fill
"
)
let
paletteColour
=
event
.
target
.
getAttribute
(
"
fill
"
)
HTML
.
rectangle
.
style
.
backgroundColor
=
paletteColour
HTML
.
rectangle
.
style
.
backgroundColor
=
paletteColour
canvas
.
setStrokeColour
(
paletteColour
)
canvas
.
setStrokeColour
(
paletteColour
)
hideElement
(
HTML
.
palette
)
hideElement
(
HTML
.
palette
)
...
@@ -110,7 +110,7 @@ function hideElement(element) {
...
@@ -110,7 +110,7 @@ function hideElement(element) {
}
}
HTML
.
picker
.
addEventListener
(
"
change
"
,
()
=>
{
HTML
.
picker
.
addEventListener
(
"
change
"
,
()
=>
{
var
paletteColour
=
event
.
target
.
value
let
paletteColour
=
event
.
target
.
value
HTML
.
rectangle
.
style
.
backgroundColor
=
paletteColour
HTML
.
rectangle
.
style
.
backgroundColor
=
paletteColour
canvas
.
setStrokeColour
(
paletteColour
)
canvas
.
setStrokeColour
(
paletteColour
)
})
})
...
@@ -176,7 +176,7 @@ canvas.input.addEventListener("strokestart", ({ detail: e }) => {
...
@@ -176,7 +176,7 @@ canvas.input.addEventListener("strokestart", ({ detail: e }) => {
if
(
currentTool
==
tools
.
PEN
)
{
if
(
currentTool
==
tools
.
PEN
)
{
pathIDsByPointerID
.
set
(
pathIDsByPointerID
.
set
(
e
.
pointerId
,
e
.
pointerId
,
room
.
addPath
([...
mousePos
,
e
.
pressure
,
canvas
.
s
troke
_c
olour
]),
room
.
addPath
([...
mousePos
,
e
.
pressure
,
canvas
.
getS
troke
C
olour
()
]),
)
)
}
else
if
(
currentTool
==
tools
.
ERASER
)
{
}
else
if
(
currentTool
==
tools
.
ERASER
)
{
erasePoint
(
mousePos
)
erasePoint
(
mousePos
)
...
@@ -198,7 +198,7 @@ canvas.input.addEventListener("strokemove", ({ detail: e }) => {
...
@@ -198,7 +198,7 @@ canvas.input.addEventListener("strokemove", ({ detail: e }) => {
room
.
extendPath
(
pathIDsByPointerID
.
get
(
e
.
pointerId
),
[
room
.
extendPath
(
pathIDsByPointerID
.
get
(
e
.
pointerId
),
[
...
mousePos
,
...
mousePos
,
e
.
pressure
,
e
.
pressure
,
canvas
.
s
troke
_c
olour
,
canvas
.
getS
troke
C
olour
()
,
])
])
}
else
if
(
currentTool
==
tools
.
ERASER
)
{
}
else
if
(
currentTool
==
tools
.
ERASER
)
{
erasePoint
(
mousePos
)
erasePoint
(
mousePos
)
...
...
This diff is collapsed.
Click to expand it.
src/canvas.js
+
6
−
2
View file @
e086c768
...
@@ -16,7 +16,7 @@ const lineFn = line()
...
@@ -16,7 +16,7 @@ const lineFn = line()
const
pathGroupElems
=
new
Map
()
const
pathGroupElems
=
new
Map
()
export
var
stroke_colour
=
"
blue
"
let
stroke_colour
=
"
blue
"
export
const
MIN_STROKE_RADIUS
=
0.1
export
const
MIN_STROKE_RADIUS
=
0.1
export
const
MAX_STROKE_RADIUS
=
3.9
export
const
MAX_STROKE_RADIUS
=
3.9
...
@@ -35,7 +35,7 @@ const createPathElem = (d, width) => {
...
@@ -35,7 +35,7 @@ const createPathElem = (d, width) => {
export
const
renderPath
=
(
id
,
points
)
=>
{
export
const
renderPath
=
(
id
,
points
)
=>
{
points
=
points
.
filter
(([
x
])
=>
x
!=
null
)
points
=
points
.
filter
(([
x
])
=>
x
!=
null
)
var
colour
=
""
let
colour
=
""
// Split up points into completely non-erased segments.
// Split up points into completely non-erased segments.
let
segments
=
[[]]
let
segments
=
[[]]
...
@@ -125,3 +125,7 @@ canvas.addEventListener("touchmove", (e) => e.preventDefault())
...
@@ -125,3 +125,7 @@ canvas.addEventListener("touchmove", (e) => e.preventDefault())
export
function
setStrokeColour
(
colour
)
{
export
function
setStrokeColour
(
colour
)
{
stroke_colour
=
colour
stroke_colour
=
colour
}
}
export
function
getStrokeColour
()
{
return
stroke_colour
}
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