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
/* Example animation function | |
* | |
* Interpolate between a start and end position. | |
* | |
* obj.x represents a position parameter (e.g. 12.2) | |
* end_pos is the value obj.x will have at the end of the animation | |
* msec is the number of milliseconds we want to run the animation for | |
* easing is a timing function that accepts a number between 0 to 1 | |
* and returns the proportion of the interpolation between start and end to move the object to. | |
* |
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 clamp (x, min, max) { | |
return Math.min(Math.max(x, min), max); | |
} | |
function springFactory (zeta, k) { | |
if (zeta < 0 || zeta >= 1) { | |
throw new Error("Parameter 1 (zeta) must be in range [0, 1). Given: " + zeta); | |
} | |
if (Math.floor(k) !== k) { |
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
var argv = require('yargs').argv, | |
gulp = require('gulp'), | |
concat = require('gulp-concat'), | |
uglify = require('gulp-uglify'), | |
stylus = require('gulp-stylus'), | |
include = require('gulp-include'), | |
minifyCss = require('gulp-minify-css'), | |
autoprefixer = require('gulp-autoprefixer'), | |
rsync = require('gulp-rsync'), | |
print = require('gulp-print') |
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
// Requires jQuery.Deferred | |
function detectVideoAlphaSupport () { | |
var _this = this; | |
if (this.state.webm_alpha_support !== undefined) { | |
return $.Deferred().resolve(this.state.webm_alpha_support).promise(); | |
} | |
var context = $('<canvas>')[0].getContext('2d'); | |
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
/* bounceFactory | |
* | |
* Consult this article: https://medium.com/@willsilversmith/the-bounce-factory-3498de1e5262#.pn5rcjp15 | |
* The variables below are annotate with comments that reference the article. | |
* | |
* Simulate a physical bouncing motion based on physics equations of motion. | |
* | |
* We assume mass and gravity = 1 as they are immaterial when we normalize both | |
* the y and t axis to 1. The length of the animation in msec will determine "gravity" | |
* and the elasticity will determine the number of bounces. |
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
/* sigmoidFactory | |
* | |
* Generate an ease-in-out function with desired steepness. | |
* Accompanying article: https://medium.com/analytic-animations/ease-in-out-the-sigmoid-factory-c5116d8abce9 | |
* | |
* Required: | |
* k: (float != 0), sharpness of ease | |
* | |
* Return: f(t), t in 0..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
/* springFactory | |
* | |
* Generate a physically realistic easing curve for a damped mass-spring system. | |
* | |
* Required: | |
* damping (zeta): [0, 1) | |
* halfcycles: 0...inf | |
* | |
* Optional: | |
* initial_position: -1..1, default 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
// Volume needs to lease the data cube | |
class Volume { | |
constructor (args) { | |
this.channel_id = args.channel_id; // volume id as corresponding to the data server | |
this.segmentation_id = args.segmentation_id; | |
this.bounds = args.bounds; |
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
/* easeOutFactory | |
* | |
* Generate an ease-out function with desired steepness. | |
* Article: https://medium.com/analytic-animations/ease-out-the-half-sigmoid-7240df433d98#.yupto8l43 | |
* | |
* Note: Values below 6 may not come to a smooth stop. | |
* | |
* Required: | |
* k: (float), sharpness of ease | |
* |
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
// Note: I found out stylus has math(x, 'sqrt') after the fact | |
sqrt(y) | |
if y < 0 | |
error("Unable to process complex roots.") | |
if y == 0 // for floating point precision | |
return 0 | |
else if y == 1 // for floating point precision | |
return 1 |
OlderNewer