canvas

Is there a way to send video data from a video tag/MediaStream to an OffscreenCanvas?

扶醉桌前 提交于 2020-07-16 07:40:22
问题 Basically I want to be able to perform effectively this same code: const video = document.getElementById('video'); const canvas = document.getElementById('canvas'); const context = canvas.getContext('2d'); const draw = () => { context.drawImage(video, 0, 0); requestAnimationFrame(draw); } video.onplay = () => { requestAnimationFrame(draw); } only using an offscreen canvas. I can send images over messages to the worker the offscreen canvas is on, but not video as it's directly tied to an

Is there a way to send video data from a video tag/MediaStream to an OffscreenCanvas?

一笑奈何 提交于 2020-07-16 07:40:14
问题 Basically I want to be able to perform effectively this same code: const video = document.getElementById('video'); const canvas = document.getElementById('canvas'); const context = canvas.getContext('2d'); const draw = () => { context.drawImage(video, 0, 0); requestAnimationFrame(draw); } video.onplay = () => { requestAnimationFrame(draw); } only using an offscreen canvas. I can send images over messages to the worker the offscreen canvas is on, but not video as it's directly tied to an

Capture video with alpha channel using canvas.captureStream()

北慕城南 提交于 2020-07-07 08:18:50
问题 I'm trying to capture the contents of a canvas element with alpha channel. When I do it I get the RGB values correctly but the Alpha channel seems to get dropped when playing back the resulting video. Is there a way to achieve this? I'm running the following code: var stream = canvas.captureStream(60); var recorder = new MediaRecorder(stream); recorder.addEventListener('dataavailable', finishCapturing); recorder.addEventListener('stop', function(e) { video.oncanplay = video.play; video.src =

Capture video with alpha channel using canvas.captureStream()

这一生的挚爱 提交于 2020-07-07 08:18:20
问题 I'm trying to capture the contents of a canvas element with alpha channel. When I do it I get the RGB values correctly but the Alpha channel seems to get dropped when playing back the resulting video. Is there a way to achieve this? I'm running the following code: var stream = canvas.captureStream(60); var recorder = new MediaRecorder(stream); recorder.addEventListener('dataavailable', finishCapturing); recorder.addEventListener('stop', function(e) { video.oncanplay = video.play; video.src =

Manipulate canvas bytes directly from WebAssembly

自闭症网瘾萝莉.ら 提交于 2020-07-06 19:29:05
问题 I'm a total beginner to Rust and WebAssembly. I was trying to find a way to draw on a canvas element with performance in mind. To draw on a canvas using Rust and WebAssembly I usually find examples in which they would use the browser's CanvasRenderingContext2D interface and draw data on it they will receive from WASM const canvasContext = canvasElement.getContext("2d"); const canvasImageData = canvasContext.createImageData(width, height); const imageDataArray = getWasmImageDataArray()

Manipulate canvas bytes directly from WebAssembly

烈酒焚心 提交于 2020-07-06 19:28:51
问题 I'm a total beginner to Rust and WebAssembly. I was trying to find a way to draw on a canvas element with performance in mind. To draw on a canvas using Rust and WebAssembly I usually find examples in which they would use the browser's CanvasRenderingContext2D interface and draw data on it they will receive from WASM const canvasContext = canvasElement.getContext("2d"); const canvasImageData = canvasContext.createImageData(width, height); const imageDataArray = getWasmImageDataArray()

Manipulate canvas bytes directly from WebAssembly

烂漫一生 提交于 2020-07-06 19:28:28
问题 I'm a total beginner to Rust and WebAssembly. I was trying to find a way to draw on a canvas element with performance in mind. To draw on a canvas using Rust and WebAssembly I usually find examples in which they would use the browser's CanvasRenderingContext2D interface and draw data on it they will receive from WASM const canvasContext = canvasElement.getContext("2d"); const canvasImageData = canvasContext.createImageData(width, height); const imageDataArray = getWasmImageDataArray()

Shuffling multidimensional array in js

我们两清 提交于 2020-07-05 12:34:43
问题 This function shuffles only matrix[y], but I want it to shuffle matrix[y][x] But it doesn't want to shuffle correctly. The code what I used: function Shuffle(arguments) { for (var k = 0; k < arguments.length; k++) { var i = arguments[k].length; if (i == 0) return false; else { while (--i) { var j = Math.floor(Math.random() * (i + 1)); var tempi = arguments[k][i]; var tempj = arguments[k][j]; arguments[k][i] = tempj; arguments[k][j] = tempi; } return arguments; } } return arguments } var

How can I draw text that looks embossed using Kinetic JS and canvas?

偶尔善良 提交于 2020-06-29 09:41:46
问题 Update - Here is my final jsfiddle working version using Kinetic. I'm trying to show text with two different shadows to create an "embossed" look. I'm using this jsfiddle as a model of the result I'd like to get which uses CSS. Here is the jsfiddle of what I'm working on currently with Kinetic JS. var stage = new Kinetic.Stage({ container: 'stage-container', width: 400, height: 200 }); var layer = new Kinetic.Layer(); stage.add(layer); var darkShadow = new Kinetic.Text({ text: 'Hello', x: 140

Wrong color when using CopyRect to copy from large image to smaller canvas

余生长醉 提交于 2020-06-28 05:23:55
问题 I was writing a function to shrink a source image (JPG file) according to a 170 x 200px picture. The source JPG image was loaded into a TImage (Image1, fixed size of 400 x 400px, stretched to fit with aspect ration maintained), then the user will make a selection rectangle to set the area to copy, and then the image will be copied using CopyRect() onto the destination TImage (Image2). void __fastcall TSizePhotoForm::Button3Click(TObject *Sender) { float scale, base = 400.0f; TRect crect; //