Export to GitHub

evoluspencil - issue #92

Grayscale helper for Color property


Posted on Jun 17, 2009 by Quick Panda

I'm using a slightly modified version of Pencil due to requirements for my custom stencils. I've added a grayed() helper on the Color property, similar to hollowed(). It will return the color's grayscale value, and I'm using it for shapes with disabled appearance. Could this helper be incorporated into Pencil? It could be useful for other stencils too, and for me it means I don't have to merge my code when new Pencil releases arrive.

Color.prototype.grayed = function () { var luma = Math.round((this.r * 0.3) + (this.g * 0.59) + (this.b * 0.11));

var color = new Color();
color.r = luma;
color.g = luma;
color.b = luma;
color.a = this.a;

return color;

};

Status: New

Labels:
Type-Defect Priority-Medium