Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
胡斌
/
liveAssistant_web_demo
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
胡斌
6 years ago
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
4cac5b6b57114b050ab8f10ffff356ba33f690a9
4cac5b6b
1 parent
649ad610
improve using line,draw arc at each end point
隐藏空白字符变更
内嵌
并排对比
正在显示
1 个修改的文件
包含
43 行增加
和
48 行删除
demo.html
demo.html
查看文件 @
4cac5b6
...
...
@@ -371,76 +371,71 @@
drawMouse
();
}
var
draw_method
=
0
;
function
Point
(
x
,
y
,
p
)
{
this
.
x
=
x
;
this
.
y
=
y
;
this
.
p
=
p
;
}
var
previousPoint
=
new
Point
(
0
,
0
,
0
),
currentPoint
=
new
Point
(
0
,
0
,
0
);
var
previousWidth
=
0
;
var
kWIDTH_MIN
=
0.2
;
var
kWIDTH_MAX
=
3.0
;
//current width
var
strokeWidth
=
3.0
;
var
rotate_degree
=
0
;
var
pressure_level
=
2048.0
-
1
;
var
draw_method
=
0
;
function
draw_method_change
(){
draw_method
=
document
.
getElementById
(
"draw_method"
).
selectedIndex
;
}
function
draw_ext_input
(
px
,
py
,
p
)
{
if
(
p
>
pressure_level
)
{
//something maybe wrong
return
;
}
if
(
draw_method
==
0
)
{
draw_ext_input_
arc
(
px
,
py
,
p
);
draw_ext_input_
dda
(
px
,
py
,
p
);
}
else
if
(
draw_method
==
1
)
{
draw_ext_input_line
(
px
,
py
,
p
);
}
}
var
last_ext_press
=
0
;
var
last_x
=
0
;
var
last_y
=
0
;
function
draw_ext_input_line
(
px
,
py
,
p
)
{
x
=
px
*
ratio_x
;
y
=
py
*
ratio_y
;
if
(
last_ext_press
==
0
){
function
draw_ext_input_line
(
px
,
py
,
p
)
{
if
(
currentPoint
.
p
==
0
){
if
(
p
!=
0
)
{
ctx
.
beginPath
();
ctx
.
lineWidth
=
(
kWIDTH_MAX
-
kWIDTH_MIN
)
/
pressure_level
*
p
+
kWIDTH_MIN
;
ctx
.
moveTo
(
x
,
y
);
ctx
.
lineTo
(
x
,
y
);
ctx
.
stroke
();
last_x
=
x
;
last_y
=
y
;
currentPoint
.
x
=
px
*
ratio_x
;
currentPoint
.
y
=
py
*
ratio_y
;
currentPoint
.
p
=
p
;
draw_point
(
currentPoint
);
}
}
else
if
(
p
!=
0
)
{
ctx
.
beginPath
();
ctx
.
lineWidth
=
(
kWIDTH_MAX
-
kWIDTH_MIN
)
/
pressure_level
*
p
+
kWIDTH_MIN
;
ctx
.
moveTo
(
last_x
,
last_y
);
ctx
.
lineTo
(
x
,
y
);
ctx
.
moveTo
(
currentPoint
.
x
,
currentPoint
.
y
);
ctx
.
lineWidth
=
previousWidth
;
currentPoint
.
x
=
px
*
ratio_x
;
currentPoint
.
y
=
py
*
ratio_y
;
ctx
.
lineTo
(
currentPoint
.
x
,
currentPoint
.
y
);
ctx
.
stroke
();
last_x
=
x
;
last_y
=
y
;
currentPoint
.
p
=
p
;
draw_point
(
currentPoint
);
}
else
{
ctx
.
beginPath
();
ctx
.
lineWidth
=
(
kWIDTH_MAX
-
kWIDTH_MIN
)
/
pressure_level
*
last_ext_press
+
kWIDTH_MIN
;
ctx
.
moveTo
(
last_x
,
last_y
);
ctx
.
lineTo
(
x
,
y
);
ctx
.
stroke
();
currentPoint
.
p
=
p
;
}
last_ext_press
=
p
;
}
function
Point
(
x
,
y
,
p
)
{
this
.
x
=
x
;
this
.
y
=
y
;
this
.
p
=
p
;
}
var
previousPoint
=
new
Point
(
0
,
0
,
0
),
currentPoint
=
new
Point
(
0
,
0
,
0
);
var
previousWidth
=
0
;
var
kWIDTH_MIN
=
0.2
;
var
kWIDTH_MAX
=
3.0
;
//current width
var
strokeWidth
=
3.0
;
var
rotate_degree
=
0
;
var
pressure_level
=
2048.0
-
1
;
function
draw_ext_input_arc
(
px
,
py
,
press
)
{
if
(
press
==
0
)
{
function
draw_ext_input_dda
(
px
,
py
,
p
)
{
if
(
p
==
0
)
{
previousPoint
.
p
=
0
;
}
else
{
...
...
@@ -450,7 +445,7 @@
currentPoint
.
x
=
px
*
ratio_x
;
currentPoint
.
y
=
py
*
ratio_y
;
currentPoint
.
p
=
p
ress
;
currentPoint
.
p
=
p
;
if
(
previousPoint
.
p
==
0
)
{
draw_point
(
currentPoint
);
...
...
@@ -469,7 +464,7 @@
$
(
"#line_width_slider"
).
slider
({
range
:
true
,
min
:
1
,
max
:
5
0
,
max
:
10
0
,
values
:
[
2
,
32
],
slide
:
function
(
event
,
ui
)
{
$
(
"#line_width"
).
val
(
ui
.
values
[
0
]
/
10.0
+
" - "
+
ui
.
values
[
1
]
/
10.0
);
...
...
@@ -2073,7 +2068,7 @@
<td><input
type=
"text"
id=
"line_width"
size=
"10"
readonly
style=
"border:0; color:#f6931f; font-weight:bold;"
/></td>
>
<td
colspan=
"2"
><select
id=
"pen_type"
name=
"pen_type"
><option
value =
"PendoTech"
>
PendoTech PH-1820-A
</option><option
value =
"robot"
>
Nebula T7
</option></select></td>
<td
colspan=
"2"
><select
id=
"draw_method"
name=
"draw_method"
onchange=
'javascript:draw_method_change();'
><option
value =
"use_arc"
>
use
arc
</option><option
value =
"use_line"
>
use line
</option></select></td>
<td
colspan=
"2"
><select
id=
"draw_method"
name=
"draw_method"
onchange=
'javascript:draw_method_change();'
><option
value =
"use_arc"
>
use
dda
</option><option
value =
"use_line"
>
use line
</option></select></td>
</tr>
</table>
</div>
...
...
请
注册
或
登录
后发表评论