Groovy web console

subscribe to the feed Subscribe
to this
site

ters

Published 6 years ago by tes
Actions Execute script  ▶ Edit in console Back to console Show/hide line numbers View recent scripts
def g(a,b,n){
    (0..(1.0/n)).collect{
        c->
        x={s->s.split("(?<=\\G.{2})").collect{Integer.parseInt(it,16)}};
        (0..2).collect {
            (int)(x(a).get(it)*n*c+x(b).get(it)*(1-n*c))
        }.collect {
            String.format("%X", it)
        }.join()
    }
}
def g2(a,b,n){(0..(1.0/n)).collect{c->x={s->s.split("(?<=\\G.{2})").collect{Integer.parseInt(it,16)}};(0..2).collect {(int)(x(a).get(it)*n*c+x(b).get(it)*(1-n*c))}.collect{String.format("%X",it)}.join()}}
println g('FFFFFF','000000',1/10)
println g2('FFFFFF','000000',1/10)