summaryrefslogtreecommitdiff
path: root/projects/projectile/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'projects/projectile/index.js')
-rw-r--r--projects/projectile/index.js14
1 files changed, 8 insertions, 6 deletions
diff --git a/projects/projectile/index.js b/projects/projectile/index.js
index 29ebfba..9d11e8c 100644
--- a/projects/projectile/index.js
+++ b/projects/projectile/index.js
@@ -6,19 +6,18 @@ let y0=50
let g=9.81
let projectile= function (node){
-
+ let width=800
+ let height=300
+ let dots=[] // Dots that show projectile path
+
node.setup = function() {
c=node.createCanvas(width, height);
v0t=node.createElement('p', '');
katex.render("v_0", v0t.elt);
v0t.elt.style.color="#b4b4b4"
};
- let width=800
- let height=300
-
-
- let dots=[]
+ // See explanations
function x(t) {
return x0+v0*t
}
@@ -27,6 +26,7 @@ let projectile= function (node){
return height - (-1/2 * g * t**2 + v0 * t + y0)
}
+
node.draw = function() {
node.background(70);
node.noStroke();
@@ -47,8 +47,10 @@ let projectile= function (node){
v0t.position(c.position().x+m.x,c.position().y+m.y)
node.pop()
};
+
node.windowResized = function(){
v0t.position(c.position().x+m.x,c.position().y+m.y)
+ node.resizeCanvas(Math.min(window.innerWidth,width), height);
}
};