Answer the question
In order to leave comments, you need to log in
How to stream canvas to server?
Hello. At the moment I am writing a program in which I use canvas.
The problem is this: a canvas that changes every second needs to be broadcast as an image to the server, changing with each change from clients (the client can change one pixel on the canvas at a time).
At the moment, I have filed an html page in which there is a canvas canvas 1080 by 600.
<!DOCTYPE html>
<html>
<head>
<title>
Pix.Bat.
</title>
<meta charset="utf-8">
</head>
<body>
<canvas id="pixbat" width="1080" height="600">
<p>Program can't work((</p>
</canvas>
<script>
window.onload = function() {
var drawingCanvas = document.getElementById('pixbat');
if(drawingCanvas && drawingCanvas.getContext) {
var ctx = drawingCanvas.getContext('2d');
ctx.fillStyle = "red"; // смена цвета
ctx.fillRect(50, 50, 10, 10); //(координата х, координата у, длина, ширина)
ctx.fillRect(70, 50, 10, 10);
//если что размеры холста регулируются на строке 11
ctx.fillStyle = "grey";
ctx.fillRect(100, 450, 100, 100);
}
}
</script>
</body>
</html>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question