Skip to content

Commit

Permalink
Minor Col optim
Browse files Browse the repository at this point in the history
  • Loading branch information
deepnight committed Jun 6, 2024
1 parent 9abde28 commit f61c8aa
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/dn/Col.hx
Original file line number Diff line number Diff line change
Expand Up @@ -630,10 +630,12 @@ abstract Col(Int) from Int to Int {
/** Interpolate to given color, at % ratio **/
public inline function interpolate(to:Col, ratio:Float) : Col {
return
( M.round( M.lerp( ai, to.ai, ratio ) ) << 24 ) |
( M.round( M.lerp( ri, to.ri, ratio ) ) << 16 ) |
( M.round( M.lerp( gi, to.gi, ratio ) ) << 8 ) |
( M.round( M.lerp( bi, to.bi, ratio ) ) );
ratio<=0 ? this
: ratio>=1 ? to
: ( M.round( M.lerp( ai, to.ai, ratio ) ) << 24 ) |
( M.round( M.lerp( ri, to.ri, ratio ) ) << 16 ) |
( M.round( M.lerp( gi, to.gi, ratio ) ) << 8 ) |
( M.round( M.lerp( bi, to.bi, ratio ) ) );
}


Expand Down

0 comments on commit f61c8aa

Please sign in to comment.