Skip to main content
3 of 3
added 51 characters in body
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 (e.g. [[0x0000ff,0x00ff00],[0xff0000,0xffffff]]) and 16711680 for red, 65280 for green, 255 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