MCPcopy Create free account
hub / github.com/codecombat/codecombat / grayscale

Function grayscale

app/core/utils.js:744–754  ·  view source on GitHub ↗
(imageData)

Source from the content-addressed store, hash-verified

742}
743
744const grayscale = function (imageData) {
745 const d = imageData.data
746 for (let i = 0, end = d.length; i <= end; i += 4) {
747 const r = d[i]
748 const g = d[i + 1]
749 const b = d[i + 2]
750 const v = (0.2126 * r) + (0.7152 * g) + (0.0722 * b)
751 d[i] = (d[i + 1] = (d[i + 2] = v))
752 }
753 return imageData
754}
755
756// Deep compares l with r, with the exception that undefined values are considered equal to missing values
757// Very practical for comparing Mongoose documents where undefined is not allowed, instead fields get deleted

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected