mirror of
https://github.com/scrtwpns/mixbox.git
synced 2026-03-19 14:39:27 +01:00
add mixbox for javascript
This commit is contained in:
20
javascript/examples/canvas.html
Normal file
20
javascript/examples/canvas.html
Normal file
@@ -0,0 +1,20 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<canvas id="canvas" width="720" height="128"></canvas>
|
||||
<script src="https://scrtwpns.com/mixbox.js"></script>
|
||||
<script>
|
||||
var canvas = document.getElementById('canvas');
|
||||
var context = canvas.getContext("2d");
|
||||
var color1 = "rgb(0, 33, 133)"; // blue
|
||||
var color2 = "rgb(252, 211, 0)"; // yellow
|
||||
var n = canvas.width;
|
||||
for (var i = 0; i < n; i++) {
|
||||
context.fillStyle = mixbox.lerp(color1, color2, i / (n - 1));
|
||||
context.fillRect(i, 0, 1, canvas.height);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user