A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/moveTo below:

CanvasRenderingContext2D: moveTo() method - Web APIs

CanvasRenderingContext2D: moveTo() method

Baseline Widely available

The CanvasRenderingContext2D.moveTo() method of the Canvas 2D API begins a new sub-path at the point specified by the given (x, y) coordinates.

Syntax Parameters
x

The x-axis (horizontal) coordinate of the point.

y

The y-axis (vertical) coordinate of the point.

Return value

None (undefined).

Examples Creating multiple sub-paths

This example uses moveTo() to create two sub-paths within a single path. Both sub-paths are then rendered with a single stroke() call.

HTML
<canvas id="canvas"></canvas>
JavaScript

The first line begins at (50, 50) and ends at (200, 50). The second line begins at (50, 90) and ends at (280, 120).

const canvas = document.getElementById("canvas");
const ctx = canvas.getContext("2d");

ctx.beginPath();
ctx.moveTo(50, 50); // Begin first sub-path
ctx.lineTo(200, 50);
ctx.moveTo(50, 90); // Begin second sub-path
ctx.lineTo(280, 120);
ctx.stroke();
Result Specifications Browser compatibility See also

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.3