html5-canvas

Javascript setInterval() function not working in drawing to canvas

喜夏-厌秋 提交于 2020-08-25 07:26:46
问题 I am trying to draw a line in a canvas. I am trying to make the line moving with time. I am using the following code to do so var ctx = mycanvas.getContext('2d'); ctx.beginPath(); for (var x = 0; x < 200; x++) { setInterval(draw(x, 0, ctx), 3000); x = x++; } And here is the draw function function draw(x, y, ctx) { ctx.moveTo(10 + x, 400); ctx.lineTo(11 + x, 400); ctx.lineWidth = 10; ctx.strokeStyle = "#ff0000"; ctx.stroke(); } But the setInterval() function is not working and the line is

How to draw a custom pie chart shape using createJS or HTML canvas API?

左心房为你撑大大i 提交于 2020-08-10 19:48:30
问题 I am working on building this specific shape: This kind of looks like a pie chart having 3 leaves with each leaf having 3 set of colours. Each colour represents a specific info about data which will be showing on a popup either by clicking or hovering over it based on JSON . This pie will be placed on the map based on the coordinates(Lat, Long) assigned to it. The small red circle at the center is the place for coordinates(Lat, Long). I might use: CreateJS to generate this kinda CreateJS

How to draw a custom pie chart shape using createJS or HTML canvas API?

随声附和 提交于 2020-08-10 19:45:30
问题 I am working on building this specific shape: This kind of looks like a pie chart having 3 leaves with each leaf having 3 set of colours. Each colour represents a specific info about data which will be showing on a popup either by clicking or hovering over it based on JSON . This pie will be placed on the map based on the coordinates(Lat, Long) assigned to it. The small red circle at the center is the place for coordinates(Lat, Long). I might use: CreateJS to generate this kinda CreateJS

Fast way to resize ImageData in browser?

情到浓时终转凉″ 提交于 2020-08-09 07:16:05
问题 I have a canvas of 600 x 400 pixels, which returns an ImageData with data length of 960,000 (600*400*4). Is there any way to downscale both width & height say 10 times, I would like to get as a result an ImageData whose data length is 9600 (60*40*4). const canvas = document.getElementsByTagName("canvas")[0] var ctx = canvas.getContext("2d"); const origImageData = ctx.getImageData(0, 0, canvas.width, canvas.height) origImageData // => ImageData {data: Uint8ClampedArray(960000), width: 600,

Fast way to resize ImageData in browser?

拜拜、爱过 提交于 2020-08-09 07:15:32
问题 I have a canvas of 600 x 400 pixels, which returns an ImageData with data length of 960,000 (600*400*4). Is there any way to downscale both width & height say 10 times, I would like to get as a result an ImageData whose data length is 9600 (60*40*4). const canvas = document.getElementsByTagName("canvas")[0] var ctx = canvas.getContext("2d"); const origImageData = ctx.getImageData(0, 0, canvas.width, canvas.height) origImageData // => ImageData {data: Uint8ClampedArray(960000), width: 600,

Disable Right Click in React.JS

ε祈祈猫儿з 提交于 2020-08-06 08:40:41
问题 How to disable right click in canvas in ReactJS. Here is what I tried which is still not working: let Canvas = <canvas onContextMenu={(e)=> {e.preventDefault(); return false;}} height={500} width={500} ref="canvas"/>; A warning is also shown in browser console. Warning: Returning false from an event handler is deprecated and will be ignored in a future release. Instead, manually call e.stopPropagation() or e.preventDefault(), as appropriate. EDIT: Yes it did stop the right click functionality

Disable Right Click in React.JS

落爺英雄遲暮 提交于 2020-08-06 08:40:28
问题 How to disable right click in canvas in ReactJS. Here is what I tried which is still not working: let Canvas = <canvas onContextMenu={(e)=> {e.preventDefault(); return false;}} height={500} width={500} ref="canvas"/>; A warning is also shown in browser console. Warning: Returning false from an event handler is deprecated and will be ignored in a future release. Instead, manually call e.stopPropagation() or e.preventDefault(), as appropriate. EDIT: Yes it did stop the right click functionality

Disable Right Click in React.JS

≡放荡痞女 提交于 2020-08-06 08:39:28
问题 How to disable right click in canvas in ReactJS. Here is what I tried which is still not working: let Canvas = <canvas onContextMenu={(e)=> {e.preventDefault(); return false;}} height={500} width={500} ref="canvas"/>; A warning is also shown in browser console. Warning: Returning false from an event handler is deprecated and will be ignored in a future release. Instead, manually call e.stopPropagation() or e.preventDefault(), as appropriate. EDIT: Yes it did stop the right click functionality

I get a “Canvas has been tainted” error in Chrome but not in FF

懵懂的女人 提交于 2020-07-18 10:42:27
问题 I'm having a problem with my Javascript implementation. The script will run in Firefox but in Chrome it says: Unable to get image data from canvas because the canvas has been tainted by cross-origin data. index.html:1 Uncaught Error: SecurityError: DOM Exception 18 Does anyone have an idea of what the cause for such inconsistent behaviour could be? 回答1: Chrome does not consider different local files to be sourced from the same domain. That is, each local file you reference via a file:// URL