This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* openFrameworks + ofxVideoRecorder setup to record video with h264 | |
* You will need ffmpeg and libx264 in your system. On mac, you can use homebrew. | |
* reason for yuv420p: | |
* 'QuickTime only supports YUV planar color space with 4:2:0 chroma subsampling (use -vf format=yuv420p or -pix_fmt yuv420p) for H.264 video.' | |
* as mentioned here: https://trac.ffmpeg.org/wiki/Encode/H.264 | |
*/ | |
recorder.setVideoCodec("libx264"); | |
string fileName = ofToDataPath("v" + ofGetTimestampString() + ".mp4"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* This is an Applicative Order Y-Combinator written in JavaScript. Y combinator is used to formally define recursion | |
* in languages that do not support it. JavaScript already does, but studying and understanding how this works | |
* is an enlightening experience anyway. | |
* | |
* Y and Yb are identical, just written differently - pick the one that's easier to read for you. An example is provided with | |
* factorial function. | |
* | |
* If you want to learn more, this article is great: http://mvanier.livejournal.com/2897.html | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.List | |
lookAndSay :: [Int] -> [Int] | |
lookAndSay = foldr fn [] . group | |
where fn x acc = length x : head x : acc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function sphere (radius, meridians, parallels) { | |
const vertices = [] | |
for (let i = 0; i < parallels; ++i) { | |
const polar = Math.PI * i / (parallels - 1) | |
for (let j = 0; j < meridians; ++j) { | |
const azimuth = 2.0 * Math.PI * j / meridians | |
vertices.push(sphericalToCartesian(radius, azimuth, polar)) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
color current_color = tex(TEXTURE, UV); | |
float cross2(vec2 a, vec2 b ){ | |
return a.x * b.y - a.y * b.x; | |
} | |
float dist_to_line(vec2 point, vec2 line_begin, vec2 line_end) { | |
vec2 c1 = line_end - line_begin; | |
vec2 c2 = point - line_begin; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "ofMain.h" | |
#include "ofApp.h" | |
//======================================================================== | |
int main( ){ | |
ofGLFWWindowSettings settings; | |
settings.windowMode = OF_FULLSCREEN; | |
settings.glVersionMajor = 4; | |
settings.glVersionMinor = 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// -- vertex shader | |
#version 150 | |
uniform mat4 modelViewProjectionMatrix; | |
uniform float elapsedTime; | |
in vec4 position; | |
void main(){ | |
gl_Position = modelViewProjectionMatrix * vec4(position.x * sin(elapsedTime), position.y * cos(elapsedTime), position.z, position.w); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function interpolatedPairs (array) { | |
return array.slice(0, array.length - 1).map((v, i) => [v, interpolate(v, array[i + 1])]) | |
} | |
function interpolate(a, b) { | |
return (a + b) / 2 | |
} | |
function flatten (arr) { | |
return arr.reduce((acc, v) => acc.concat(v), []) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const countryMap = countryData.reduce((map, data) => Object.assign(map, {[data.name]: data}), {}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const texture = gl.createTexture(); | |
gl.bindTexture(gl.TEXTURE_2D, texture); | |
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true); | |
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image); | |
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); | |
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); |