function bezier(position){

  context.strokeStyle = attribute.color;
  context.lineJoin = context.lineCap = 'round';  
  context.fillStyle = attribute.color;
  context.lineWidth = attribute.width;
  function midPointBtw(p1, p2) {
    return {
      x: p1.x + (p2.x - p1.x) / 2,
      y: p1.y + (p2.y - p1.y) / 2
      };
    }  
  points.push({ x: position.x, y: position.y });
  context.fillStyle = 'white';
  context.fillRect(0,0,canvas.width,canvas.height);
  var p1 = points[0];
  var p2 = points[1];
  context.beginPath();
  context.moveTo(p1.x, p1.y);
  for (var i = 1, len = points.length; i < len; i++) {
      var midPoint = midPointBtw(p1, p2);
      context.quadraticCurveTo(p1.x, p1.y, midPoint.x, midPoint.y);
      p1 = points[i];
      p2 = points[i+1];
  }
  context.lineTo(p1.x, p1.y);
  context.stroke();
  }
//using quadratic curves to make sharp edges smooth
using quadratic curves to make sharp edges smooth
using quadratic curves to make sharp edges smooth
function bezier(position){
  context.strokeStyle = attribute.color;
  context.lineJoin = context.lineCap = 'round';  
  context.fillStyle = attribute.color;
  context.lineWidth = attribute.width;
  function midPointBtw(p1, p2) {
    return {
      x: p1.x + (p2.x - p1.x) / 2,
      y: p1.y + (p2.y - p1.y) / 2
      };
    }  
  points.push({ x: position.x, y: position.y });
  context.fillStyle = 'white';
  context.fillRect(0,0,canvas.width,canvas.height);
  var p1 = points[0];
  var p2 = points[1];
  context.beginPath();
  context.moveTo(p1.x, p1.y);
  for (var i = 1, len = points.length; i < len; i++) {
      var midPoint = midPointBtw(p1, p2);
      context.quadraticCurveTo(p1.x, p1.y, midPoint.x, midPoint.y);
      p1 = points[i];
      p2 = points[i+1];
  }
  context.lineTo(p1.x, p1.y);
  context.stroke();
  }
function bezier ( position ) { context . strokeStyle = attribute . color ; context . lineJoin = context . lineCap = 'round' ; context . fillStyle = attribute . color ; context . lineWidth = attribute . width ; function midPointBtw ( p1 , p2 ) { return { x : p1 . x + ( p2 . x - p1 . x ) / 2 , y : p1 . y + ( p2 . y - p1 . y ) / 2 } ; } points . push ( { x : position . x , y : position . y } ) ; context . fillStyle = 'white' ; context . fillRect ( 0 , 0 , canvas . width , canvas . height ) ; var p1 = points [ 0 ] ; var p2 = points [ 1 ] ; context . beginPath ( ) ; context . moveTo ( p1 . x , p1 . y ) ; for ( var i = 1 , len = points . length ; i < len ; i ++ ) { var midPoint = midPointBtw ( p1 , p2 ) ; context . quadraticCurveTo ( p1 . x , p1 . y , midPoint . x , midPoint . y ) ; p1 = points [ i ] ; p2 = points [ i + 1 ] ; } context . lineTo ( p1 . x , p1 . y ) ; context . stroke ( ) ; }
using quadratic curves to make sharp edges smooth
using quadratic curves to make sharp edges smooth