Skip to content

Commit

Permalink
Speed up lighten/darken
Browse files Browse the repository at this point in the history
  • Loading branch information
Phrogz committed Feb 9, 2011
1 parent 3493d80 commit 6f2f7fd
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions context_blender.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,17 @@ if (window.CanvasRenderingContext2D && CanvasRenderingContext2D.prototype.getIma
break;

case 'darken':
dst[px ] = Math.min(sRA,dRA) * demultiply;
dst[px+1] = Math.min(sGA,dGA) * demultiply;
dst[px+2] = Math.min(sBA,dBA) * demultiply;
case 'darker':
dst[px ] = (sRA>dRA ? dRA : sRA) * demultiply;
dst[px+1] = (sGA>dGA ? dGA : sGA) * demultiply;
dst[px+2] = (sBA>dBA ? dBA : sBA) * demultiply;
break;

case 'lighten':
dst[px ] = Math.max(sRA,dRA) * demultiply;
dst[px+1] = Math.max(sGA,dGA) * demultiply;
dst[px+2] = Math.max(sBA,dBA) * demultiply;
case 'lighter':
dst[px ] = (sRA<dRA ? dRA : sRA) * demultiply;
dst[px+1] = (sGA<dGA ? dGA : sGA) * demultiply;
dst[px+2] = (sBA<dBA ? dBA : sBA) * demultiply;
break;

case 'exclusion':
Expand Down

0 comments on commit 6f2f7fd

Please sign in to comment.