MCPcopy Index your code
hub / github.com/processing/processing / blend_hard_light

Method blend_hard_light

core/src/processing/core/PImage.java:2827–2854  ·  view source on GitHub ↗

Hard Light O = OVERLAY(S, D) O = 2 MULTIPLY(D, S) = 2DS for S < 0.5 O = 2 SCREEN(D, S) - 1 = 2(S + D - DS) - 1 otherwise

(int dst, int src)

Source from the content-addressed store, hash-verified

2825 * O = 2 * SCREEN(D, S) - 1 = 2(S + D - DS) - 1 otherwise
2826 */
2827 private static int blend_hard_light(int dst, int src) {
2828 int a = src >>> 24;
2829
2830 int s_a = a + (a >= 0x7F ? 1 : 0);
2831 int d_a = 0x100 - s_a;
2832
2833 int d_r = dst & RED_MASK;
2834 int d_g = dst & GREEN_MASK;
2835 int d_b = dst & BLUE_MASK;
2836
2837 int s_r = src & RED_MASK;
2838 int s_g = src & GREEN_MASK;
2839 int s_b = src & BLUE_MASK;
2840
2841 int r = (s_r < 0x800000) ?
2842 s_r * ((d_r >>> 16) + 1) >>> 7 :
2843 0xFF0000 - ((0x100 - (d_r >>> 16)) * (RED_MASK - s_r) >>> 7);
2844 int g = (s_g < 0x8000) ?
2845 s_g * (d_g + 0x100) >>> 15 :
2846 (0xFF00 - ((0x10000 - d_g) * (GREEN_MASK - s_g) >>> 15));
2847 int b = (s_b < 0x80) ?
2848 s_b * (d_b + 1) >>> 7 :
2849 (0xFF00 - ((0x100 - d_b) * (BLUE_MASK - s_b) << 1)) >>> 8;
2850
2851 return min((dst >>> 24) + a, 0xFF) << 24 |
2852 ((dst & RB_MASK) * d_a + ((r | b) & RB_MASK) * s_a) >>> 8 & RB_MASK |
2853 ((dst & GN_MASK) * d_a + (g & GN_MASK) * s_a) >>> 8 & GN_MASK;
2854 }
2855
2856
2857 /**

Callers 2

blendColorMethod · 0.95
blit_resizeMethod · 0.95

Calls 1

minMethod · 0.95

Tested by

no test coverage detected