zenozeng / p5.js-svg

SVG runtime for p5.js.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Typescript type declarations

marcw opened this issue · comments

Hello and thanks for the library.

This is a bit of a niche feature request: It would be absolutely awesome to provide type declaration for Typescript users.

Many thanks

Not niche at all :)

@PeterShershov @marcw

Hi, I just rewrote the entire lib in TypeScript and released the new version v1.5.1. If you have time, you can try it out. Additionally, I also added a TypeScript + Vite example here: https://github.com/zenozeng/p5.js-svg/blob/main/examples/vite/src/main.ts

@zenozeng thanks man! I'll test it soon

@zenozeng Hey, I just tried the Vite example and I'm getting the following error when trying to run it:

image

Here's my code (same as the example):

import "./style.css";
import p5 from "p5";
import init, { p5SVG } from "p5.js-svg";

init(p5);

const sketch = (p: p5SVG) => {
	p.setup = () => { 
            p.createCanvas(400, 400, p.SVG) 
        };

	p.draw = () => { 
            p.background(220);
            p.ellipse(50, 50, 80, 80);
	};
};

new p5(sketch, document.body);