WebReflection / WebReflection/linkedom
Adding some emulated canvas support.
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 2.1k
- Forks
- 104
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
After viewing the Deno 2.0 anoncement video, I tryed to use observablehq's samples in deno Jupyter Notebooks.
some samplkes use canvas, and so do crash.
by implementing some ugly code I can make canvas's dependent code to works, so it's posible to use an EmulatedCanvas2D to make canvas works in linkdom.
the question is: Can a canvas like can be integrated to the project ?
for reference there is a deno Notebooks of plot-mandelbrot-set:
import * as Plot from "npm:@observablehq/plot";
import { document } from "jsr:@ry/jupyter-helper";
import { createCanvas, type EmulatedCanvas2D } from "https://deno.land/x/canvas@v1.4.2/mod.ts";
function mandelbrot(x: number, y: number) {
for (let n = 0, zr = 0, zi = 0; n < 80; ++n) {
[zr, zi] = [zr * zr - zi * zi + x, 2 * zr * zi + y];
if (zr * zr + zi * zi > 4) return n;
}
}
const old = document.createElement;
document.createElement = (...args: any[]) => {
if (args.length === 1 && args[0] === "canvas") {
let realCanvas: EmulatedCanvas2D | undefined;
const canvas = {
height: 200,
width: 200,
getContext: (drv: string) => {
realCanvas = createCanvas(canvas.width, canvas.height);
return realCanvas.getContext(drv);
},
toDataURL: () => {
return realCanvas?.toDataURL();
}
}
return canvas;
}
return old.apply(document, args);
}
Plot.raster({fill: mandelbrot, x1: -2, x2: 1, y1: -1.164, y2: 1.164}).plot({aspectRatio: 1, document})
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at linkedom's document.createElement entry point and review how the issue's EmulatedCanvas2D example supplies canvas elements and contexts. Determine the integration scope and compatibility requirements, then validate that the Observable Plot Mandelbrot notebook can create a canvas and render successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- web-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100