Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Adding some emulated canvas support.

未关闭
#287 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
20/100
Issue 类型
功能
描述清晰度
需要澄清
活跃度
停滞
技术栈
typescript
领域
web-dev

调研方向

从 linkedom 的 document.createElement 入口点开始,检查 issue 的 EmulatedCanvas2D 示例如何提供 canvas 元素和上下文。确定集成范围和兼容性要求,然后验证 Observable Plot Mandelbrot notebook 能够创建 canvas 并成功渲染。

由索引模型根据 Issue 内容生成。

描述

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/[email protected]/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})
主要语言
HTML
星标
2.1k
派生
108
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

WebReflection/linkedom 的其他 Issue

查看 WebReflection/linkedom 的全部 Issue

相似的 Issue

更多 Web Dev Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。