| 1 |
<!DOCTYPE html> |
| 2 |
<html> |
| 3 |
<head> |
| 4 |
<title>Gradient Test</title> |
| 5 |
<style> |
| 6 |
|
| 7 |
body { |
| 8 |
text-align: center |
| 9 |
} |
| 10 |
|
| 11 |
</style> |
| 12 |
|
| 13 |
<script> |
| 14 |
|
| 15 |
window.onload = function() { |
| 16 |
var ctx = document.getElementById('c').getContext('2d'); |
| 17 |
var g = ctx.createLinearGradient(0, 0, 300, 0); |
| 18 |
g.addColorStop(0, '#000'); |
| 19 |
g.addColorStop(1 / 7, '#00f'); |
| 20 |
g.addColorStop(2 / 7, '#0f0'); |
| 21 |
g.addColorStop(3 / 7, '#0ff'); |
| 22 |
g.addColorStop(4 / 7, '#f00'); |
| 23 |
g.addColorStop(5 / 7, '#f0f'); |
| 24 |
g.addColorStop(6 / 7, '#ff0'); |
| 25 |
g.addColorStop(1, '#fff'); |
| 26 |
ctx.fillStyle = g; |
| 27 |
ctx.fillRect(0, 0, 300, 200); |
| 28 |
}; |
| 29 |
|
| 30 |
</script> |
| 31 |
</head> |
| 32 |
<body> |
| 33 |
|
| 34 |
<canvas id=c width=300 height=200></canvas> |
| 35 |
|
| 36 |
<p>This tests gradients</p> |
| 37 |
|
| 38 |
</body> |
| 39 |
</html> |