Nurutomo2

Blending Algorithm

Sep 5th, 2018
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* Blending Algorithm */
  2.  
  3. function blend(a, b, mode = 0) {
  4.     // 0 = Normal, 1 = Dissolve, 2 = Multiply,3 = Screen
  5.     switch (mode) {
  6.     case 0:
  7.         return b;
  8.         break;
  9.     case 1:
  10.         return (~~(Math.random() * 2) == 0) ? a : b;
  11.         break;
  12.     case 2:
  13.         return a * b;
  14.         break;
  15.     case 3:
  16.         return 1 - (1 - a) * (1 - b);
  17.         break;
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment