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
72414a7f
Commit
72414a7f
authored
5 years ago
by
Yuriy Maksymets
Browse files
Options
Downloads
Patches
Plain Diff
Decoupled stroke color and radius from html
parent
bbb44f34
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
public/index.html
+1
-2
1 addition, 2 deletions
public/index.html
src/elements.js
+2
-2
2 additions, 2 deletions
src/elements.js
src/tool-selection.js
+13
-10
13 additions, 10 deletions
src/tool-selection.js
with
16 additions
and
14 deletions
public/index.html
+
1
−
2
View file @
72414a7f
...
...
@@ -87,7 +87,6 @@
type=
"range"
min=
"1"
max=
"10"
value=
"2"
class=
"slider"
id=
"range"
/>
...
...
@@ -192,7 +191,7 @@
<b>
Other colours
</b>
</div>
<label
id=
"colours"
>
<input
id=
"other-colours"
type=
"color"
value=
"#0000ff"
/>
<input
id=
"other-colours"
type=
"color"
/>
</label>
</div>
</div>
...
...
This diff is collapsed.
Click to expand it.
src/elements.js
+
2
−
2
View file @
72414a7f
...
...
@@ -29,8 +29,8 @@ export const closeButton = document.querySelectorAll(".close")
export
const
palette
=
document
.
getElementById
(
"
palette
"
)
export
const
rectangle
=
document
.
getElementById
(
"
rectangle
"
)
export
const
wheel
=
document
.
getElementById
(
"
wheel
"
)
export
const
p
icker
=
document
.
getElementById
(
"
other-colours
"
)
export
const
slider
=
document
.
getElementById
(
"
range
"
)
export
const
strokeColorP
icker
=
document
.
getElementById
(
"
other-colours
"
)
export
const
s
trokeRadiusS
lider
=
document
.
getElementById
(
"
range
"
)
export
const
output
=
document
.
getElementById
(
"
value
"
)
export
const
labelColours
=
document
.
getElementById
(
"
colours
"
)
export
const
userInfo
=
document
.
getElementById
(
"
user-avatar
"
)
This diff is collapsed.
Click to expand it.
src/tool-selection.js
+
13
−
10
View file @
72414a7f
...
...
@@ -5,14 +5,14 @@ export const Tools = Object.freeze({
ERASER
:
Symbol
(
"
eraser
"
),
})
let
t
ool
=
Tools
.
PEN
let
selectedT
ool
=
Tools
.
PEN
let
strokeColour
=
"
#000000
"
let
strokeRadius
=
2
let
recognitionEnabled
=
false
// TODO: The erase radius should also be selectable.
const
ERASE_RADIUS
=
20
export
const
getTool
=
()
=>
t
ool
export
const
getTool
=
()
=>
selectedT
ool
export
const
getStrokeColour
=
()
=>
strokeColour
export
const
getStrokeRadius
=
()
=>
strokeRadius
...
...
@@ -27,6 +27,9 @@ const hideElement = (element) => {
element
.
style
.
display
=
"
none
"
}
HTML
.
strokeColorPicker
.
setAttribute
(
"
value
"
,
strokeColour
)
HTML
.
strokeRadiusSlider
.
setAttribute
(
"
value
"
,
strokeRadius
)
HTML
.
recognitionModeButton
.
addEventListener
(
"
click
"
,
()
=>
{
recognitionEnabled
=
!
recognitionEnabled
if
(
recognitionEnabled
)
{
...
...
@@ -37,39 +40,39 @@ HTML.recognitionModeButton.addEventListener("click", () => {
})
HTML
.
penButton
.
addEventListener
(
"
click
"
,
()
=>
{
if
(
t
ool
==
Tools
.
PEN
)
{
if
(
selectedT
ool
==
Tools
.
PEN
)
{
showElement
(
HTML
.
penProperties
)
}
else
{
t
ool
=
Tools
.
PEN
selectedT
ool
=
Tools
.
PEN
HTML
.
penButton
.
classList
.
add
(
"
selected
"
)
HTML
.
eraserButton
.
classList
.
remove
(
"
selected
"
)
}
})
HTML
.
eraserButton
.
addEventListener
(
"
click
"
,
()
=>
{
t
ool
=
Tools
.
ERASER
selectedT
ool
=
Tools
.
ERASER
HTML
.
penButton
.
classList
.
remove
(
"
selected
"
)
HTML
.
eraserButton
.
classList
.
add
(
"
selected
"
)
})
HTML
.
p
icker
.
addEventListener
(
"
change
"
,
()
=>
{
HTML
.
strokeColorP
icker
.
addEventListener
(
"
change
"
,
()
=>
{
const
paletteColour
=
event
.
target
.
value
HTML
.
rectangle
.
style
.
backgroundColor
=
paletteColour
HTML
.
labelColours
.
style
.
backgroundColor
=
paletteColour
strokeColour
=
paletteColour
})
HTML
.
slider
.
oninput
=
function
()
{
HTML
.
s
trokeRadiusS
lider
.
oninput
=
function
()
{
HTML
.
output
.
innerHTML
=
this
.
value
strokeRadius
=
this
.
value
/
2
}
HTML
.
output
.
innerHTML
=
HTML
.
slider
.
value
HTML
.
output
.
innerHTML
=
HTML
.
s
trokeRadiusS
lider
.
value
// If the page has been refreshed
if
(
performance
.
navigation
.
type
==
1
)
{
const
sliderValue
=
parseInt
(
HTML
.
output
.
innerHTML
)
HTML
.
slider
.
setAttribute
(
"
value
"
,
sliderValue
)
HTML
.
s
trokeRadiusS
lider
.
setAttribute
(
"
value
"
,
sliderValue
)
strokeRadius
=
sliderValue
/
2
}
...
...
@@ -109,7 +112,7 @@ for (let i = 1; i < svg.length; i++) {
svg
[
i
].
addEventListener
(
"
click
"
,
(
event
)
=>
{
const
paletteColour
=
event
.
target
.
getAttribute
(
"
fill
"
)
HTML
.
rectangle
.
style
.
backgroundColor
=
paletteColour
HTML
.
p
icker
.
value
=
paletteColour
HTML
.
strokeColorP
icker
.
value
=
paletteColour
HTML
.
labelColours
.
style
.
backgroundColor
=
paletteColour
strokeColour
=
paletteColour
hideElement
(
HTML
.
palette
)
...
...
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