EN
Este contenido no se encuentra disponible en su idioma, pero aquí tiene la versión en inglés.

quadraticCurveTo method

Adds a point to the current subpath by using the specified control points that represent a quadratic Bézier curve.

HTML Canvas 2D Context, Section 9Internet Explorer 9

Syntax

CanvasRenderingContext2D.quadraticCurveTo(cp1x, cp1y, x, y);

Parameters

cp1x [in]

Type: number

The x-coordinate of the Bézier control point.

cp1y [in]

Type: number

The y-coordinate of the Bézier control point.

x [in]

Type: number

The x-coordinate of the point to add to the current path.

y [in]

Type: number

The y-coordinate of the point to add to the current path.

Return value

This method does not return a value.

Standards information

Remarks

A quadratic Bézier curve requires two points. The first point is a control point that is used in the quadratic Bézier calculation and the second point is the ending point for the curve. The starting point for the curve is the last point in the existing current subpath. If a path does not exist, use the beginPath and moveTo methods to set a starting point.

Examples

The following code example uses quadraticCurveTo to draw an arc.


<html>
<head>
    <title>QuadraticCurveTo example</title>
  <script type="text/javascript">
      function beginDemo() {
          var canvas = document.getElementById("demo")
          var ctx = canvas.getContext('2d');
          // Draw a straight reference line.
          ctx.beginPath();
          ctx.strokeStyle = "blue";
          ctx.moveTo(100, 100);
          ctx.lineTo(300, 100);
          ctx.stroke();
          // Draw a quadratic curve by using the same line coordinates.
          ctx.beginPath();
          ctx.lineWidth = "3";
          ctx.strokeStyle = "black";
          ctx.moveTo(100, 100);
          ctx.quadraticCurveTo(200, 300, 300, 100);
          ctx.stroke();
      }
          </script>
</head>
    <body onload="beginDemo();">
        <canvas id="demo" width="400" height="400"></canvas>
  </body>
</html>


See also

CanvasRenderingContext2D
bezierCurveTo

 

 

Mostrar:
© 2014 Microsoft