tint color image to grayscale

Out of context: Reply #2

  • Started
  • Last post
  • 12 Responses
  • fusionpixel0

    here is one way:

    import flash.filters.BitmapFilter;
    import flash.filters.ColorMatrixFilter;

    desaturation = 0;
    this.onEnterFrame = function(){

    if(desaturation = 1){
    des = -0.05;
    }
    desaturation += des;

    image_mc.filters = new Array(getDesaturationFilter(desa...
    }

    function getDesaturationFilter(t:Number...
    t = t != undefined ? t : 1;
    var r = 0.212671;
    var g = 0.715160;
    var b = 0.072169;
    return new ColorMatrixFilter(
    [t*r+1-t, t*g, t*b, 0, 0,
    t*r, t*g+1-t, t*b, 0, 0,
    t*r, t*g, t*b+1-t, 0, 0,
    0, 0, 0, 1, 0]);
    }

View thread