Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PET-rating
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
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
Timo Heikkilä
PET-rating
Commits
246a59fd
Commit
246a59fd
authored
5 years ago
by
Ossi Laine
Browse files
Options
Downloads
Patches
Plain Diff
Set mouse pointer to crosshair on canvas
parent
9ec0c142
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/static/css/main.css
+3
-1
3 additions, 1 deletion
app/static/css/main.css
app/static/js/canvas.js
+11
-8
11 additions, 8 deletions
app/static/js/canvas.js
app/task/templates/task.html
+1
-1
1 addition, 1 deletion
app/task/templates/task.html
with
15 additions
and
10 deletions
app/static/css/main.css
+
3
−
1
View file @
246a59fd
...
@@ -22,4 +22,6 @@ body {
...
@@ -22,4 +22,6 @@ body {
.clear-button
{
.clear-button
{
margin
:
10px
;
margin
:
10px
;
}
}
\ No newline at end of file
.crosshair
{
cursor
:
crosshair
;}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
app/static/js/canvas.js
+
11
−
8
View file @
246a59fd
...
@@ -6,6 +6,7 @@ $(document).ready(function() {
...
@@ -6,6 +6,7 @@ $(document).ready(function() {
try
{
try
{
var
canvas
=
$
(
"
#embody-canvas
"
)
var
canvas
=
$
(
"
#embody-canvas
"
)
var
canvasInfo
=
$
(
"
.canvas-info
"
)
var
context
=
document
.
getElementById
(
"
embody-canvas
"
).
getContext
(
"
2d
"
);
var
context
=
document
.
getElementById
(
"
embody-canvas
"
).
getContext
(
"
2d
"
);
var
img
=
document
.
getElementById
(
"
baseImage
"
);
var
img
=
document
.
getElementById
(
"
baseImage
"
);
...
@@ -43,9 +44,10 @@ $(document).ready(function() {
...
@@ -43,9 +44,10 @@ $(document).ready(function() {
// TODO: if mousedown -> can draw outside of image
// TODO: if mousedown -> can draw outside of image
var
mouseX
=
e
.
pageX
-
this
.
offsetLeft
;
var
mouseX
=
e
.
pageX
-
this
.
offsetLeft
;
var
mouseY
=
e
.
pageY
-
this
.
offsetTop
;
var
mouseY
=
e
.
pageY
-
this
.
offsetTop
;
if
(
paint
&&
pointInsideBaseImage
([
mouseX
,
mouseY
])){
addClick
(
mouseX
,
mouseY
,
true
);
if
(
paint
&&
pointInsideBaseImage
([
mouseX
,
mouseY
])){
redraw
();
addClick
(
mouseX
,
mouseY
,
true
);
redraw
();
}
}
});
});
...
@@ -57,11 +59,12 @@ $(document).ready(function() {
...
@@ -57,11 +59,12 @@ $(document).ready(function() {
paint
=
false
;
paint
=
false
;
});
});
// TODO: changing drawradius doesnt affect to the saved datapoints !!!
// TODO: changing drawradius doesnt affect to the saved datapoints !!!
// Bigger brush should make more datapoints compared to smaller ones.
// Bigger brush should make more datapoints compared to smaller ones.
// add brush size to click arry -> {x:[...], y:[...], size:[...]} ??
// add brush size to click arry -> {x:[...], y:[...], size:[...]} ??
$
(
"
.canvas-container
"
).
bind
(
'
DOMMouseScroll
'
,
changeBrushSize
)
$
(
"
#embody-canvas
"
).
bind
(
'
DOMMouseScroll
'
,
changeBrushSize
)
// DOMMouseScroll is only for firefox
// DOMMouseScroll is only for firefox
//$(".canvas-container").bind('wheel', changeBrushSize)
//$(".canvas-container").bind('wheel', changeBrushSize)
...
@@ -81,11 +84,11 @@ $(document).ready(function() {
...
@@ -81,11 +84,11 @@ $(document).ready(function() {
// Show brush size to user
// Show brush size to user
if
(
drawRadius
==
10
)
{
if
(
drawRadius
==
10
)
{
this
.
firstElementChild
.
innerHTML
=
"
small brush
"
canvasInfo
.
html
(
"
small brush
"
)
}
else
if
(
drawRadius
==
15
)
{
}
else
if
(
drawRadius
==
15
)
{
this
.
firstElementChild
.
innerHTML
=
"
normal brush
"
canvasInfo
.
html
(
"
normal brush
"
)
}
else
if
(
drawRadius
==
20
)
{
}
else
if
(
drawRadius
==
20
)
{
this
.
firstElementChild
.
innerHTML
=
"
large brush
"
canvasInfo
.
html
(
"
large brush
"
)
}
}
}
}
...
@@ -123,7 +126,7 @@ $(document).ready(function() {
...
@@ -123,7 +126,7 @@ $(document).ready(function() {
startG
=
imageData
.
data
[
1
];
startG
=
imageData
.
data
[
1
];
startB
=
imageData
.
data
[
2
];
startB
=
imageData
.
data
[
2
];
return
(
isWhite
(
startB
)
&&
isWhite
(
startG
)
&&
isWhite
(
startR
))
?
true
:
fals
e
;
return
(
isWhite
(
startB
)
&&
isWhite
(
startG
)
&&
isWhite
(
startR
))
?
false
:
tru
e
;
}
}
function
redraw
()
{
function
redraw
()
{
...
...
This diff is collapsed.
Click to expand it.
app/task/templates/task.html
+
1
−
1
View file @
246a59fd
...
@@ -100,7 +100,7 @@
...
@@ -100,7 +100,7 @@
<div
class=
"canvas-container"
>
<div
class=
"canvas-container"
>
<span
class=
"canvas-info"
></span>
<span
class=
"canvas-info"
></span>
<canvas
id=
"embody-canvas"
width=
"20"
height=
"20"
style=
"border: 1px solid blue;"
></canvas>
<canvas
id=
"embody-canvas"
class=
"crosshair"
width=
"20"
height=
"20"
style=
"border: 1px solid blue;"
></canvas>
</div>
</div>
<img
id=
"baseImage"
class=
""
src=
{{
url_for
('
static
',
filename=
'img/dummy_600.png'
)
}}
/>
<img
id=
"baseImage"
class=
""
src=
{{
url_for
('
static
',
filename=
'img/dummy_600.png'
)
}}
/>
...
...
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