Skip to content

CanvasKitInit not found #36

Description

@rylydou

When running this code using deno run -A ... I get this error: The requested module 'https://deno.land/x/canvas@v1.4.1/mod.ts' does not provide an export named 'CanvasKitInit'

My Code:

import { CanvasKitInit } from "https://deno.land/x/canvas@v1.4.1/mod.ts"

const kit = await CanvasKitInit({
	// What path would you use for locating files in deno?
	locateFile: (file) => '/node_modules/canvaskit-wasm/bin/' + file,
})

const surface = kit.MakeSurface(100, 100)!
const canvas = surface.getCanvas()!

const paint = new kit.Paint()
paint.setColor([255, 0, 0, 255])
canvas.drawCircle(25, 25, 20, paint)

const image = surface.makeImageSnapshot()!
const bytes = image.encodeToBytes()!
Deno.writeFileSync('image.png', bytes)

Before using this package I tried using canvaskit-wasm and got similar errors.

Same code but with a slightly modified header:

import CanvasKitInit from 'npm:canvaskit-wasm'

CanvasKitInit.default({ // ...

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions