2024年5月6日发(作者:)
var lineWidth = calcLineWidth( t , s );
//draw
ath();
( lastLoc.x , lastLoc.y );
( curLoc.x , curLoc.y );
Style = strokeColor;
dth = lineWidth;
p = "round";
in = "round";
();
lastLoc = curLoc;
lastTimestamp = curTimestamp;
lastLineWidth = lineWidth;
}
edown = function(e){
tDefault();
beginStroke( {x: X , y: Y} );
};
eup = function(e){
tDefault();
endStroke();
};
eout = function(e){
tDefault();
endStroke();
};
emove = function(e){
tDefault();
if( isMouseDown ){
moveStroke({x: X , y: Y})
}
};
ntListener('touchstart',function(e){
tDefault();
touch = s[0];
beginStroke( {x: , y: } )
});
ntListener('touchmove',function(e){
tDefault();
if( isMouseDown ){
touch = s[0];
moveStroke({x: , y: });
}
});
ntListener('touchend',function(e){
tDefault();
endStroke();
});
var maxLineWidth = 30;
var minLineWidth = 1;
var maxStrokeV = 10;
var minStrokeV = 0.1;
function calcLineWidth( t , s ){
var v = s / t;
var resultLineWidth;
if( v <= minStrokeV )
resultLineWidth = maxLineWidth;
else if ( v >= maxStrokeV )
resultLineWidth = minLineWidth;
else{
resultLineWidth = maxLineWidth - (v-minStrokeV)/(maxStrokeV-minStrokeV)*(maxLineWidth-minLineWidth);
}
if( lastLineWidth == -1 )
return resultLineWidth;
return resultLineWidth*1/3 + lastLineWidth*2/3;
}
function calcDistance( loc1 , loc2 ){
return ( (loc1.x - loc2.x)*(loc1.x - loc2.x) + (loc1.y - loc2.y)*(loc1.y - loc2.y) );
}


发布评论