I’m trying to create a composed color using a color choosed by me and another preset color that goes in overlay.

I’m trying to create a composed color using a color choosed by me and another preset color that goes in overlay.

To do this i used some android classes and this is the outcome:

var color = LL.pickColor(“”,some color,false);

var add = 0x9050…..;

var drawable = new ColorDrawable(color);

drawable.setColorFilter(add,PorterDuff.Mode.OVERLAY);

var col = drawable.getColor();

It gives me no error, but it returns always the choosed color.

I tried with other different PorterDuff modes and the result is always the same…

Am I doing something wrong or this is impracticable on LL?

Please i need a quick answer!!

EDIT: I did some research and i realized that setting a color filter on a ColorDrawable has no effect…

There is still another way to do the same thing??

]]>

3 Commentsto I’m trying to create a composed color using a color choosed by me and another preset color that goes in overlay.

  1. Anonymous says:

    < ![CDATA[

    What about something like



    alert(average_color(Color.YELLOW, Color.BLUE));




    function average_color(a,b){


    return Color.argb(Color.alpha(a)/2+Color.alpha(b)/2,Color.red(a)/2+Color.red(b)/2,Color.green(a)/2+Color.green(b)/2,Color.blue(a)/2+Color.blue(b)/2)


    }

    ]]>

  2. Anonymous says:

    < ![CDATA[

    Yes this should work.


    I’ll try to modify it a little bit for my purpose and I let know you if it works 😉

    ]]>

  3. Anonymous says:

    < ![CDATA[

    OK, it works ^^


    Now I can create various shades of the entered color!



    That’s the function:



    function color_shade(col,con){


    var red=


    Math.min(Math.max(Color.red(col)-con,0),(255));


    var green=


    Math.min(Math.max(Color.green(col)-con,0),(255));


    var blue=


    Math.min(Math.max(Color.blue(col)-con,0),(255));



    return Color.rgb(red,green,blue);


    }



    Thanks TrianguloY​ for your help 🙂

    ]]>

Leave a Reply

Your email address will not be published. Required fields are marked *