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
47ad7d8e
Commit
47ad7d8e
authored
5 years ago
by
Yuriy Maksymets
Browse files
Options
Downloads
Patches
Plain Diff
Drawing recognized upcoming before converting
parent
c6c41cab
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/app.js
+58
-31
58 additions, 31 deletions
src/app.js
src/room.js
+2
-1
2 additions, 1 deletion
src/room.js
with
60 additions
and
32 deletions
src/app.js
+
58
−
31
View file @
47ad7d8e
...
@@ -130,7 +130,7 @@ const onRoomConnect = (room_) => {
...
@@ -130,7 +130,7 @@ const onRoomConnect = (room_) => {
room
.
addEventListener
(
"
addOrUpdatePath
"
,
({
detail
:
{
id
,
points
}
})
=>
{
room
.
addEventListener
(
"
addOrUpdatePath
"
,
({
detail
:
{
id
,
points
}
})
=>
{
canvas
.
renderPath
(
id
,
points
,
room
.
erasureIntervals
)
canvas
.
renderPath
(
id
,
points
,
room
.
erasureIntervals
)
//
drawRecognized
(id,
points)
drawRecognized
Upcoming
(
points
)
})
})
room
.
addEventListener
(
room
.
addEventListener
(
...
@@ -145,35 +145,67 @@ const onRoomConnect = (room_) => {
...
@@ -145,35 +145,67 @@ const onRoomConnect = (room_) => {
)
)
}
}
const
mp
=
(
x
,
y
)
=>
[
x
,
y
,
1
,
"
black
"
]
const
mp
=
(
x
,
y
)
=>
[
x
,
y
,
1
,
"
#00000033
"
]
const
r
=
[]
function
drawRecognized
(
pathID
,
points
)
{
function
attributedPoint
(
x
,
y
,
pressure
=
0
)
{
if
(
r
.
includes
(
pathID
))
return
return
[
console
.
log
(
123
)
x
,
y
,
toolSelection
.
getStrokeRadius
()
*
getPressureFactor
(
pressure
),
toolSelection
.
getStrokeColour
(),
]
}
function
getRecognizedShapePoints
(
points
)
{
const
recognizedShape
=
recognizeFromPoints
(
points
)
const
recognizedShape
=
recognizeFromPoints
(
points
)
if
(
recognizedShape
.
shape
===
Shapes
.
line
)
{
if
(
recognizedShape
.
shape
===
Shapes
.
line
)
{
console
.
log
(
recognizedShape
)
console
.
log
(
recognizedShape
)
const
[
x
,
y
]
=
points
[
0
]
const
[
x
,
y
]
=
points
[
0
]
const
a
=
(
recognizedShape
.
angle
*
Math
.
PI
)
/
180
const
a
=
(
recognizedShape
.
angle
*
Math
.
PI
)
/
180
const
[
x0
,
y0
]
=
[
x
-
2000
*
Math
.
cos
(
a
),
y
+
2000
*
Math
.
sin
(
a
)]
const
p1
=
[
x
-
2000
*
Math
.
cos
(
a
),
y
+
2000
*
Math
.
sin
(
a
)]
const
[
x1
,
y1
]
=
[
x
+
2000
*
Math
.
cos
(
a
),
y
-
2000
*
Math
.
sin
(
a
)]
const
p2
=
[
x
+
2000
*
Math
.
cos
(
a
),
y
-
2000
*
Math
.
sin
(
a
)]
canvas
.
renderPath
(
"
lastRecognizedLine
"
,
[
mp
(
x0
,
y0
),
mp
(
x1
,
y1
)])
return
[
p1
,
p2
]
}
else
if
(
recognizedShape
.
shape
===
Shapes
.
rectangle
)
{
}
else
if
(
recognizedShape
.
shape
===
Shapes
.
rectangle
)
{
console
.
log
(
recognizedShape
)
console
.
log
(
recognizedShape
)
r
.
push
(
pathID
)
return
recognizedShape
.
boundingPoints
canvas
.
renderPath
(
}
"
lastRecognizedLine
"
,
return
undefined
recognizedShape
.
boundingPoints
.
map
((
x
)
=>
mp
(...
x
)),
}
)
room
.
setInvisible
(
pathID
)
const
LAST_RECOGNIZED_PATH_ID
=
"
LSP
"
recognizedShape
.
boundingPoints
.
forEach
((
point
)
=>
room
.
extendPath
(
pathID
,
mp
(...
point
)),
function
drawIfRecognized
(
points
,
callback
,
notRecCallback
)
{
)
const
recognizedPoints
=
getRecognizedShapePoints
(
points
)
if
(
recognizedPoints
)
{
callback
(
recognizedPoints
)
}
else
{
}
else
{
canvas
.
renderPath
(
"
lastRecognizedLine
"
,
[]
)
notRecCallback
(
)
}
}
}
}
function
clearRecognizedUpcoming
()
{
canvas
.
renderPath
(
LAST_RECOGNIZED_PATH_ID
,
[])
}
function
drawRecognizedUpcoming
(
points
)
{
drawIfRecognized
(
points
,
(
recognizedPoints
)
=>
canvas
.
renderPath
(
LAST_RECOGNIZED_PATH_ID
,
recognizedPoints
.
map
((
x
)
=>
mp
(...
x
)),
),
clearRecognizedUpcoming
,
)
}
function
drawRecognized
(
pathID
,
points
)
{
drawIfRecognized
(
points
,
(
newPoints
)
=>
room
.
replacePath
(
pathID
,
newPoints
.
map
((
x
)
=>
attributedPoint
(...
x
))),
)
clearRecognizedUpcoming
()
}
const
tryRoomConnect
=
async
(
roomID
)
=>
{
const
tryRoomConnect
=
async
(
roomID
)
=>
{
return
await
connect
(
roomID
)
return
await
connect
(
roomID
)
.
then
(
onRoomConnect
)
.
then
(
onRoomConnect
)
...
@@ -269,10 +301,10 @@ const updateOverallStatusIcon = () => {
...
@@ -269,10 +301,10 @@ const updateOverallStatusIcon = () => {
canvas
.
input
.
addEventListener
(
"
strokestart
"
,
({
detail
:
e
})
=>
{
canvas
.
input
.
addEventListener
(
"
strokestart
"
,
({
detail
:
e
})
=>
{
e
.
preventDefault
()
e
.
preventDefault
()
clearRecognizedUpcoming
()
if
(
room
==
null
)
{
if
(
room
==
null
)
{
return
return
}
}
console
.
log
(
pathIDsByPointerID
)
const
currentTool
=
toolSelection
.
getTool
()
const
currentTool
=
toolSelection
.
getTool
()
const
mousePos
=
[
e
.
offsetX
,
e
.
offsetY
]
const
mousePos
=
[
e
.
offsetX
,
e
.
offsetY
]
if
(
currentTool
==
toolSelection
.
Tools
.
PEN
)
{
if
(
currentTool
==
toolSelection
.
Tools
.
PEN
)
{
...
@@ -295,13 +327,10 @@ canvas.input.addEventListener("strokestart", ({ detail: e }) => {
...
@@ -295,13 +327,10 @@ canvas.input.addEventListener("strokestart", ({ detail: e }) => {
})
})
canvas
.
input
.
addEventListener
(
"
strokeend
"
,
({
detail
:
e
})
=>
{
canvas
.
input
.
addEventListener
(
"
strokeend
"
,
({
detail
:
e
})
=>
{
console
.
log
(
12331
)
console
.
log
(
12331
)
console
.
log
(
12331
)
const
pathID
=
pathIDsByPointerID
.
get
(
e
.
pointerId
)
const
pathID
=
pathIDsByPointerID
.
get
(
e
.
pointerId
)
drawRecognized
(
pathID
,
room
.
getPoints
(
pathID
))
drawRecognized
(
pathID
,
room
.
getPoints
(
pathID
))
//pathIDsByPointerID.delete(e.pointerId)
pathIDsByPointerID
.
delete
(
e
.
pointerId
)
clearRecognizedUpcoming
()
})
})
canvas
.
input
.
addEventListener
(
"
strokemove
"
,
({
detail
:
e
})
=>
{
canvas
.
input
.
addEventListener
(
"
strokemove
"
,
({
detail
:
e
})
=>
{
...
@@ -311,12 +340,10 @@ canvas.input.addEventListener("strokemove", ({ detail: e }) => {
...
@@ -311,12 +340,10 @@ canvas.input.addEventListener("strokemove", ({ detail: e }) => {
const
currentTool
=
toolSelection
.
getTool
()
const
currentTool
=
toolSelection
.
getTool
()
const
mousePos
=
[
e
.
offsetX
,
e
.
offsetY
]
const
mousePos
=
[
e
.
offsetX
,
e
.
offsetY
]
if
(
currentTool
==
toolSelection
.
Tools
.
PEN
)
{
if
(
currentTool
==
toolSelection
.
Tools
.
PEN
)
{
console
.
log
(
pathIDsByPointerID
.
get
(
e
.
pointerId
))
room
.
extendPath
(
room
.
extendPath
(
pathIDsByPointerID
.
get
(
e
.
pointerId
),
[
pathIDsByPointerID
.
get
(
e
.
pointerId
),
...
mousePos
,
attributedPoint
(...
mousePos
,
e
.
pressure
),
toolSelection
.
getStrokeRadius
()
*
getPressureFactor
(
e
.
pressure
),
)
toolSelection
.
getStrokeColour
(),
])
}
else
if
(
currentTool
==
toolSelection
.
Tools
.
ERASER
)
{
}
else
if
(
currentTool
==
toolSelection
.
Tools
.
ERASER
)
{
eraseEverythingAtPosition
(
eraseEverythingAtPosition
(
mousePos
[
0
],
mousePos
[
0
],
...
...
This diff is collapsed.
Click to expand it.
src/room.js
+
2
−
1
View file @
47ad7d8e
...
@@ -63,7 +63,7 @@ class Room extends EventTarget {
...
@@ -63,7 +63,7 @@ class Room extends EventTarget {
})
})
}
}
setInvisible
(
pathID
)
{
replacePath
(
pathID
,
newPoints
)
{
const
self
=
this
const
self
=
this
// eslint-disable-next-line require-yield
// eslint-disable-next-line require-yield
...
@@ -77,6 +77,7 @@ class Room extends EventTarget {
...
@@ -77,6 +77,7 @@ class Room extends EventTarget {
return
return
}
}
newPoints
.
forEach
((
point
)
=>
self
.
extendPath
(
pathID
,
point
))
self
.
shared
.
eraseIntervals
.
set
(
pathID
,
postJSON
)
self
.
shared
.
eraseIntervals
.
set
(
pathID
,
postJSON
)
})
})
}
}
...
...
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