Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made MAX_WIND_INTENSITY configurable. Fixed links to canvas_layer.js in the examples. #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions components/renderers/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ import {getAnimationFrame, isValue} from './../utilities/functions';
import {math} from './../utilities/math';
import {palettes} from './../utilities/palettes';

// Wind velocity at which particle intensity is maximum (m/s).
const MAX_WIND_INTENSITY = 30;

// Max number of frames a particle is drawn before regeneration.
const MAX_PARTICLE_AGE = 100;

Expand Down Expand Up @@ -83,7 +80,9 @@ export class Renderer {
// Line width of a drawn particle.
particleWidth: 2,
// Reduce particle count to this fraction (improves FPS).
particleReduction: 0.1
particleReduction: 0.1,
// Wind velocity at which particle intensity is maximum (m/s).
Copy link
Owner

@dannycochran dannycochran Aug 20, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes sense to have this option configurable, but you also need to add a line after 141 so this gets updated when a user calls start or update:

this.config_.maxWindIntensity = config.maxWindIntensity || this.config_.maxWindIntensity;

Can you also add a line to wind/typedefs.js after line 52 that indicates this option is configurable? Something like:

* maxWindIntensity: (!number=) An optional integer for changing the max wind intensity.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Thanks for pointing that out. I'll fix it in a day or two.

maxWindIntensity: 30
};

// Determine the context type.
Expand Down Expand Up @@ -407,7 +406,7 @@ export class Renderer {
this.config_.colorScheme.indexFor = (m) => { // map wind speed to a style
const length = this.config_.colorScheme.length - 1;
return Math.floor(
Math.min(m, MAX_WIND_INTENSITY) / MAX_WIND_INTENSITY * length);
Math.min(m, this.config_.maxWindIntensity) / this.config_.maxWindIntensity * length);
};

this.rgbColorScheme_ = {
Expand Down Expand Up @@ -457,7 +456,7 @@ export class Renderer {
* @return {!Array<!Array<string, number>>} [hexColor, velocity]
*/
velocityScale() {
const increment = MAX_WIND_INTENSITY / this.config_.colorScheme.length;
const increment = this.config_.maxWindIntensity / this.config_.colorScheme.length;
return this.config_.colorScheme.map((color, idx) => {
idx += 1;
let value = idx * increment;
Expand Down
12 changes: 5 additions & 7 deletions dist/windable.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,6 @@ var _palettes = require('./../utilities/palettes');

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

// Wind velocity at which particle intensity is maximum (m/s).
var MAX_WIND_INTENSITY = 30;

// Max number of frames a particle is drawn before regeneration.
var MAX_PARTICLE_AGE = 100;

Expand Down Expand Up @@ -371,7 +368,9 @@ var Renderer = exports.Renderer = function () {
// Line width of a drawn particle.
particleWidth: 2,
// Reduce particle count to this fraction (improves FPS).
particleReduction: 0.1
particleReduction: 0.1,
// Wind velocity at which particle intensity is maximum (m/s).
maxWindIntensity: 30
};

// Determine the context type.
Expand Down Expand Up @@ -725,7 +724,7 @@ var Renderer = exports.Renderer = function () {
this.config_.colorScheme.indexFor = function (m) {
// map wind speed to a style
var length = _this4.config_.colorScheme.length - 1;
return Math.floor(Math.min(m, MAX_WIND_INTENSITY) / MAX_WIND_INTENSITY * length);
return Math.floor(Math.min(m, _this4.config_.maxWindIntensity) / _this4.config_.maxWindIntensity * length);
};

this.rgbColorScheme_ = {
Expand Down Expand Up @@ -779,7 +778,7 @@ var Renderer = exports.Renderer = function () {
value: function velocityScale() {
var _this5 = this;

var increment = MAX_WIND_INTENSITY / this.config_.colorScheme.length;
var increment = this.config_.maxWindIntensity / this.config_.colorScheme.length;
return this.config_.colorScheme.map(function (color, idx) {
idx += 1;
var value = idx * increment;
Expand Down Expand Up @@ -1144,7 +1143,6 @@ var WindMap = exports.WindMap = function () {
*
* @param {!ConfigPayload} config An instance of ConfigPayload.
*/

function WindMap(config) {
var _this = this;

Expand Down
Loading