--- title: CanvasRenderingContext2D.quadraticCurveTo() slug: Web/API/CanvasRenderingContext2D/quadraticCurveTo translation_of: Web/API/CanvasRenderingContext2D/quadraticCurveTo ---
{{APIRef}}

o método CanvasRenderingContext2D.quadraticCurveTo() da API Canvas 2D adiciona uma Curva de Bézier quadrática ao caminho. São exigidos dois pontos. O primeiro ponto é um ponto de controle e o segundo é o ponto final. The starting point is the last point in the current path, which can be changed using moveTo() before creating the quadratic Bézier curve.

Sintaxe

void ctx.quadraticCurveTo(cpx, cpy, x, y);

Parâmetros

cpx
O eixo X da coordenada para o ponto de controle.
cpy
O eixo Y da coordenada para o ponto de controle.
x
O eixo X da coordenada para o ponto final.
y
O eixo Y da coordenada para o ponto final.

Exemplos

Usando o método quadraticCurveTo

This is just a simple code snippet drawing a quadratic bezier curve. The control point is red and the start and end points are blue.

HTML

<canvas id="canvas"></canvas>

JavaScript

var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');

ctx.beginPath();
ctx.moveTo(50,20);
ctx.quadraticCurveTo(230, 30, 50, 100);
ctx.stroke();

ctx.fillStyle = 'blue';
// start point
ctx.fillRect(50, 20, 10, 10);
// end point
ctx.fillRect(50, 100, 10, 10);

ctx.fillStyle = 'red';
// control point
ctx.fillRect(230, 30, 10, 10);

{{ EmbedLiveSample('Using_the_quadraticCurveTo_method', 315, 165) }}

Trying the quadraticCurveTo parameters

Edit the code below and see your changes update live in the canvas:

{{ EmbedLiveSample('Trying_the_quadraticCurveTo_parameters', 700, 360) }}

Especificações

Specification Status Comment
{{SpecName('HTML WHATWG', "scripting.html#dom-context-2d-quadraticcurveto", "CanvasRenderingContext2D.quadraticCurveTo")}} {{Spec2('HTML WHATWG')}}  

Browser compatibility

{{CompatibilityTable}}

{{CompatVersionUnknown}}
Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari
Basic support {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}}
{{CompatVersionUnknown}}
Feature Android Chrome for Android Edge Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}}

Veja também