胡斌

add method use line to compare with use arc

正在显示 1 个修改的文件 包含 61 行增加17 行删除
... ... @@ -371,25 +371,58 @@
drawMouse();
}
var draw_method = 0;
function draw_method_change(){
draw_method = document.getElementById("draw_method").selectedIndex;
}
function draw_ext_input(px,py,p) {
if(draw_method == 0) {
draw_ext_input_arc(px,py,p);
}
else if(draw_method == 1) {
draw_ext_input_line(px,py,p);
}
}
/*
var last_ext_press = 0;
function draw_ext_input(px,py,press) {
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 && press != 0){
if(last_ext_press == 0){
if (p != 0) {
ctx.beginPath();
ctx.lineWidth = (kWIDTH_MAX - kWIDTH_MIN) / pressure_level * p + kWIDTH_MIN;
ctx.moveTo(x, y);
last_ext_press = 1;
ctx.lineTo(x, y);
ctx.stroke();
last_x = x;
last_y = y;
}
}
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.stroke();
last_x = x;
last_y = y;
}
else if(press != 0) {
var line_width = (kWIDTH_MAX - kWIDTH_MIN)/pressure_level * p + kWIDTH_MIN;
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();
}
last_ext_press = press;
}*/
last_ext_press = p;
}
function Point(x , y, p) {
this.x = x;
this.y = y;
... ... @@ -406,13 +439,17 @@
var rotate_degree = 0;
var pressure_level = 2048.0 - 1;
function draw_ext_input(px, py, press) {
function draw_ext_input_arc(px, py, press) {
if(press == 0) {
previousPoint.p = 0;
}
else {
currentPoint.x = Math.round( px * ratio_x);
currentPoint.y = Math.round( py * ratio_y);
//currentPoint.x = Math.round( px * ratio_x);
//currentPoint.y = Math.round( py * ratio_y);
currentPoint.x = px * ratio_x;
currentPoint.y = py * ratio_y;
currentPoint.p = press;
if(previousPoint.p == 0) {
... ... @@ -455,7 +492,8 @@
function draw_point(pt){
var line_width = (kWIDTH_MAX - kWIDTH_MIN)/pressure_level * pt.p + kWIDTH_MIN;
ctx.beginPath(); //Start path
ctx.arc(pt.x, pt.y, line_width, 0, Math.PI * 2, true); // Draw a point using the arc function of the canvas with a point structure.
ctx.lineWidth = 0.1;
ctx.arc(pt.x, pt.y, line_width/2, 0, Math.PI * 2, true); // Draw a point using the arc function of the canvas with a point structure.
ctx.fill();
previousWidth = line_width;
}
... ... @@ -506,16 +544,21 @@
while (times > 0) {
times = times - 1;
ctx.lineWidth = w;
ctx.beginPath(); //Start path
ctx.arc(x, y, w, 0, Math.PI * 2, true); // Draw a point using the arc function of the canvas with a point structure.
if(w < kWIDTH_MIN) {
w = kWIDTH_MIN;
}
ctx.arc(x, y, w /2, 0, Math.PI * 2, true); // Draw a point using the arc function of the canvas with a point structure.
ctx.fill();
x += stepx;
y += stepy;
w += stepw;
}
ctx.beginPath(); //Start path
ctx.arc(pt.x, pt.y, w1 /2, 0, Math.PI * 2, true); // Draw a point using the arc function of the canvas with a point structure.
ctx.fill();
previousWidth = w1;
}
... ... @@ -2016,7 +2059,7 @@
</div>
<table width = "500" align="top">
<table width = "600" align="top">
<tr>
<td><label for="line_width" style="color:#a3bd97;">line width:</label></td>
<td>
... ... @@ -2030,6 +2073,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>
</tr>
</table>
</div>
... ...