Skip to main content
1 of 3
ETHproductions
  • 50.1k
  • 6
  • 94
  • 240

JavaScript (ES6), 29 bytes

a=>n=>a.map(b=>b.map(c=>c&n))

Input is a 2D array of 24-bit integers and -16711681 for red, -65281 for green, -256 for blue. If this isn't valid, try this instead:

JavaScript (ES6), 48 bytes

a=>n=>a.map(b=>b.map(c=>c.map((d,i)=>i==n?d:0)))

Input is a 3D array of color values and 0 for red, 1 for green, 2 for blue.

ETHproductions
  • 50.1k
  • 6
  • 94
  • 240