An example of a canvas transform which doesn't alter the canvas at all (it's the identity transform). Useful as boilerplate for making real canvas transforms which do alter the canvas.
To implement a form of middleware for image manipulation. The contract is simple. Every middlware is a function that accepts a canvas and calls a callback, providing it with an error or a canvas. This makes it easy to compose various image manipulations any way you want. See imaginate, which offers an API that does exactly this.
- returns (function) transform - A function that accepts a canvas and returns it as-is
const cIdentity = require('ctx-identity')
var canvas = document.getElementById('aCanvas')
cIdentity()(canvas, function (err, newCanvas) {
var ctx = newCanvas.getContext('2d')
...
})
const cIdentity = require('ctx-identity')
var Canvas = require('canvas')
var canvas = new Canvas()
cIdentity()(canvas, function (err, newCanvas) {
var ctx = newCanvas.getContext('2d')
...
})