Not able to draw on whole canvas screen when screen size is small (canvas)
I am using HTML canvas to draw shapes on a web page. when the screen size is normal, I can draw on the whole screen as expected. (see the attached diagram fullscreen.png
).
On the whole browser screen:
But when I decrease the screen size, I can draw only to a limited portion of the screen. (see the attached diagram smallscreen.png
)
on the mobile screen:
I don't know why this is happening.
Any help would be appreciated.
<div class="col-11 col-xs-12">
<div class="canvas-container" id="container">
<canvas id="canvas"></canvas>
<canvas id="picker" class="fixed-bottom"></canvas>
</div>
</div>
let color = "";
let picker = new KellyColorPicker({place : 'picker', input : 'color', size : 200});
let ctx;
let canvas;
let isTouchSupported;
let isPointerSupported;
let isMSPointerSupported;
let isActive = false;
let plots = ;
let sliderSpan;
(function()
{
//test
let slider = document.getElementById("slider");
sliderSpan = slider.getElementsByTagName("span");
let pickerCanvas = picker.getCanvas();
let canvasContainer = document.getElementById("container");
canvas = document.getElementById('canvas');
ctx = canvas.getContext('2d');
canvas.width = Math.min(document.documentElement.clientWidth, window.innerWidth || 300);
canvas.height = Math.min(document.documentElement.clientHeight, window.innerHeight || 300);
canvas.style.zIndex = 19;
canvasContainer.appendChild(pickerCanvas);
canvasContainer.appendChild(canvas);
ctx.strokeStyle = picker.getCurColorRgb();
ctx.lineWidth = '3';
ctx.lineCap = ctx.lineJoin = 'round';
isTouchSupported = 'ontouchstart' in window;
isPointerSupported = navigator.pointerEnabled;
isMSPointerSupported = navigator.msPointerEnabled;
let downEvent = isTouchSupported ? 'touchstart' : (isPointerSupported ? 'pointerdown' : (isMSPointerSupported ? 'MSPointerDown' : 'mousedown'));
let moveEvent = isTouchSupported ? 'touchmove' : (isPointerSupported ? 'pointermove' : (isMSPointerSupported ? 'MSPointerMove' : 'mousemove'));
let upEvent = isTouchSupported ? 'touchend' : (isPointerSupported ? 'pointerup' : (isMSPointerSupported ? 'MSPointerUp' : 'mouseup'));
canvas.addEventListener(downEvent, startDraw, false);
canvas.addEventListener(moveEvent, draw, false);
canvas.addEventListener(upEvent, endDraw, false);
})();
function drawOnCanvas(color, plots)
{
ctx.strokeStyle = color;
ctx.beginPath();
ctx.moveTo(plots[0].x, plots[0].y);
for(let i=1; i<plots.length; i++)
{
ctx.lineTo(plots[i].x, plots[i].y);
}
ctx.stroke();
}
function draw(e)
{
e.preventDefault(); // prevent continuous touch event process e.g. scrolling!
if(!isActive) return;
let x = isTouchSupported ? (e.targetTouches[0].pageX - canvas.offsetLeft) : (e.offsetX || e.layerX - canvas.offsetLeft);
let y = isTouchSupported ? (e.targetTouches[0].pageY - canvas.offsetTop) : (e.offsetY || e.layerY - canvas.offsetTop);
plots.push({x: (x << 0), y: (y << 0)}); // round numbers for touch screens
let packet = CreatePacket();
packet.pushByte(dataType.drawing);
packet.pushString(color);
packet.pushInt(x);
packet.pushInt(y);
packet.pushString(OwnerId);
packet.pushByte(drawType.drawing);
packet.send();
drawOnCanvas(color, plots);
}
function startDraw(e)
{
color = picker.getCurColorHex();
let size = parseInt(sliderSpan[0].style.left.replace('%',''));
ctx.lineWidth = size;
e.preventDefault();
let x = isTouchSupported ? (e.targetTouches[0].pageX - canvas.offsetLeft) : (e.offsetX || e.layerX - canvas.offsetLeft);
let y = isTouchSupported ? (e.targetTouches[0].pageY - canvas.offsetTop) : (e.offsetY || e.layerY - canvas.offsetTop);
let packet = CreatePacket();
packet.pushByte(dataType.drawing);
packet.pushString(color);
packet.pushInt(x);
packet.pushInt(y);
packet.pushString(OwnerId);
packet.pushByte(drawType.start);
packet.pushByte(size);
packet.send();
isActive = true;
}
function endDraw(e)
{
e.preventDefault();
isActive = false;
plots = ;
}
css canvas bootstrap-4 html5-canvas
add a comment |
I am using HTML canvas to draw shapes on a web page. when the screen size is normal, I can draw on the whole screen as expected. (see the attached diagram fullscreen.png
).
On the whole browser screen:
But when I decrease the screen size, I can draw only to a limited portion of the screen. (see the attached diagram smallscreen.png
)
on the mobile screen:
I don't know why this is happening.
Any help would be appreciated.
<div class="col-11 col-xs-12">
<div class="canvas-container" id="container">
<canvas id="canvas"></canvas>
<canvas id="picker" class="fixed-bottom"></canvas>
</div>
</div>
let color = "";
let picker = new KellyColorPicker({place : 'picker', input : 'color', size : 200});
let ctx;
let canvas;
let isTouchSupported;
let isPointerSupported;
let isMSPointerSupported;
let isActive = false;
let plots = ;
let sliderSpan;
(function()
{
//test
let slider = document.getElementById("slider");
sliderSpan = slider.getElementsByTagName("span");
let pickerCanvas = picker.getCanvas();
let canvasContainer = document.getElementById("container");
canvas = document.getElementById('canvas');
ctx = canvas.getContext('2d');
canvas.width = Math.min(document.documentElement.clientWidth, window.innerWidth || 300);
canvas.height = Math.min(document.documentElement.clientHeight, window.innerHeight || 300);
canvas.style.zIndex = 19;
canvasContainer.appendChild(pickerCanvas);
canvasContainer.appendChild(canvas);
ctx.strokeStyle = picker.getCurColorRgb();
ctx.lineWidth = '3';
ctx.lineCap = ctx.lineJoin = 'round';
isTouchSupported = 'ontouchstart' in window;
isPointerSupported = navigator.pointerEnabled;
isMSPointerSupported = navigator.msPointerEnabled;
let downEvent = isTouchSupported ? 'touchstart' : (isPointerSupported ? 'pointerdown' : (isMSPointerSupported ? 'MSPointerDown' : 'mousedown'));
let moveEvent = isTouchSupported ? 'touchmove' : (isPointerSupported ? 'pointermove' : (isMSPointerSupported ? 'MSPointerMove' : 'mousemove'));
let upEvent = isTouchSupported ? 'touchend' : (isPointerSupported ? 'pointerup' : (isMSPointerSupported ? 'MSPointerUp' : 'mouseup'));
canvas.addEventListener(downEvent, startDraw, false);
canvas.addEventListener(moveEvent, draw, false);
canvas.addEventListener(upEvent, endDraw, false);
})();
function drawOnCanvas(color, plots)
{
ctx.strokeStyle = color;
ctx.beginPath();
ctx.moveTo(plots[0].x, plots[0].y);
for(let i=1; i<plots.length; i++)
{
ctx.lineTo(plots[i].x, plots[i].y);
}
ctx.stroke();
}
function draw(e)
{
e.preventDefault(); // prevent continuous touch event process e.g. scrolling!
if(!isActive) return;
let x = isTouchSupported ? (e.targetTouches[0].pageX - canvas.offsetLeft) : (e.offsetX || e.layerX - canvas.offsetLeft);
let y = isTouchSupported ? (e.targetTouches[0].pageY - canvas.offsetTop) : (e.offsetY || e.layerY - canvas.offsetTop);
plots.push({x: (x << 0), y: (y << 0)}); // round numbers for touch screens
let packet = CreatePacket();
packet.pushByte(dataType.drawing);
packet.pushString(color);
packet.pushInt(x);
packet.pushInt(y);
packet.pushString(OwnerId);
packet.pushByte(drawType.drawing);
packet.send();
drawOnCanvas(color, plots);
}
function startDraw(e)
{
color = picker.getCurColorHex();
let size = parseInt(sliderSpan[0].style.left.replace('%',''));
ctx.lineWidth = size;
e.preventDefault();
let x = isTouchSupported ? (e.targetTouches[0].pageX - canvas.offsetLeft) : (e.offsetX || e.layerX - canvas.offsetLeft);
let y = isTouchSupported ? (e.targetTouches[0].pageY - canvas.offsetTop) : (e.offsetY || e.layerY - canvas.offsetTop);
let packet = CreatePacket();
packet.pushByte(dataType.drawing);
packet.pushString(color);
packet.pushInt(x);
packet.pushInt(y);
packet.pushString(OwnerId);
packet.pushByte(drawType.start);
packet.pushByte(size);
packet.send();
isActive = true;
}
function endDraw(e)
{
e.preventDefault();
isActive = false;
plots = ;
}
css canvas bootstrap-4 html5-canvas
@HelderSepulveda here is my Code
– Kashif Ahmed
Nov 16 '18 at 6:50
You should try to created a smaller snippet that works and reproduces your issue... click on the [Run code snippet] buttonan you get an error
– Helder Sepulveda
Nov 16 '18 at 14:10
add a comment |
I am using HTML canvas to draw shapes on a web page. when the screen size is normal, I can draw on the whole screen as expected. (see the attached diagram fullscreen.png
).
On the whole browser screen:
But when I decrease the screen size, I can draw only to a limited portion of the screen. (see the attached diagram smallscreen.png
)
on the mobile screen:
I don't know why this is happening.
Any help would be appreciated.
<div class="col-11 col-xs-12">
<div class="canvas-container" id="container">
<canvas id="canvas"></canvas>
<canvas id="picker" class="fixed-bottom"></canvas>
</div>
</div>
let color = "";
let picker = new KellyColorPicker({place : 'picker', input : 'color', size : 200});
let ctx;
let canvas;
let isTouchSupported;
let isPointerSupported;
let isMSPointerSupported;
let isActive = false;
let plots = ;
let sliderSpan;
(function()
{
//test
let slider = document.getElementById("slider");
sliderSpan = slider.getElementsByTagName("span");
let pickerCanvas = picker.getCanvas();
let canvasContainer = document.getElementById("container");
canvas = document.getElementById('canvas');
ctx = canvas.getContext('2d');
canvas.width = Math.min(document.documentElement.clientWidth, window.innerWidth || 300);
canvas.height = Math.min(document.documentElement.clientHeight, window.innerHeight || 300);
canvas.style.zIndex = 19;
canvasContainer.appendChild(pickerCanvas);
canvasContainer.appendChild(canvas);
ctx.strokeStyle = picker.getCurColorRgb();
ctx.lineWidth = '3';
ctx.lineCap = ctx.lineJoin = 'round';
isTouchSupported = 'ontouchstart' in window;
isPointerSupported = navigator.pointerEnabled;
isMSPointerSupported = navigator.msPointerEnabled;
let downEvent = isTouchSupported ? 'touchstart' : (isPointerSupported ? 'pointerdown' : (isMSPointerSupported ? 'MSPointerDown' : 'mousedown'));
let moveEvent = isTouchSupported ? 'touchmove' : (isPointerSupported ? 'pointermove' : (isMSPointerSupported ? 'MSPointerMove' : 'mousemove'));
let upEvent = isTouchSupported ? 'touchend' : (isPointerSupported ? 'pointerup' : (isMSPointerSupported ? 'MSPointerUp' : 'mouseup'));
canvas.addEventListener(downEvent, startDraw, false);
canvas.addEventListener(moveEvent, draw, false);
canvas.addEventListener(upEvent, endDraw, false);
})();
function drawOnCanvas(color, plots)
{
ctx.strokeStyle = color;
ctx.beginPath();
ctx.moveTo(plots[0].x, plots[0].y);
for(let i=1; i<plots.length; i++)
{
ctx.lineTo(plots[i].x, plots[i].y);
}
ctx.stroke();
}
function draw(e)
{
e.preventDefault(); // prevent continuous touch event process e.g. scrolling!
if(!isActive) return;
let x = isTouchSupported ? (e.targetTouches[0].pageX - canvas.offsetLeft) : (e.offsetX || e.layerX - canvas.offsetLeft);
let y = isTouchSupported ? (e.targetTouches[0].pageY - canvas.offsetTop) : (e.offsetY || e.layerY - canvas.offsetTop);
plots.push({x: (x << 0), y: (y << 0)}); // round numbers for touch screens
let packet = CreatePacket();
packet.pushByte(dataType.drawing);
packet.pushString(color);
packet.pushInt(x);
packet.pushInt(y);
packet.pushString(OwnerId);
packet.pushByte(drawType.drawing);
packet.send();
drawOnCanvas(color, plots);
}
function startDraw(e)
{
color = picker.getCurColorHex();
let size = parseInt(sliderSpan[0].style.left.replace('%',''));
ctx.lineWidth = size;
e.preventDefault();
let x = isTouchSupported ? (e.targetTouches[0].pageX - canvas.offsetLeft) : (e.offsetX || e.layerX - canvas.offsetLeft);
let y = isTouchSupported ? (e.targetTouches[0].pageY - canvas.offsetTop) : (e.offsetY || e.layerY - canvas.offsetTop);
let packet = CreatePacket();
packet.pushByte(dataType.drawing);
packet.pushString(color);
packet.pushInt(x);
packet.pushInt(y);
packet.pushString(OwnerId);
packet.pushByte(drawType.start);
packet.pushByte(size);
packet.send();
isActive = true;
}
function endDraw(e)
{
e.preventDefault();
isActive = false;
plots = ;
}
css canvas bootstrap-4 html5-canvas
I am using HTML canvas to draw shapes on a web page. when the screen size is normal, I can draw on the whole screen as expected. (see the attached diagram fullscreen.png
).
On the whole browser screen:
But when I decrease the screen size, I can draw only to a limited portion of the screen. (see the attached diagram smallscreen.png
)
on the mobile screen:
I don't know why this is happening.
Any help would be appreciated.
<div class="col-11 col-xs-12">
<div class="canvas-container" id="container">
<canvas id="canvas"></canvas>
<canvas id="picker" class="fixed-bottom"></canvas>
</div>
</div>
let color = "";
let picker = new KellyColorPicker({place : 'picker', input : 'color', size : 200});
let ctx;
let canvas;
let isTouchSupported;
let isPointerSupported;
let isMSPointerSupported;
let isActive = false;
let plots = ;
let sliderSpan;
(function()
{
//test
let slider = document.getElementById("slider");
sliderSpan = slider.getElementsByTagName("span");
let pickerCanvas = picker.getCanvas();
let canvasContainer = document.getElementById("container");
canvas = document.getElementById('canvas');
ctx = canvas.getContext('2d');
canvas.width = Math.min(document.documentElement.clientWidth, window.innerWidth || 300);
canvas.height = Math.min(document.documentElement.clientHeight, window.innerHeight || 300);
canvas.style.zIndex = 19;
canvasContainer.appendChild(pickerCanvas);
canvasContainer.appendChild(canvas);
ctx.strokeStyle = picker.getCurColorRgb();
ctx.lineWidth = '3';
ctx.lineCap = ctx.lineJoin = 'round';
isTouchSupported = 'ontouchstart' in window;
isPointerSupported = navigator.pointerEnabled;
isMSPointerSupported = navigator.msPointerEnabled;
let downEvent = isTouchSupported ? 'touchstart' : (isPointerSupported ? 'pointerdown' : (isMSPointerSupported ? 'MSPointerDown' : 'mousedown'));
let moveEvent = isTouchSupported ? 'touchmove' : (isPointerSupported ? 'pointermove' : (isMSPointerSupported ? 'MSPointerMove' : 'mousemove'));
let upEvent = isTouchSupported ? 'touchend' : (isPointerSupported ? 'pointerup' : (isMSPointerSupported ? 'MSPointerUp' : 'mouseup'));
canvas.addEventListener(downEvent, startDraw, false);
canvas.addEventListener(moveEvent, draw, false);
canvas.addEventListener(upEvent, endDraw, false);
})();
function drawOnCanvas(color, plots)
{
ctx.strokeStyle = color;
ctx.beginPath();
ctx.moveTo(plots[0].x, plots[0].y);
for(let i=1; i<plots.length; i++)
{
ctx.lineTo(plots[i].x, plots[i].y);
}
ctx.stroke();
}
function draw(e)
{
e.preventDefault(); // prevent continuous touch event process e.g. scrolling!
if(!isActive) return;
let x = isTouchSupported ? (e.targetTouches[0].pageX - canvas.offsetLeft) : (e.offsetX || e.layerX - canvas.offsetLeft);
let y = isTouchSupported ? (e.targetTouches[0].pageY - canvas.offsetTop) : (e.offsetY || e.layerY - canvas.offsetTop);
plots.push({x: (x << 0), y: (y << 0)}); // round numbers for touch screens
let packet = CreatePacket();
packet.pushByte(dataType.drawing);
packet.pushString(color);
packet.pushInt(x);
packet.pushInt(y);
packet.pushString(OwnerId);
packet.pushByte(drawType.drawing);
packet.send();
drawOnCanvas(color, plots);
}
function startDraw(e)
{
color = picker.getCurColorHex();
let size = parseInt(sliderSpan[0].style.left.replace('%',''));
ctx.lineWidth = size;
e.preventDefault();
let x = isTouchSupported ? (e.targetTouches[0].pageX - canvas.offsetLeft) : (e.offsetX || e.layerX - canvas.offsetLeft);
let y = isTouchSupported ? (e.targetTouches[0].pageY - canvas.offsetTop) : (e.offsetY || e.layerY - canvas.offsetTop);
let packet = CreatePacket();
packet.pushByte(dataType.drawing);
packet.pushString(color);
packet.pushInt(x);
packet.pushInt(y);
packet.pushString(OwnerId);
packet.pushByte(drawType.start);
packet.pushByte(size);
packet.send();
isActive = true;
}
function endDraw(e)
{
e.preventDefault();
isActive = false;
plots = ;
}
let color = "";
let picker = new KellyColorPicker({place : 'picker', input : 'color', size : 200});
let ctx;
let canvas;
let isTouchSupported;
let isPointerSupported;
let isMSPointerSupported;
let isActive = false;
let plots = ;
let sliderSpan;
(function()
{
//test
let slider = document.getElementById("slider");
sliderSpan = slider.getElementsByTagName("span");
let pickerCanvas = picker.getCanvas();
let canvasContainer = document.getElementById("container");
canvas = document.getElementById('canvas');
ctx = canvas.getContext('2d');
canvas.width = Math.min(document.documentElement.clientWidth, window.innerWidth || 300);
canvas.height = Math.min(document.documentElement.clientHeight, window.innerHeight || 300);
canvas.style.zIndex = 19;
canvasContainer.appendChild(pickerCanvas);
canvasContainer.appendChild(canvas);
ctx.strokeStyle = picker.getCurColorRgb();
ctx.lineWidth = '3';
ctx.lineCap = ctx.lineJoin = 'round';
isTouchSupported = 'ontouchstart' in window;
isPointerSupported = navigator.pointerEnabled;
isMSPointerSupported = navigator.msPointerEnabled;
let downEvent = isTouchSupported ? 'touchstart' : (isPointerSupported ? 'pointerdown' : (isMSPointerSupported ? 'MSPointerDown' : 'mousedown'));
let moveEvent = isTouchSupported ? 'touchmove' : (isPointerSupported ? 'pointermove' : (isMSPointerSupported ? 'MSPointerMove' : 'mousemove'));
let upEvent = isTouchSupported ? 'touchend' : (isPointerSupported ? 'pointerup' : (isMSPointerSupported ? 'MSPointerUp' : 'mouseup'));
canvas.addEventListener(downEvent, startDraw, false);
canvas.addEventListener(moveEvent, draw, false);
canvas.addEventListener(upEvent, endDraw, false);
})();
function drawOnCanvas(color, plots)
{
ctx.strokeStyle = color;
ctx.beginPath();
ctx.moveTo(plots[0].x, plots[0].y);
for(let i=1; i<plots.length; i++)
{
ctx.lineTo(plots[i].x, plots[i].y);
}
ctx.stroke();
}
function draw(e)
{
e.preventDefault(); // prevent continuous touch event process e.g. scrolling!
if(!isActive) return;
let x = isTouchSupported ? (e.targetTouches[0].pageX - canvas.offsetLeft) : (e.offsetX || e.layerX - canvas.offsetLeft);
let y = isTouchSupported ? (e.targetTouches[0].pageY - canvas.offsetTop) : (e.offsetY || e.layerY - canvas.offsetTop);
plots.push({x: (x << 0), y: (y << 0)}); // round numbers for touch screens
let packet = CreatePacket();
packet.pushByte(dataType.drawing);
packet.pushString(color);
packet.pushInt(x);
packet.pushInt(y);
packet.pushString(OwnerId);
packet.pushByte(drawType.drawing);
packet.send();
drawOnCanvas(color, plots);
}
function startDraw(e)
{
color = picker.getCurColorHex();
let size = parseInt(sliderSpan[0].style.left.replace('%',''));
ctx.lineWidth = size;
e.preventDefault();
let x = isTouchSupported ? (e.targetTouches[0].pageX - canvas.offsetLeft) : (e.offsetX || e.layerX - canvas.offsetLeft);
let y = isTouchSupported ? (e.targetTouches[0].pageY - canvas.offsetTop) : (e.offsetY || e.layerY - canvas.offsetTop);
let packet = CreatePacket();
packet.pushByte(dataType.drawing);
packet.pushString(color);
packet.pushInt(x);
packet.pushInt(y);
packet.pushString(OwnerId);
packet.pushByte(drawType.start);
packet.pushByte(size);
packet.send();
isActive = true;
}
function endDraw(e)
{
e.preventDefault();
isActive = false;
plots = ;
}
let color = "";
let picker = new KellyColorPicker({place : 'picker', input : 'color', size : 200});
let ctx;
let canvas;
let isTouchSupported;
let isPointerSupported;
let isMSPointerSupported;
let isActive = false;
let plots = ;
let sliderSpan;
(function()
{
//test
let slider = document.getElementById("slider");
sliderSpan = slider.getElementsByTagName("span");
let pickerCanvas = picker.getCanvas();
let canvasContainer = document.getElementById("container");
canvas = document.getElementById('canvas');
ctx = canvas.getContext('2d');
canvas.width = Math.min(document.documentElement.clientWidth, window.innerWidth || 300);
canvas.height = Math.min(document.documentElement.clientHeight, window.innerHeight || 300);
canvas.style.zIndex = 19;
canvasContainer.appendChild(pickerCanvas);
canvasContainer.appendChild(canvas);
ctx.strokeStyle = picker.getCurColorRgb();
ctx.lineWidth = '3';
ctx.lineCap = ctx.lineJoin = 'round';
isTouchSupported = 'ontouchstart' in window;
isPointerSupported = navigator.pointerEnabled;
isMSPointerSupported = navigator.msPointerEnabled;
let downEvent = isTouchSupported ? 'touchstart' : (isPointerSupported ? 'pointerdown' : (isMSPointerSupported ? 'MSPointerDown' : 'mousedown'));
let moveEvent = isTouchSupported ? 'touchmove' : (isPointerSupported ? 'pointermove' : (isMSPointerSupported ? 'MSPointerMove' : 'mousemove'));
let upEvent = isTouchSupported ? 'touchend' : (isPointerSupported ? 'pointerup' : (isMSPointerSupported ? 'MSPointerUp' : 'mouseup'));
canvas.addEventListener(downEvent, startDraw, false);
canvas.addEventListener(moveEvent, draw, false);
canvas.addEventListener(upEvent, endDraw, false);
})();
function drawOnCanvas(color, plots)
{
ctx.strokeStyle = color;
ctx.beginPath();
ctx.moveTo(plots[0].x, plots[0].y);
for(let i=1; i<plots.length; i++)
{
ctx.lineTo(plots[i].x, plots[i].y);
}
ctx.stroke();
}
function draw(e)
{
e.preventDefault(); // prevent continuous touch event process e.g. scrolling!
if(!isActive) return;
let x = isTouchSupported ? (e.targetTouches[0].pageX - canvas.offsetLeft) : (e.offsetX || e.layerX - canvas.offsetLeft);
let y = isTouchSupported ? (e.targetTouches[0].pageY - canvas.offsetTop) : (e.offsetY || e.layerY - canvas.offsetTop);
plots.push({x: (x << 0), y: (y << 0)}); // round numbers for touch screens
let packet = CreatePacket();
packet.pushByte(dataType.drawing);
packet.pushString(color);
packet.pushInt(x);
packet.pushInt(y);
packet.pushString(OwnerId);
packet.pushByte(drawType.drawing);
packet.send();
drawOnCanvas(color, plots);
}
function startDraw(e)
{
color = picker.getCurColorHex();
let size = parseInt(sliderSpan[0].style.left.replace('%',''));
ctx.lineWidth = size;
e.preventDefault();
let x = isTouchSupported ? (e.targetTouches[0].pageX - canvas.offsetLeft) : (e.offsetX || e.layerX - canvas.offsetLeft);
let y = isTouchSupported ? (e.targetTouches[0].pageY - canvas.offsetTop) : (e.offsetY || e.layerY - canvas.offsetTop);
let packet = CreatePacket();
packet.pushByte(dataType.drawing);
packet.pushString(color);
packet.pushInt(x);
packet.pushInt(y);
packet.pushString(OwnerId);
packet.pushByte(drawType.start);
packet.pushByte(size);
packet.send();
isActive = true;
}
function endDraw(e)
{
e.preventDefault();
isActive = false;
plots = ;
}
css canvas bootstrap-4 html5-canvas
css canvas bootstrap-4 html5-canvas
edited Nov 16 '18 at 6:50
Kashif Ahmed
asked Nov 15 '18 at 13:29
Kashif AhmedKashif Ahmed
478
478
@HelderSepulveda here is my Code
– Kashif Ahmed
Nov 16 '18 at 6:50
You should try to created a smaller snippet that works and reproduces your issue... click on the [Run code snippet] buttonan you get an error
– Helder Sepulveda
Nov 16 '18 at 14:10
add a comment |
@HelderSepulveda here is my Code
– Kashif Ahmed
Nov 16 '18 at 6:50
You should try to created a smaller snippet that works and reproduces your issue... click on the [Run code snippet] buttonan you get an error
– Helder Sepulveda
Nov 16 '18 at 14:10
@HelderSepulveda here is my Code
– Kashif Ahmed
Nov 16 '18 at 6:50
@HelderSepulveda here is my Code
– Kashif Ahmed
Nov 16 '18 at 6:50
You should try to created a smaller snippet that works and reproduces your issue... click on the [Run code snippet] buttonan you get an error
– Helder Sepulveda
Nov 16 '18 at 14:10
You should try to created a smaller snippet that works and reproduces your issue... click on the [Run code snippet] buttonan you get an error
– Helder Sepulveda
Nov 16 '18 at 14:10
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53320590%2fnot-able-to-draw-on-whole-canvas-screen-when-screen-size-is-small-canvas%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53320590%2fnot-able-to-draw-on-whole-canvas-screen-when-screen-size-is-small-canvas%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
@HelderSepulveda here is my Code
– Kashif Ahmed
Nov 16 '18 at 6:50
You should try to created a smaller snippet that works and reproduces your issue... click on the [Run code snippet] buttonan you get an error
– Helder Sepulveda
Nov 16 '18 at 14:10