<!DOCTYPE html>
<html>
<head>
<title>Рисование прямоугольников</title>
<script src='OSC.js'></script>
</head>
<body>
<canvas id='mycanvas' width='640' height='240'></canvas>
<script>
canvas = O('mycanvas')
context = canvas.getContext('2d')
S(canvas).background = 'lightblue'
//Градиент сверху вниз
//gradient = context.createLinearGradient(0, 0, 0, 270)
//Градиент слева направа
gradient = context.createLinearGradient(0, 0, 460, 0)
gradient.addColorStop(0.00, 'red')
gradient.addColorStop(0.14, 'orange')
gradient.addColorStop(0.28, 'yellow')
gradient.addColorStop(0.42, 'green')
gradient.addColorStop(0.56, 'blue')
gradient.addColorStop(0.70, 'indigo')
gradient.addColorStop(0.84, 'violet')
context.fillStyle = gradient
context.fillRect(285, 20, 135, 200)
</script>
</body>
</html> |