function toContext(context, options) {
  const canvas = context.canvas;
  options = options ? options : {};
  const pixelRatio = options.pixelRatio || DEVICE_PIXEL_RATIO;
  const size = options.size;
  if (size) {
    canvas.width = size[0] * pixelRatio;
    canvas.height = size[1] * pixelRatio;
    canvas.style.width = size[0] + 'px';
    canvas.style.height = size[1] + 'px';
  }
  const extent = [0, 0, canvas.width, canvas.height];
  const transform = scaleTransform(createTransform(), pixelRatio, pixelRatio);
  return new CanvasImmediateRenderer(context, pixelRatio, extent, transform, 0);
}
Binds a Canvas Immediate API to a canvas context, to allow drawing geometries
to the context's canvas.

The units for geometry coordinates are css pixels relative to the top left
corner of the canvas element.
```js
import {toContext} from 'ol/render.js';
import Fill from 'ol/style/Fill.js';
import Polygon from 'ol/geom/Polygon.js';

const canvas = document.createElement('canvas');
const render = toContext(
    canvas.getContext('2d'),
    {size: [100, 100]}
);
render.setFillStrokeStyle(new Fill({ color: blue }));
render.drawPolygon(
    new Polygon([[[0, 0], [100, 100], [100, 0], [0, 0]]])
);
```

@param {CanvasRenderingContext2D} context Canvas context.
@param {ToContextOptions} [options] Options.
@return {CanvasImmediateRenderer} Canvas Immediate.
@api