INNER CODE UNIT · TypeScript

Canvas

suchipi/hex-engine · packages/2d/src/Canvas/index.ts:20

  function Canvas(options: {
    /** You can specify an existing Canvas element to render into, if desired. If you do not, one will be created. */
    element?: HTMLCanvasElement;

    /** The background color to set the canvas to prior to drawing each frame. */
    backgroundColor: string | null;
  }) {
    useType(Canvas);

    const backgroundColor = options.backgroundColor;

    let canvas: HTMLCanvasElement;
    if (options.element) {
      canvas = options.element;
    } else {
      canvas = document.createElement("canvas");
      document.body.appendChild(canvas);
      canvas.style.userSelect = "none";

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…