Skip to content

Instantly share code, notes, and snippets.

@jsreeram
jsreeram / drawvideo.js
Created August 21, 2012 21:10
Drawing a video to canvas
// Draws a video element onto a 2D context
// output_canvas: A canvas element
// output_context: A 2D context on output_canvas
// video: A video element to draw
output_context.drawImage(video, 0, 0, output_canvas.width, output_canvas.height);
@jsreeram
jsreeram / PAConstructors.js
Created August 8, 2012 23:31
Parallel Array Constructors
// Create an empty Parallel Array
var pa0 = new ParallelArray();
// pa0 = <>
// Create a ParallelArray out of a nested JS array.
// Note that the inner arrays are also ParallelArrays
var pa1 = new ParallelArray([ [0,1], [2,3], [4,5] ]);
// pa1 = <<0,1>, <2,3>, <4.5>>
// Create a ParallelArray from another ParallelArray
function ParallelInvoke(iterationSpace, obj, fn) {
/*....*/
}
// 2D convolve. input, filter & output are 2D (nested) arrays.
function Test(input, filter, output) {
let filterHalfWidth = (filter.length/2)-1
let inputHeight = input.length;
let inputWidth = input[0].length;