Returns a linear CanvasGradient initialized with the specified line as represented by the start point (x0, y0) and end point (x1, y1) of the gradient.
Method of apis/canvas/CanvasRenderingContext2Dapis/canvas/CanvasRenderingContext2D
Syntaxvar object = object.createLinearGradient(x0, y0, x1, y1);
Parameters x0
The x-coordinate, in pixels, of the start point of the gradient.
y0The y-coordinate, in pixels, of the start point of the gradient.
x1The x-coordinate, in pixels, of the end point of the gradient.
y1The y-coordinate, in pixels, of the end point of the gradient.
Return ValueReturns an object of type DOM NodeDOM Node
A CanvasGradient object that represents the new linear gradient.
ExamplesThis example creates a diagonal (upper left to lower right) gradient, fading from red to yellow, and then places a rectangle filled with the gradient onto the canvas.
<canvas id="myCanvas" width="300" height="150" style="border:1px solid blue;"></canvas>
<p>. . .</p>
<script>
var can = document.getElementById("myCanvas");
var ctxt = can.getContext("2d");
var grdt = ctxt.createLinearGradient(0, 0, 150, 150);
grdt.addColorStop(0, "red");
grdt.addColorStop(1, "yellow");
ctxt.fillStyle = grdt;
ctxt.fillRect(20, 20, 150, 100);
</script>
Related specifications
Microsoft Developer Network: Windows Internet Explorer API reference Article
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.4