-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathCanvasGradient.html
More file actions
26 lines (24 loc) · 5.22 KB
/
Copy pathCanvasGradient.html
File metadata and controls
26 lines (24 loc) · 5.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<!DOCTYPE html><html><head><meta charset="utf-8"><title>CanvasGradient JavaScript API</title><meta name="description" content="Interactive API reference for the JavaScript CanvasGradient Object. Defines a linear or radial gradient that can be used as the fillStyle or strokeStyle of a CanvasRenderingContext2D. Created through"><link rel="stylesheet" type="text/css" href="styles.css"><script type="text/javascript">var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-23450559-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();</script></head><body><script>if (sessionStorage.collapsed === 'true') {
document.body.classList.add('members-collapsed');
}
if (localStorage.theme) {
document.body.parentElement.classList.add(localStorage.theme);
}</script><div class="topnav"><a href="/">JavaScripture</a><div class="bookmarks"><a class="bookmark contribute" href="https://github.com/nkronlage/JavaScripture">Contribute via GitHub</a> <a class="bookmark" href="/feedback">Feedback</a></div></div><div class="container"><nav class="leftnav"><div id="searchContainer"><input id="searchBox" type="text" placeholder="Search (Ctrl + S)" autocomplete="false"><div id="resultsBox" style="display:none;"></div></div><div id="apichooser"><a href="#" onclick="openApiChooser(); return false;"><div class="arrow"></div><span id="selectedsets"></span></a><div id="obscure"></div><div id="apisets"><ul></ul></div></div><div class="toc"><h2>CanvasGradient</h2><div class="navgroup"><div class="group collapsed"><a href="#InstanceMethods" onclick="expandoClicked(this.parentNode); return false;"><div class="arrow"></div>Instance Methods</a><div class="subgroup"><a href="#addColorStop_Number_String">addColorStop</a></div></div></div><h2>Canvas API</h2><div id="related-apis" class="navgroup"></div><h2>All API</h2><div id="rootObjs" class="navgroup"><span class="empty">No API set selected.</span></div></div></nav><div class="content"><h1 class="declaration"><span class="object">CanvasGradient</span> <span class="type">: <a href="/Object">Object</a></span></h1><div class="metadata"></div><div class="objectdescription">Defines a linear or radial gradient that can be used as the <a href="/CanvasRenderingContext2D#fillStyle"><code>fillStyle</code></a> or <a href="/CanvasRenderingContext2D#strokeStyle"><code>strokeStyle</code></a> of a <a href="/CanvasRenderingContext2D"><code>CanvasRenderingContext2D</code></a>. Created through <a href="/CanvasRenderingContext2D#createLinearGradient"><code>createLinearGradient()</code></a> or <a href="/CanvasRenderingContext2D#createRadialGradient"><code>createRadialGradient()</code></a>.<div class="membermetadata"><a href="https://html.spec.whatwg.org/#canvasgradient" class="spec">Spec</a></div></div><div><a name="InstanceMethods"></a><h2>Instance Methods</h2><div class="member"><div class="expand-members" title="Toggle showing all descriptions and examples"></div><a name="addColorStop"></a> <a name="addColorStop_Number_String"></a><div class="declaration"><span class="membername primary">addColorStop</span>(<span class="membername">offset</span> : <a class="membertype" href="/Number">Number</a>, <span class="membername">color</span> : <a class="membertype" href="/String">String</a>) : <a class="membertype" href="/undefined">undefined</a></div><div class="member-body"><p class="description">Adds a color stop in the gradient. <code>offset</code> must be between <code>0</code> and <code>1</code>, where <code>0</code> is the start of the gradient and <code>1</code> is the end of the gradient. <code>color</code> is a string representation of the color such as <code>'black'</code>, <code>'#000'</code>, <code>'rgba(0, 0, 0, 1)'</code>, etc.</p><div class="htmlexample"><div class="codePanel"><h4>Example:</h4><textarea class="code" rows="19" cols="60" wrap="off">
<canvas id='canvas'></canvas>
<script>
var canvas = document.getElementById('canvas');
var context = canvas.getContext('2d');
var g = context.createLinearGradient(0,0,canvas.width,0);
g.addColorStop(0, 'white');
g.addColorStop(1, 'blue');
context.fillStyle = g;
context.fillRect(0,0,canvas.width,canvas.height);
</script>
</textarea><a onclick='executeHTMLExample(this.parentNode.parentNode, "CanvasGradient.addColorStop"); return false' href="#" class="run">Run</a></div><div class="resultsPanel"><h4>Results:</h4><div style="position: relative"><div class="htmlerrormessage" style="display: none"></div><iframe class="output" width="350" height="200"></iframe><pre class="results"> </pre></div></div></div><p></p></div></div></div><div class="bottomnav"><a href="/">home</a> <a href="/license">license</a> <a href="https://github.com/nkronlage/JavaScripture">contribute</a> <a href="/feedback">feedback</a> <a id="toggle-theme" href="#">toggle light/dark mode</a></div><div class="copyright">Copyright © JavaScripture Contributors</div></div></div></body><script src="javascripture.js"></script></html>