Comments (1)
I got it working by doing the following:
The 'ctx' variable is undefined. That is supposed to be an object of CanvasRenderingContext2D. That can be retrieved by creating a canvas element in your document and calling .getContext('2d') on that element.
After I got that working I spotted that the x and y elements of the position vector of each particle was 'NaN' (not a number). You'll need to initialize them, I recommend random values constrained within the dimensions of your canvas to see a more appreciable effect.
Also, I see that the rendering method's call to ctx.arc uses particle.x as a parameter, this should be set to particle.pos.x (same applies for y).
After patching that up you should see something happening. Don't forget to set the width and height of your canvas, and there is a fillStyle property for the ctx variable that can be used to change the colours of the particles.
from coffee-physics.
Related Issues (12)
- Canvas renderer caching
- Attraction and Repulsion increased HOT 1
- Demos are all broken HOT 3
- Existing example without canvas
- Custom renderer for Framer
- Time-Corrected Verlet Integrator HOT 1
- images in experimental-webgl HOT 1
- Collision Behaviour Index Out of bounds bug HOT 1
- Sats not defined
- Have a rectangle shape HOT 2
- performance.now support
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 coffee-physics.