胡斌

add slider to select pen width,improve rotate

正在显示 1 个修改的文件 包含 49 行增加13 行删除
@@ -25,7 +25,9 @@ @@ -25,7 +25,9 @@
25 <title>LiveAssistant Demo</title> 25 <title>LiveAssistant Demo</title>
26 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 26 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
27 <link rel="stylesheet" href="./jqx/styles/jqx.base.css" type="text/css" /> 27 <link rel="stylesheet" href="./jqx/styles/jqx.base.css" type="text/css" />
  28 + <link rel="stylesheet" href="./jqx/styles/jquery-ui.css"/>
28 <script type="text/javascript" src="./jqx/jquery-1.11.1.min.js"></script> 29 <script type="text/javascript" src="./jqx/jquery-1.11.1.min.js"></script>
  30 + <script type="text/javascript" src="./jqx/jquery-ui.min.js"></script>
29 <script type="text/javascript" src="./jqx/jqxcore.js"></script> 31 <script type="text/javascript" src="./jqx/jqxcore.js"></script>
30 <script type="text/javascript" src="./jqx/jqxtabs.js"></script> 32 <script type="text/javascript" src="./jqx/jqxtabs.js"></script>
31 <style type="text/css"> 33 <style type="text/css">
@@ -419,6 +421,22 @@ @@ -419,6 +421,22 @@
419 var rotate_degree = 0; 421 var rotate_degree = 0;
420 var pressure_level = 2048.0; 422 var pressure_level = 2048.0;
421 423
  424 + $( function() {
  425 + $( "#line_width_slider" ).slider({
  426 + range: true,
  427 + min: 1,
  428 + max: 50,
  429 + values: [ 2, 32 ],
  430 + slide: function( event, ui ) {
  431 + $( "#line_width" ).val( ui.values[ 0 ] /10.0+ " - " + ui.values[ 1 ] /10.0);
  432 + kWIDTH_MIN = ui.values[ 0 ] /10.0;
  433 + kWIDTH_MAX = ui.values[ 1 ] /10.0;
  434 + }
  435 + });
  436 + $( "#line_width" ).val( $( "#line_width_slider" ).slider( "values", 0 )/10.0 +
  437 + " - " + $( "#line_width_slider" ).slider( "values", 1 )/10.0 );
  438 + } );
  439 +
422 440
423 function setStrokeWidth(strokeWidth) { 441 function setStrokeWidth(strokeWidth) {
424 strokeWidth = strokeWidth; 442 strokeWidth = strokeWidth;
@@ -485,7 +503,7 @@ @@ -485,7 +503,7 @@
485 function onTouchDownEvent(x, y, p) { 503 function onTouchDownEvent(x, y, p) {
486 previousPoint = null; 504 previousPoint = null;
487 currentPoint = null; 505 currentPoint = null;
488 - currentPoint = new Point(x, y, p); 506 + currentPoint = new Point(x, y, 0);
489 previousPoint = currentPoint; 507 previousPoint = currentPoint;
490 } 508 }
491 509
@@ -569,6 +587,7 @@ @@ -569,6 +587,7 @@
569 var start = function (e) { 587 var start = function (e) {
570 clicked = 1; 588 clicked = 1;
571 ctx.beginPath(); 589 ctx.beginPath();
  590 + ctx.lineWidth = kWIDTH_MIN;
572 x = e.pageX; 591 x = e.pageX;
573 y = e.pageY - voffset; 592 y = e.pageY - voffset;
574 ctx.moveTo(x, y); 593 ctx.moveTo(x, y);
@@ -1339,19 +1358,19 @@ @@ -1339,19 +1358,19 @@
1339 rotate_degree = 0; 1358 rotate_degree = 0;
1340 } 1359 }
1341 1360
1342 - if (rotate_degree == 0 || rotate_gree == 180) {  
1343 - var w = ext_input_panel_height * 1.0;  
1344 - var h = ext_input_panel_width * 1.0; 1361 + if (rotate_degree == 0 || rotate_degree == 180) {
  1362 + var w = ext_input_panel_width * 1.0;
  1363 + var h = ext_input_panel_height * 1.0;
1345 var canvasw = w / h * canvas_height; 1364 var canvasw = w / h * canvas_height;
1346 ratio_x = (canvasw + 0.0) / w; 1365 ratio_x = (canvasw + 0.0) / w;
1347 ratio_y = (canvas_height + 0.0) / h; 1366 ratio_y = (canvas_height + 0.0) / h;
1348 } 1367 }
1349 else { 1368 else {
1350 - var w = ext_input_panel_width * 1.0;  
1351 - var h = ext_input_panel_height * 1.0; 1369 + var w = ext_input_panel_height * 1.0;
  1370 + var h = ext_input_panel_width * 1.0;
1352 var canvasw = w / h * canvas_height; 1371 var canvasw = w / h * canvas_height;
1353 - ratio_x = (canvasw + 0.0) / ext_input_panel_width;  
1354 - ratio_y = (canvas_height + 0.0) / ext_input_panel_height; 1372 + ratio_x = (canvasw + 0.0) / w;
  1373 + ratio_y = (canvas_height + 0.0) / h;
1355 } 1374 }
1356 1375
1357 return; 1376 return;
@@ -1942,10 +1961,9 @@ @@ -1942,10 +1961,9 @@
1942 </td><td ><div style="height:600px; overflow:scroll;"><div id="output" /></div></td> </tr> 1961 </td><td ><div style="height:600px; overflow:scroll;"><div id="output" /></div></td> </tr>
1943 </table> 1962 </table>
1944 </div> 1963 </div>
1945 - <div>  
1946 <div id="page"> 1964 <div id="page">
1947 <div class="header"> 1965 <div class="header">
1948 - <select id="pen_type" name="pen_type"><option value ="PendoTech">PendoTech PH-1820-A</option><option value ="robot">Nebula T7</option></select> 1966 +
1949 <a id="new" class="navbtn" onclick="newCanvas()">New</a> 1967 <a id="new" class="navbtn" onclick="newCanvas()">New</a>
1950 <a id="open_ext_input" class="navbtn" onclick="onTestClick(this)">open_ext_input</a> 1968 <a id="open_ext_input" class="navbtn" onclick="onTestClick(this)">open_ext_input</a>
1951 <a id="close_ext_input" class="navbtn" onclick="onTestClick(this)">close_ext_input</a> 1969 <a id="close_ext_input" class="navbtn" onclick="onTestClick(this)">close_ext_input</a>
@@ -1967,12 +1985,30 @@ @@ -1967,12 +1985,30 @@
1967 <div class="palette-box"> 1985 <div class="palette-box">
1968 <div class="palette black" onclick="selectColor(this)"></div> 1986 <div class="palette black" onclick="selectColor(this)"></div>
1969 </div> 1987 </div>
1970 - </div> 1988 +
  1989 +
  1990 + <table width = "500" align="top">
  1991 + <tr>
  1992 + <td><label for="line_width" style="color:#a3bd97;">line width:</label></td>
  1993 + <td>
  1994 + <table width = "100">
  1995 + <tr>
  1996 + <td id="line_width_slider"></td>
  1997 + </tr>
  1998 + </table>
  1999 + </td>
  2000 +
  2001 + <td><input type="text" id="line_width" size="10" readonly style="border:0; color:#f6931f; font-weight:bold;"/></td>>
  2002 +
  2003 + <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>
  2004 + </tr>
  2005 + </table>
  2006 + </div>
  2007 +
1971 <div id="content"> 2008 <div id="content">
1972 <p style="text-align:center">Loading Canvas...</p> 2009 <p style="text-align:center">Loading Canvas...</p>
1973 </div> 2010 </div>
1974 - </div>  
1975 - </div> 2011 + </div>
1976 <div> 2012 <div>
1977 <table> 2013 <table>
1978 <tr> 2014 <tr>