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
289ac9dd
Commit
289ac9dd
authored
5 years ago
by
Yuriy Maksymets
Browse files
Options
Downloads
Patches
Plain Diff
Recognition refactoing
parent
47ad7d8e
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
+22
-14
22 additions, 14 deletions
src/app.js
src/room.js
+2
-1
2 additions, 1 deletion
src/room.js
with
24 additions
and
15 deletions
src/app.js
+
22
−
14
View file @
289ac9dd
...
@@ -145,7 +145,9 @@ const onRoomConnect = (room_) => {
...
@@ -145,7 +145,9 @@ const onRoomConnect = (room_) => {
)
)
}
}
const
mp
=
(
x
,
y
)
=>
[
x
,
y
,
1
,
"
#00000033
"
]
function
faintPoint
(
x
,
y
)
{
return
[
x
,
y
,
1
,
"
#00000033
"
]
}
function
attributedPoint
(
x
,
y
,
pressure
=
0
)
{
function
attributedPoint
(
x
,
y
,
pressure
=
0
)
{
return
[
return
[
...
@@ -156,24 +158,28 @@ function attributedPoint(x, y, pressure = 0) {
...
@@ -156,24 +158,28 @@ function attributedPoint(x, y, pressure = 0) {
]
]
}
}
const
INF_LINE_OFFSET
=
2000
function
getRecognizedShapePoints
(
points
)
{
function
getRecognizedShapePoints
(
points
)
{
const
recognizedShape
=
recognizeFromPoints
(
points
)
const
recognizedShape
=
recognizeFromPoints
(
points
)
if
(
recognizedShape
.
shape
===
Shapes
.
line
)
{
if
(
!
recognizedShape
.
shape
)
return
undefined
console
.
log
(
recognizedShape
)
switch
(
recognizedShape
.
shape
)
{
const
[
x
,
y
]
=
points
[
0
]
case
Shapes
.
line
:
{
const
a
=
(
recognizedShape
.
angle
*
Math
.
PI
)
/
180
const
[
x
,
y
]
=
points
[
0
]
const
p1
=
[
x
-
2000
*
Math
.
cos
(
a
),
y
+
2000
*
Math
.
sin
(
a
)]
const
a
=
(
recognizedShape
.
angle
*
Math
.
PI
)
/
180
const
p2
=
[
x
+
2000
*
Math
.
cos
(
a
),
y
-
2000
*
Math
.
sin
(
a
)]
const
dx
=
INF_LINE_OFFSET
*
Math
.
cos
(
a
)
return
[
p1
,
p2
]
const
dy
=
INF_LINE_OFFSET
*
Math
.
sin
(
a
)
}
else
if
(
recognizedShape
.
shape
===
Shapes
.
rectangle
)
{
const
p1
=
[
x
-
dx
,
y
+
dy
]
console
.
log
(
recognizedShape
)
const
p2
=
[
x
+
dx
,
y
-
dy
]
return
recognizedShape
.
boundingPoints
return
[
p1
,
p2
]
}
case
Shapes
.
rectangle
:
{
return
recognizedShape
.
boundingPoints
}
}
}
return
undefined
return
undefined
}
}
const
LAST_RECOGNIZED_PATH_ID
=
"
LSP
"
function
drawIfRecognized
(
points
,
callback
,
notRecCallback
)
{
function
drawIfRecognized
(
points
,
callback
,
notRecCallback
)
{
const
recognizedPoints
=
getRecognizedShapePoints
(
points
)
const
recognizedPoints
=
getRecognizedShapePoints
(
points
)
if
(
recognizedPoints
)
{
if
(
recognizedPoints
)
{
...
@@ -183,6 +189,8 @@ function drawIfRecognized(points, callback, notRecCallback) {
...
@@ -183,6 +189,8 @@ function drawIfRecognized(points, callback, notRecCallback) {
}
}
}
}
const
LAST_RECOGNIZED_PATH_ID
=
"
LSP
"
function
clearRecognizedUpcoming
()
{
function
clearRecognizedUpcoming
()
{
canvas
.
renderPath
(
LAST_RECOGNIZED_PATH_ID
,
[])
canvas
.
renderPath
(
LAST_RECOGNIZED_PATH_ID
,
[])
}
}
...
@@ -193,7 +201,7 @@ function drawRecognizedUpcoming(points) {
...
@@ -193,7 +201,7 @@ function drawRecognizedUpcoming(points) {
(
recognizedPoints
)
=>
(
recognizedPoints
)
=>
canvas
.
renderPath
(
canvas
.
renderPath
(
LAST_RECOGNIZED_PATH_ID
,
LAST_RECOGNIZED_PATH_ID
,
recognizedPoints
.
map
((
x
)
=>
mp
(...
x
)),
recognizedPoints
.
map
((
x
)
=>
faintPoint
(...
x
)),
),
),
clearRecognizedUpcoming
,
clearRecognizedUpcoming
,
)
)
...
...
This diff is collapsed.
Click to expand it.
src/room.js
+
2
−
1
View file @
289ac9dd
...
@@ -54,7 +54,7 @@ class Room extends EventTarget {
...
@@ -54,7 +54,7 @@ class Room extends EventTarget {
[
flattenErasureIntervals
({
[
pointID
]:
newIntervals
})],
[
flattenErasureIntervals
({
[
pointID
]:
newIntervals
})],
)[
0
]
)[
0
]
const
postJSON
=
JSON
.
stringify
(
combinedIntervals
)
const
postJSON
=
JSON
.
stringify
(
combinedIntervals
)
console
.
log
(
postJSON
)
if
(
prevJSON
==
postJSON
)
{
if
(
prevJSON
==
postJSON
)
{
return
return
}
}
...
@@ -63,6 +63,7 @@ class Room extends EventTarget {
...
@@ -63,6 +63,7 @@ class Room extends EventTarget {
})
})
}
}
// TODO: Refactor duplication
replacePath
(
pathID
,
newPoints
)
{
replacePath
(
pathID
,
newPoints
)
{
const
self
=
this
const
self
=
this
...
...
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