susurros / evoluspencil

Automatically exported from code.google.com/p/evoluspencil
0 stars 0 forks source link

Grayscale helper for Color property #92

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
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;
};

Original issue reported on code.google.com by dejong.a...@gmail.com on 17 Jun 2009 at 9:35