Comments (7)
The global.d.ts has been created so that you do not have to import the 'p5' module. It exposes both global and instanced p5.
If you would like to use import instead then you can do the following:
- Delete global.d.ts
- Remove/Change Module setting in tsconfig,.json
You should then be able to do something like the following:
import * as p5 from 'p5';
let sketch = (p: p5) => {
p.setup = () =>{
}
p.draw = () =>{
}
}
new p5(sketch);
from p5-typescript-starter.
Hey, thanks, it worked however some functions are unavailable, such as color or radians. Do you know what is the correct way to use them? I'm trying to use p5.color('#777');
, but I'm getting 'Cannot find name color'
error.
from p5-typescript-starter.
Sorry I got confused. I think I have to pass it as a parameter or make it global.
from p5-typescript-starter.
Update: It compiles without errors, but I still get an error in the browser saying
Uncaught ReferenceError: define is not defined
at build.js:1
I also set "module": "amd"
, but no luck.
from p5-typescript-starter.
This app has been written to expect the p5.min.js in the head of the HTML page and so does not use the require methodology (global.d.ts exposes the p5.js codebase for use in the ts files).
Does this help:
https://stackoverflow.com/questions/34675659/define-is-not-defined-in-nodejs-typescript-app
Sorry I'm not much help.
from p5-typescript-starter.
Hey thanks, I replaced dependencies wiith parcel-bundle so that I don't have to provide .tsconfig and it seems to be working.
In my index.html I have:
<body>
<script src="./src/sketch.ts"></script>
</body>
And I can execute parcel index.html
to build and run everything
from p5-typescript-starter.
Brilliant :)
from p5-typescript-starter.
Related Issues (13)
- Can't access p5.dom methods HOT 4
- werid typescript error HOT 2
- How do you import/use external libraries? HOT 3
- Missing properties of p5.color HOT 4
- SourceMap directory is incorrect HOT 3
- How to use sound HOT 7
- How to use clmtrackr HOT 6
- How to deploy it to a server? HOT 3
- Routing to mulitple Sketches HOT 2
- Processing KEY constants are missing HOT 1
- createSlider seems to be undefined HOT 4
- Import destroys build HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from p5-typescript-starter.