8000 Fast color parsing by dy · Pull Request #1443 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

Fast color parsing #1443

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

Merged
merged 11 commits into from
Mar 14, 2017
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix possible edge cases
  • Loading branch information
dy committed Mar 3, 2017
commit 5aa4d57c581b059040abd9a97cf1bd9bcedaaf1d
11 changes: 8 additions & 3 deletions src/lib/gl_format_color.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var rgba = require('color-rgba');
var Colorscale = require('../components/colorscale');
var colorDflt = require('../components/color/attributes').defaultLine;

var colorDfltRgba = rgba(colorDflt);
var opacityDflt = 1;

function calculateColor(colorIn, opacityIn) {
Expand All @@ -24,7 +25,7 @@ function calculateColor(colorIn, opacityIn) {
}

function validateColor(colorIn) {
return rgba(colorIn) || rgba(colorDflt);
return rgba(colorIn) || colorDfltRgba;
}

function validateOpacity(opacityIn) {
Expand All @@ -48,11 +49,15 @@ function formatColor(containerIn, opacityIn, len) {
)
);
}
else sclFunc = validateColor;
else {
sclFunc = function (c) {
return c;
};
}

if(isArrayColorIn) {
getColor = function(c, i) {
return c[i] === undefined ? colorDflt : sclFunc(c[i]);
return c[i] === undefined ? colorDfltRgba : rgba(sclFunc(c[i]));
};
}
else getColor = validateColor;
Expand Down
0