vis_files/button.js
/// Draws a rectangle with rounded corners
Draws a rectangle with rounded corners
Draws a rectangle with rounded corners
function drawroundrect(x,y,dx,dy,r,col,col2)            
{
	var th, i, nth = Math.floor(r/2);
	if(nth < 1){
		cv.lineWidth = 1;	
		cv.beginPath();
		cv.beginPath();
		cv.moveTo(x+r,y);
		cv.lineTo(x+dx-r,y);
		cv.lineTo(x+dx,y+r);
		cv.lineTo(x+dx,y+dy-r);
		cv.lineTo(x+dx-r,y+dy);
		cv.lineTo(x+r,y+dy);
		cv.lineTo(x,y+dy-r);
		cv.lineTo(x,y+r);
		cv.closePath();
		cv.fillStyle = col; 
		cv.fill();
		cv.strokeStyle = col2;
		cv.stroke();
		return;
	}
	cv.lineWidth = 1;
	cv.beginPath();
	cv.moveTo(x+r,y);
	for(i = 0; i <= nth; i++){
		th = i*Math.PI/(2*nth);
		cv.lineTo(x+dx-r+r*Math.sin(th),y+r-r*Math.cos(th));
	}
	for(i = 0; i <= nth; i++){
		th = i*Math.PI/(2*nth);
		cv.lineTo(x+dx-r+r*Math.cos(th),y+dy-r+r*Math.sin(th));
	}
	for(i = 0; i <= nth; i++){
		th = i*Math.PI/(2*nth);
		cv.lineTo(x+r-r*Math.sin(th),y+dy-r+r*Math.cos(th));
	}
	for(i = 0; i <= nth; i++){
		th = i*Math.PI/(2*nth);
		cv.lineTo(x+r-r*Math.cos(th),y+r-r*Math.sin(th));
	}
	cv.closePath();
	cv.fillStyle = col; 
	cv.fill();
	cv.strokeStyle = col2;
	cv.stroke();
}
function drawroundrect ( x , y , dx , dy , r , col , col2 ) { var th , i , nth = Math . floor ( r / 2 ) ; if ( nth < 1 ) { cv . lineWidth = 1 ; cv . beginPath ( ) ; cv . beginPath ( ) ; cv . moveTo ( x + r , y ) ; cv . lineTo ( x + dx - r , y ) ; cv . lineTo ( x + dx , y + r ) ; cv . lineTo ( x + dx , y + dy - r ) ; cv . lineTo ( x + dx - r , y + dy ) ; cv . lineTo ( x + r , y + dy ) ; cv . lineTo ( x , y + dy - r ) ; cv . lineTo ( x , y + r ) ; cv . closePath ( ) ; cv . fillStyle = col ; cv . fill ( ) ; cv . strokeStyle = col2 ; cv . stroke ( ) ; return ; } cv . lineWidth = 1 ; cv . beginPath ( ) ; cv . moveTo ( x + r , y ) ; for ( i = 0 ; i <= nth ; i ++ ) { th = i * Math . PI / ( 2 * nth ) ; cv . lineTo ( x + dx - r + r * Math . sin ( th ) , y + r - r * Math . cos ( th ) ) ; } for ( i = 0 ; i <= nth ; i ++ ) { th = i * Math . PI / ( 2 * nth ) ; cv . lineTo ( x + dx - r + r * Math . cos ( th ) , y + dy - r + r * Math . sin ( th ) ) ; } for ( i = 0 ; i <= nth ; i ++ ) { th = i * Math . PI / ( 2 * nth ) ; cv . lineTo ( x + r - r * Math . sin ( th ) , y + dy - r + r * Math . cos ( th ) ) ; } for ( i = 0 ; i <= nth ; i ++ ) { th = i * Math . PI / ( 2 * nth ) ; cv . lineTo ( x + r - r * Math . cos ( th ) , y + r - r * Math . sin ( th ) ) ; } cv . closePath ( ) ; cv . fillStyle = col ; cv . fill ( ) ; cv . strokeStyle = col2 ; cv . stroke ( ) ; }
Draws a rectangle with rounded corners
Draws a rectangle with rounded corners